Tkinter OptionMenu: width of items in menu

2004-12-29 Thread mariox19
Hello,

The Tkinter OptionMenu widget has me a bit confused. I have set up an
OptionMenu to expand along the X axis as the window expands. What I
find though is that the width of the submenu displaying the list of
items in the menu does not expand.

This is the object I'm talking about:



popup = OptionMenu(master, StringVar(), "")
theObjectIAmTalkingAbout = popup["menu"]



When I click on the OptionMenu, I notice that the list of items is only
about as wide as the longest word in the list, even if the OptionMenu
width extends for the entire width of the screen. This not only looks
funny, but interferes with usability. (If you click on the right side
of the OptionMenu, you have to move the mouse over to the left to
highlight one of the choices in the list.)

Am I missing something? Does anyone know how to get the submenu (the
list) of an OptionMenu to expand as well? Thanks!

Mario

-- 
http://mail.python.org/mailman/listinfo/python-list


Text widget updates only after calling method exits (threading issue?)

2007-12-11 Thread mariox19
Are Tkinter widgets running on their own thread?

If I try to make a simple application that will print the letters A to
Z to a Tkinter Text widget, and I space the printing of each letter by
1 second, it seems no text will appear in the Text widget until the
method exits.

Take a look at this snippet:

# Assume I have created no threads other than the one that comes
with Main

def printToTkinterTextWidget(text):
"""
Prints A-Z to the Text widget, 1 letter per second.
"""
# Problem: no text appears in the widget until 26 seconds has
elapsed
for aNumber in range(65, 91):
self.textWidget.insert(END, text)
time.sleep(1)

If I am supposed to send messages to Tkinter objects only from the
main thread, how can I get the letters to appear 1 per second?

Thanks,

Mario

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Text widget updates only after calling method exits (threading issue?)

2007-12-12 Thread mariox19
*** SOLVED ***

Thanks, Eric. I've had luck with code along these lines:

# 1. Assume Text widget as instance variable: textView
# 2. Assume button with method, 'start', bound to it

def start(self, event=None):
"""
Starts the demo.
"""
# Print A-Z to widget, pausing 1/10 second between each letter
for aNumber in range(65, 91):
self.textView.insert(END, chr(aNumber))
self.textView.update_idletasks()
time.sleep(0.1)

The code does just what I want it to.

Mario

On Dec 12, 3:43 am, "Eric Brunel" <[EMAIL PROTECTED]> wrote:
> On Wed, 12 Dec 2007 02:58:37 +0100, mariox19 <[EMAIL PROTECTED]> wrote:
> > Are Tkinter widgets running on their own thread?
>
> No. And usually, GUI toolkits and threads don't mix well...
>
>
>
> > If I try to make a simple application that will print the letters A to
> > Z to a Tkinter Text widget, and I space the printing of each letter by
> > 1 second, it seems no text will appear in the Text widget until the
> > method exits.
>
> > Take a look at this snippet:
>
> > # Assume I have created no threads other than the one that comes
> > with Main
>
> > def printToTkinterTextWidget(text):
> > """
> > Prints A-Z to the Text widget, 1 letter per second.
> > """
> > # Problem: no text appears in the widget until 26 seconds has
> > elapsed
> > for aNumber in range(65, 91):
> > self.textWidget.insert(END, text)
> > time.sleep(1)
>
> time.sleep will not give back the control to the Tkinter mainloop, so your
> text widget won't be refreshed on screen. Try:
> self.textWidget.update_idletasks()
> before the sleep.
>
> HTH
> --
> python -c "print ''.join([chr(154 - ord(c)) for c in
> 'U(17zX(%,5.zmz5(17l8(%,5.Z*(93-965$l7+-'])"

-- 
http://mail.python.org/mailman/listinfo/python-list