[Tutor] Entry box + browse button
Kent Johnson
kent_johnson at skillsoft.com
Sun Aug 15 00:07:01 CEST 2004
Klas,
One thing you can do is connect the entry widgets to Tk Variables. Then any
change to the Variable will be reflected in the Entry and vice versa. By
having the Browse button set the Variable it will show up in the Entry. In
doProcessFiles() you read the value of the Variable.
Here are the changes needed to your program to set this up for the input file:
- Create infile and inputEntry like this:
self.infile = StringVar()
self.infile.set("/home/klas/Python_filer/Tragic/ebom_from_file_wider.txt")
self.inputEntry = Entry(master)
self.inputEntry["textvariable"] = self.infile
self.inputEntry.grid(row=0,column=1)
- openFile() looks like this:
def openFile(self):
import tkFileDialog
self.infile.set(tkFileDialog.askopenfilename())
- In doProcessFiles() change
inputFileName = self.inputEntry.get()
to
inputFileName = self.infile.get()
You have to make similar changes for the outputEntry.
I hope I have correctly understood what you are trying to do!
Kent
http://www.kentsjohnson.com
At 11:10 PM 8/14/2004 +0200, Klas Marteleur wrote:
>I dont know what to try actually.
>
>Some idea i had was to call a function from the "command" in
>self.inputBrowseButton (self.openFile) and change the value of self.infile in
>that function. But i am not so sure about that idea anymore.
>
>Some other idea i had was to "bind" a button the "inputEntry" but i have no
>idea how to do that, i am just fumbling in the dark....
>
>I could really need some guidance :)
More information about the Tutor
mailing list