On Sun, 29 Mar 2009 19:12:23 +0100, Muddy Coder <cosmo_gene...@yahoo.com>
wrote:
Hi Folks,
I need to update the text field of a Label created in Main, but can't
find a way to do it. Please take a look at my code:
from Tkinter import *
def makemenu(r)
amenu = Menu(r)
amenu.add_command(....., command=update_label)
def update_label():
how to access mesg created in __main__ ?
if __name__ == '__main__':
root = Tk()
mesg = Label(root, text='foo\nbar\nfoo')
mesg.pack(expand=YES, fill=BOTH)
root.mainloop()
A style point: the "if __name__ == '__main__'" construct implies that
you expect your file to be included as a module at some time in the
future. When that time comes, having your menu structure rely on
module globals that will not exist (because the "mesg = Label()"
doesn't get run) will cause your program to explode messily in a
deeply confusing way.
--
Rhodri James *-* Wildebeeste Herder to the Masses
--
http://mail.python.org/mailman/listinfo/python-list