tags:

views:

46

answers:

1

Hi,

I'm developing a GTK app, and would like to print some messages over existing widgets rather than displaying them in the status bar, kind of like the way Mendeley does it when no document is selected:

alt text

(as opposed to what is displayed in the right pane when you select a document:)

alt text

Should I dynamically create a panel, label, ... with the appropriate message and destroy it when needed, or is there a simpler / better way?

+2  A: 

You don't need to destroy the label, even nothing forces you to do so, neither create it dynamically. You could create it when you need it or glade could do it for you. This is a minimal example but, as you notice, both labels are created only once.

import gtk

labels = []

def changeLabel(widget):
    l = p.get_children()[1]
    p.remove(l)
    nl = labels[l is l1]
    p.add2(nl)

w = gtk.Window()
w.connect('destroy', lambda w: gtk.main_quit())
p = gtk.HPaned()
w.add(p)
b = gtk.Button('change label')
b.connect('clicked', changeLabel)
p.add1(b)
l1 = gtk.Label('hello world')
l1.show()
p.add2(l1)
l2 = gtk.Label('ciao mondo')
l2.show()
labels = [l1, l2]
which = 0
w.show_all()
gtk.main()
mg
Thanks, this seems to do the job!
Anthony Labarre