FAQ
hi,

I want to place a small widget (colorchoser) on a sub menu of
a popup menu. But - depending on the os and python version
used - I get:
- nothing or
- the widget itself.

The latter in very rare cases. When using a Tkinter.Button()
I get the same behaviour.

(win_nt4 + python 2.2 fails)
(solaris 2.6 + python 1.5 OK!)

What am I doing wrong,
is there way to achieve the desired behaviour?

here is a code snippet
-----8<----
# Code to show problem with widget on (sub-) menus
import Tkinter

def hello_cb( ):
print "hello!"

root = Tkinter.Tk( )
frame = Tkinter.Frame( root,
width 0,
height 0
)

frame.pack( )

#popup menu w/o menubar
menu0 = Tkinter.Menu( frame, tearoff=0)
menu1 = Tkinter.Menu( menu0, tearoff=0)
menu2 = Tkinter.Menu( menu0, tearoff=0)

menu2.add_command( label="sub one",
command = hello_cb)

menu2.add_command( label="sub two",
command = hello_cb)

#
# the tricky part of the deal
frm = Tkinter.Frame( menu1 )
frm.pack( )
btn = Tkinter.Button( frm,
text = ' 16 tons',
command = hello_cb)
btn.pack( )


#OK! make a 'simple' one
menu0.add_command( label="First 1",
command=hello_cb)

#doesn't work
menu0.add_cascade( label="Second is Sub ...",
menu = menu1)
#OK!
menu0.add_cascade( label="Third is Sub ...",
menu = menu2)

# pop it up
def showMenu(event):
menu0.post(event.x_root, event.y_root)

frame.bind("<Button-3>", showMenu)


Tkinter.mainloop()

----->8----

Kind Reards,

Jan (Wegner)

Search Discussions

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
grouppython-list @
categoriespython
postedNov 13, '02 at 2:18p
activeNov 13, '02 at 2:18p
posts1
users1
websitepython.org

1 user in discussion

Jan Wegner: 1 post

People

Translate

site design / logo © 2022 Grokbase