I am trying to create a Gtk popup menu when a button is clicked using a handler, as shown below:
def code_clicked(self,widget,event):
newmenu=Gtk.Menu()
newitem=Gtk.MenuItem('hello')
newmenu.append(newitem)
newitem1=Gtk.MenuItem('goodbye')
newmenu.append(newitem1)
newmenu.show_all()
newmenu.popup(None,None,None,None,event.button,event.time)
return True
The menu never appears. Theoretically, the third argument to popup, func sets the position of the cursor position if set to Null. I think the problem is that if I set func to lambda x,y: (event.x,event.y,True), it displays a popup menu 100 pixels above my cursor.
I would like to find a way to open this menu under my cursor. Any help would be appreciated!
source
share