Hi Adam!
I'm not a Tkinter expert, so I probably cannot provide the best solution for your problem. Nevertheless I tried two corrections, which adress your problem seeminly successfully
Adam Cripps schrieb:
I'm trying out Tkinter as one of my first forays into GUI programming. However, I'm having a couple of problems.
My intitial efforts can be seen at: http://www.monkeez.org/code/python/tkinter/min.txt or here [1].
Firstly, I'm trying to grab the contents of Entry widget entry1 with a StringVar and take that value to another function to print the value to the command line. However, my function 'printentry' always runs when the application is run, without the button being pressed. Then, when I do press the button, the function isn't called. However, this button is just the same as all the other buttons. Why is this?
This is because of
command=self.printentry(self.content.get())
in createWidgets. Here you don't assign the method pintentry to command, but the result of executing this method. (So it is ececuted, when createWidget is called, but not when the command is executed.
Remedy:
self.save2Button = Button(self, text = "Submit", command=self.printentry)
*and*
def printentry(self): print "ok - the submit has been pressed - \ I need to get it's value" print self.content.get()
Secondly, when I try to exit the app, the quit button doesn't kill the root, window, but just the widgets. How do I reference the root window and all, instead of just exiting the widgets?
self.destroy destroys the frame, not the root window.
Remedy:
def exiting(self): if tkMessageBox.askokcancel("Quit", "Do you really wish to quit?"): self.master.destroy()
I'm not sure if this is the canonical way of exiting a Tkinter-App :-( (Perhaps somebody knows more.)
Hope this helps, Gregor
TIA - Adam
-- Gregor Lingl Reisnerstrasse 3/19 A-1030 Wien
Telefon: +43 1 713 33 98 Mobil: +43 664 140 35 27
Autor von "Python für Kids" Website: python4kids.net _______________________________________________ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor