Dorzu
May 12th, 2009, 04:02 AM
I recently decided that I wanted to expand from command line scripts to GUI interfaces. I've been using a WYSIWYG GUI creator on Solaris so I understand the concepts of Widgets, Containers, et cetera. However, I haven't ever made a solid attempt at coding one "from scratch", so I decided to apply my Python and use Tkinter to convert a script.
I worked through a couple of examples, read the pythonware.com tutorial, and now I'm trying to convert one of my simpler scripts. Of course, I finished most of it and found an error that I cannot correct, despite searching and reading man pages/tutorials.
How do I make a variable update after typing in an Entry widget?
Some code from my little project:
self.filename = ""
Label(master, text="File: ", justify="right").grid(row=0)
self.file_entry = Entry(root, textvariable=self.filename)
self.file_entry.grid(row=1)
open = Button(root, text='Browse', command=self.askopenfilename).grid(row=2)
#The open command gets a filename and sets self.filename.
It works just fine, but, if I type something _new_ into the text field, the filename variable isn't updated.
This is troublesome because I have another problem elsewhere that behaves the same way. Unlike the code above, I have one entry field that doesn't have a method acting to set the variable. As a result, its behavior is to print a value of "PY_VAR3"(Type: instance?) since it hasn't been set by the first use in my source code.
Any ideas? I'm very lost. I can post/attach the full source if necessary.:confused:
I worked through a couple of examples, read the pythonware.com tutorial, and now I'm trying to convert one of my simpler scripts. Of course, I finished most of it and found an error that I cannot correct, despite searching and reading man pages/tutorials.
How do I make a variable update after typing in an Entry widget?
Some code from my little project:
self.filename = ""
Label(master, text="File: ", justify="right").grid(row=0)
self.file_entry = Entry(root, textvariable=self.filename)
self.file_entry.grid(row=1)
open = Button(root, text='Browse', command=self.askopenfilename).grid(row=2)
#The open command gets a filename and sets self.filename.
It works just fine, but, if I type something _new_ into the text field, the filename variable isn't updated.
This is troublesome because I have another problem elsewhere that behaves the same way. Unlike the code above, I have one entry field that doesn't have a method acting to set the variable. As a result, its behavior is to print a value of "PY_VAR3"(Type: instance?) since it hasn't been set by the first use in my source code.
Any ideas? I'm very lost. I can post/attach the full source if necessary.:confused: