[Tutor] Tk variable problem
Øyvind
python at kapitalisten.no
Fri Aug 6 21:51:35 CEST 2004
>> I have made a box that shows what directory is currently default. If
> one
>> wants to change the directory, one can press a button and change it.
>
> When you say a "box" I assume you mean a Label widget?
> It is important you tell us exactly what you are doing since the
> text insertion methods are slightly different betwen Labels,
> Text widgets and Entry widgets...
I guess one of my problems are that I am not too certain what each part is
called. I call it a box, since it is a square box that comes up on the
screen. However, I assume you are right. What I realy mean is a widget
with a label and a button. The label tells the user which directory that
is active now. if that is wrong, the user can press the button and select
a new. The problem is that the label is not updated with the new
selection, but rather adds a new label with the new selection. The old is
still there.
>> However, the new directory is not changing the text where the
> default one
>> is told, but rather printing the new info in addition to the old.
>
> It is very hard to read your code since the indentation has
> gone(at least for me it has!). Can you repost with plain text
> so that we can see the structure more clearly?
Sorry... I thought I did....I have updated it below.
> You also seem to have two calls to mainloop(), that usually confuses
> Tkinter... It certainly confuses me!
It is on two different tab spacings. Does that still confuse Tkinter?
>> I update the directoryinfo instead of adding the new to the old and
> wrong
>> info?
>>
>> Thanks in advance...
>>
>> def preferanser():
>> def die(event):
>> root.destroy()
>> def bildekatalog():
>> bildedir = tkFileDialog.askdirectory(initialdir='c:/bilder/')
>> print bildedir
>> blabel = Label(root)
>> xx = StringVar(root)
>> xx.set("Bildekatalog:\n" + bildedir)
>> blabel["text"] = xx.get()
>> blabel.pack()
>> root.mainloop()
>>
>> root = Tk()
>> blabel = Label(root)
>> xx = StringVar(root)
>> xx.set("Bildekatalog:\n" + bildedir)
>> blabel["height"] = 10
>> blabel["width"] = 30
>> blabel["text"] = xx.get()
>>
>> b = Button(root, text="Endre", width=10, command=bildekatalog)
>>
>> blabel.pack(side=LEFT)
>> b.pack(side=RIGHT, padx=40, pady=15)
--
This email has been scanned for viruses & spam by Decna as - www.decna.no
Denne E-post er sjekket for virus & spam av Decna as - www.decna.no
More information about the Tutor
mailing list