GTK+ Forums

Discussion forum for GTK+ and Programming. Ask questions, troubleshoot problems, view and post example code, or express your opinions.
It is currently Thu Aug 25, 2016 9:41 am

All times are UTC

Post new topic Reply to topic  [ 2 posts ] 
Author Message
 Post subject: Python: Right click menu
PostPosted: Fri Jun 06, 2008 11:05 pm 

Joined: Fri Jun 06, 2008 11:01 pm
Posts: 1
Hi. I've been wondering how to popup a right click menu. I want it to be launched when I right click a gtkImage widget.

Thank you.

 Post subject:
PostPosted: Sun Jun 08, 2008 3:09 am 
Never Seen the Sunlight

Joined: Thu Jun 14, 2007 11:02 pm
Posts: 923
Location: Falun, WI USA
You'll probably need to pack your gtk.Image into a gtk.EventBox, but then you should be able to do something like this:
import gtk

def cb(widget, event, data):
    if(event.button != 3):
        return False
    m = gtk.Menu()
    i = gtk.MenuItem("Hello")
    m.popup(None, None, None, event.button, event.time, None)
    return False

win = gtk.Window()
win.connect("delete_event", gtk.main_quit)

eb = gtk.EventBox()
eb.connect("button_press_event", cb, None)


You can see info on gtk.Menu.popup() here: ... enu--popup

Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 

All times are UTC

Who is online

Users browsing this forum: Yahoo [Bot] and 4 guests

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group