[pygtk] Submenu not getting focus
Ian Larsen
drblast at gmail.com
Sat Dec 30 06:11:47 WST 2006
Hello all,
I believe I've encountered a bug in pygtk. When creating a context
menu with a submenu, the submenu doesn't get focus until the menu item
it's attached to is clicked (even though the submenu appears when the
mouse is over the menu item.)
The upshot is that items in the sub menu don't emit the activate
signal unless the parent menu item is clicked first.
Here is some test code demonstrating this problem:
import pygtk
pygtk.require('2.0')
import gtk
class bugtest:
def hello(self, widget, data=None):
print "hello"
return False
def contextMenu(self, widget, event, data=None):
menu = gtk.Menu()
one = gtk.MenuItem("One")
menu.append(one)
submenu = gtk.Menu()
two = gtk.MenuItem("Two")
two.connect("activate", self.hello)
submenu.append(two)
one.set_submenu(submenu)
three = gtk.MenuItem("Three")
three.connect("activate", self.hello)
menu.append(three)
menu.show_all()
menu.popup(None, None, None, event.button, event.get_time())
return True
def __init__(self):
win = gtk.Window()
label = gtk.Label('Submenu bug test')
evbox = gtk.EventBox()
evbox.add(label)
win.add(evbox)
win.resize(200,200)
evbox.connect('button-release-event', self.contextMenu)
win.show_all()
def main(self):
gtk.main()
if __name__ == "__main__":
a = bugtest()
a.main()
More information about the pygtk
mailing list