[Tutor] Tk variable problem

Øyvind python at kapitalisten.no
Fri Aug 6 16:39:59 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.
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. How can
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)

		root.mainloop()



-- 
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