GTK+ Forums

Discussion forum for GTK+ and Programming. Ask questions, troubleshoot problems, view and post example code, or express your opinions.
It is currently Mon Dec 22, 2014 7:31 pm

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 
Offline

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.


Top
 Profile  
 
 Post subject:
PostPosted: Sun Jun 08, 2008 3:09 am 
Offline
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:
Code:
import gtk

def cb(widget, event, data):
    if(event.button != 3):
        return False
    m = gtk.Menu()
    i = gtk.MenuItem("Hello")
    i.show()
    m.append(i)
    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()
win.add(eb)
eb.connect("button_press_event", cb, None)
eb.show()

win.show()

gtk.main()

You can see info on gtk.Menu.popup() here:
http://www.pygtk.org/docs/pygtk/class-g ... enu--popup


Top
 Profile  
 
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: No registered users and 2 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