[Tkinter-discuss] Menu.unpost not working on Windows?

2010-05-04 Thread Geoff Bache
Hi all,

I've been trying to use the "unpost" method on a popup menu and I
cannot make it work on Windows. It works fine on Linux, but seems to
have no effect on Windows even in simple cases. For example this basic
example code the menu is not unposted in Windows and is shown as
without the "unpost" line. Can anyone confirm or shed any light on
this?

Regards,
Geoff

from Tkinter import *

root = Tk()

w = Label(root, text="Right-click to display menu", width=40, height=20)
w.pack()

def next(*args):
print "Next"

# create a menu
popup = Menu(root, tearoff=0)
popup.add_command(label="Next", command=next)

def do_popup(event):
# display the popup menu
popup.post(event.x_root, event.y_root)
popup.unpost()

w.bind("", do_popup)

root.mainloop()
___
Tkinter-discuss mailing list
Tkinter-discuss@python.org
http://mail.python.org/mailman/listinfo/tkinter-discuss


[Tkinter-discuss] constraining toplevel windows to be on screen?

2010-05-04 Thread Russell E. Owen
I've received a bug report that my application's windows can appear off 
screen. This happens when a user has two monitors and saves window 
positions, then runs again later with only one monitor. Tkinter is 
apparently perfectly happy to display toplevel windows entirely off 
screen. At least on Mac OS X.

The solution I've thought of is to get the full screen size using 
"root.wm_maxsize" and use that to constrain the geometry when restoring 
the window positions.

However, it is messy code because tk geometry strings are complex: they 
may be missing the extent, or the extent may be positive or negative.

So I was wondering if somebody had a simpler solution or had already 
written code they would be willing to share (and, preferably, allow me 
to redistribute in the RO package).

It would suffice to show part of each window on screen, though it would 
be better to show the whole thing.

Regards,

-- Russell

___
Tkinter-discuss mailing list
Tkinter-discuss@python.org
http://mail.python.org/mailman/listinfo/tkinter-discuss