Ioannis Lalopoulos wrote:
I assume that you create the two windows through two different calls
to Tkinter.Tk() but you cannot enter two mainloops (at least not in a
normal way).

If you want a second window use the Toplevel widget.

Try the following, it does what you want:

import Tkinter

root = Tkinter.Tk()

my_text = Tkinter.StringVar(root)

another_window = Tkinter.Toplevel()

entry = Tkinter.Entry(root, textvar=my_text)
entry.pack()

label = Tkinter.Label(another_window, textvar=my_text)
label.pack()

root.mainloop()

In the above example, whatever you type in the entry widget in the
root window gets reflected in the label widget which is inside the
second window, the one that was created with Tkinter.Toplevel().

Hope it helps,

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

================================================
Hendrik van Rooyen  mentioned the textvar too.  Thanks Hendrik

John (Ioannis);
        It took me awhile to get your template to work for me.
        People reading this!  THE ABOVE CODE WORKS JUST FINE - AS IS!!!

My needs are slightly different and it took me a bit to get python and I on the same track. I still have reflexes that demand dictionary compliance. Global is supposed to be Global, really, not just sort of.

Once I get past the children I seem to do OK in python.

like:
mVar= '1234'            according to docs, this is a global
p='%6s\n' % mVar        same
...some code to do something
mVar= '4321'            updates a supposed global

                              these two don't think so
print p                 prints from both of these show the 1234,
print '%s' % p[:]       they do not reflect the updated 'global'


>>>
>>> mVar= '1234'
>>> mVar
'1234'
>>> p= '%s\n' % mVar
>>> p
'1234\n'
>>>
>>> mVar= '4321'
>>> mVar
'4321'
>>> print p
1234
>>> print '%s' % p[:]
1234
>>>


The definitive on Toplevel was the biggest help. All I have read have never clearly stated its purpose. (A non-root root)

per Tkinter help:
"class Toplevel(BaseWidget, Wm)
     Toplevel widget, e.g. for dialogs.
 ...
"
Since I'm not doing dialogs, I quite reading and move on.




John: Thank you again.

Today: 20090504
copy/paste from Python 2.5.2 on Linux Slackware 10.2

Steve
norse...@hughes.net
--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to