textvariable help
I must be missing something basic. Can anyone explain why 'A' does not show on the entry widget? import Tkinter root = Tkinter.Tk() class Col: Rows = [0] def __init__(self): Frame = Tkinter.Frame(root); Frame.pack (side='left') self.Rows[0] = Tkinter.StringVar(); Tkinter.Entry(Frame,textvariable=self.Rows[0]).pack (); X = Col() # X.Rows[0].set ('A') # 'A' displays in Entry this way Y = Col() X.Rows[0].set ('A') # Why not also this way? Y.Rows[0].set ('B') root.mainloop() -- http://mail.python.org/mailman/listinfo/python-list
Re: textvariable help
swisscheese wrote: I must be missing something basic. Can anyone explain why 'A' does not show on the entry widget? import Tkinter root = Tkinter.Tk() class Col: Rows = [0] def __init__(self): Frame = Tkinter.Frame(root); Frame.pack (side='left') self.Rows[0] = Tkinter.StringVar(); Tkinter.Entry(Frame,textvariable=self.Rows[0]).pack (); X = Col() # X.Rows[0].set ('A') # 'A' displays in Entry this way Y = Col() X.Rows[0].set ('A') # Why not also this way? Y.Rows[0].set ('B') root.mainloop() Rows is a class variable, and since you're modifying it in place, Rows[0] will always be set to the most recently created Entry widget. what is it you're trying to do here ? /F -- http://mail.python.org/mailman/listinfo/python-list
Re: textvariable help
Thanks for the quick reply. With your reply and another tutorial I get it now. I needed self.Rows = ... in the constructor. I find myself wasting a lot of time with poor python docs. Whatever time Python is supposed to save I'm losing so far in looking up things. I suppose that will change as I get past the learning curve. Are you aware of any good docs on python that make it easy to find things? -- http://mail.python.org/mailman/listinfo/python-list
Re: textvariable help
swisscheese wrote: Thanks for the quick reply. With your reply and another tutorial I get it now. I needed self.Rows = ... in the constructor. I find myself wasting a lot of time with poor python docs. Whatever time Python is supposed to save I'm losing so far in looking up things. I suppose that will change as I get past the learning curve. Are you aware of any good docs on python that make it easy to find things? just curious, but what documentation told you to use a class variable in the way you did ? /F -- http://mail.python.org/mailman/listinfo/python-list
Re: textvariable help
None - it was a false impression I got somehow. -- http://mail.python.org/mailman/listinfo/python-list
Re: textvariable help
swisscheese wrote: Thanks for the quick reply. With your reply and another tutorial I get it now. I needed self.Rows = ... in the constructor. I find myself wasting a lot of time with poor python docs. I have found the standard library documentation amazingly well written: http://www.python.org/doc/ Whatever time Python is supposed to save I'm losing so far in looking up things. I suppose that will change as I get past the learning curve. Python will save you a lot of time when you come back to your code 6 months later and when you begin to get some competence at the more esoteric aspects of python, like generators, closures, and magic methods. Are you aware of any good docs on python that make it easy to find things? It depends on your task. Jumping into GUI programming without a solid grasp of the language you are writing in can be frustrating. In fact jumping into GUI programming at all can be frustrating. I learnt from Learning Python by O'Reilly. Beyond that I highly recommend Python Programming. I especially recommend chapters 2, 3, 6, 7, and 8 of the latter. If you have the time, try to get through as much of both of those as you can. Beyond that, you may want to keep a copy of Python in a Nutshell by your keyboard. I use the classic Python Essential Reference, which is now pretty dated. If you have not worked through a tutorial on python basics, you should really stop what you are doing and spend a few hours doing that. It will make you much more pleased with the language. James -- http://mail.python.org/mailman/listinfo/python-list
Re: textvariable help
Thanks - actually I have some of those books on the way from amazon. The first couple of days with a new language are always the hardest! -- http://mail.python.org/mailman/listinfo/python-list