Issue #6615: logging: Used weak references in internal handler list. Thanks to flox...
[python.git] / Demo / tix / samples / PopMenu.py
blob32f322929489e1981ac32cd25f0ab2c16aa119cd
1 # -*-mode: python; fill-column: 75; tab-width: 8; coding: iso-latin-1-unix -*-
3 # $Id$
5 # Tix Demostration Program
7 # This sample program is structured in such a way so that it can be
8 # executed from the Tix demo program "tixwidgets.py": it must have a
9 # procedure called "RunSample". It should also have the "if" statment
10 # at the end of this file so that it can be run as a standalone
11 # program using tixwish.
13 # This file demonstrates the use of the tixPopupMenu widget.
15 import Tix
17 def RunSample(w):
18 # We create the frame and the button, then we'll bind the PopupMenu
19 # to both widgets. The result is, when you press the right mouse
20 # button over $w.top or $w.top.but, the PopupMenu will come up.
22 top = Tix.Frame(w, relief=Tix.RAISED, bd=1)
23 but = Tix.Button(top, text='Press the right mouse button over this button or its surrounding area')
24 but.pack(expand=1, fill=Tix.BOTH, padx=50, pady=50)
26 p = Tix.PopupMenu(top, title='Popup Test')
27 p.bind_widget(top)
28 p.bind_widget(but)
30 # Set the entries inside the PopupMenu widget.
31 # [Hint] You have to manipulate the "menu" subwidget.
32 # $w.top.p itself is NOT a menu widget.
33 # [Hint] Watch carefully how the sub-menu is created
35 p.menu.add_command(label='Desktop', underline=0)
36 p.menu.add_command(label='Select', underline=0)
37 p.menu.add_command(label='Find', underline=0)
38 p.menu.add_command(label='System', underline=1)
39 p.menu.add_command(label='Help', underline=0)
40 m1 = Tix.Menu(p.menu)
41 m1.add_command(label='Hello')
42 p.menu.add_cascade(label='More', menu=m1)
44 but.pack(side=Tix.TOP, padx=40, pady=50)
46 box = Tix.ButtonBox(w, orientation=Tix.HORIZONTAL)
47 box.add('ok', text='Ok', underline=0, width=6,
48 command=lambda w=w: w.destroy())
49 box.add('cancel', text='Cancel', underline=0, width=6,
50 command=lambda w=w: w.destroy())
51 box.pack(side=Tix.BOTTOM, fill=Tix.X)
52 top.pack(side=Tix.TOP, fill=Tix.BOTH, expand=1)
54 if __name__ == '__main__':
55 root = Tix.Tk()
56 RunSample(root)
57 root.mainloop()