Here is the simple one.
from gnome.ui import *
import GDK
win = GtkWindow()
win.connect('destroy', mainquit)
canvas = GnomeCanvas()
canvas.set_usize(300, 300)
canvas.set_scroll_region(0,0,300,300)
rect = canvas.root().add('rect',
x1=150,y1=150,x2=250,y2=250,
fill_color='blue4', outline_color='blue',
width_pixels=2)
circle = canvas.root().add('ellipse',
x1=50,y1=50,x2=150,y2=150,
fill_color='blue4', outline_color='blue',
width_pixels=2)
def create_popup():
menu=GtkMenu()
item = GtkMenuItem('shieree1')
item.show()
menu.append(item)
def cb(item): print 'shieree1'
item.connect('activate', cb)
item = GtkMenuItem('shieree2')
item.show()
menu.append(item)
def cb(item): print 'shieree2'
item.connect('activate', cb)
return menu
menu = create_popup()
def event_cb(item, event):
if event.type == GDK.BUTTON_PRESS and event.button == 3:
print item.get_data('shape')
menu.popup(None, None, None, 3, 0)
return TRUE
return FALSE
rect.set_data('shape', 'rect')
rect.connect('event', event_cb)
circle.set_data('shape', 'circle')
circle.connect('event', event_cb)
win.add(canvas)
win.show_all()
mainloop()
On Sun, 28 Mar 1999, Rick Ree wrote:
> I'm working on a program that will allow the graphical manipulation of
> phylogenetic trees using pygnome. I would like to be able to right-click
> on a canvas item (e.g. a tree node) and have a popup menu appear, with
> operations to perform on that node.
>
> I haven't come across any python examples for popup menus. Does anyone
> have any hints/suggestions/example pseudocode?
>
> Thanks! Cheers,
> Rick
>
> To unsubscribe: echo "unsubscribe" | mail [EMAIL PROTECTED]
>
To unsubscribe: echo "unsubscribe" | mail [EMAIL PROTECTED]