|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
AT&T devCentral & BlackBerry(r) Webcast Series: BlackBerry and GPS -Build Location Awareness into your BlackBerry Applications, July 10th-1:00PM EST. Register Today!
|
|
#1
|
||||
|
||||
|
Some very basic Tkinter help
Hi, I've decided to finally get dirty with Tkinter. Anyway, I grabbed the following code from http://www.pythonware.com/library/t...hello-again.htm :
Code:
# File: hello2.py
from Tkinter import *
class App:
def __init__(self, master):
frame = Frame(master)
frame.pack()
self.button = Button(frame, text="QUIT", fg="red", command=frame.quit)
self.button.pack(side=LEFT)
self.hi_there = Button(frame, text="Hello", command=self.say_hi)
self.hi_there.pack(side=LEFT)
def say_hi(self):
print "hi there, everyone!"
root = Tk()
app = App(root)
root.mainloop()
Nothing very complicated, that's for sure, but for some reason each time I press the QUIT button, the program goes fubar and I Ctrl-Alt-Del my way out of it. I've tried it on my own PC and our university's and both get the same result. I can't see what could be wrong with the code, so any help/corrections would be appreciated.
__________________
Time is the greatest of teachers ; sadly, it kills all of its students. - Hector Berlioz |
|
#2
|
||||
|
||||
|
I've knowticed the same thing! Your script worked fine on windows XP, but if i took it to 98 or ME the console window would hang like a beast! I havn't tested this on *nix but i think its a TK thing since it doesn't seem to happen with other GUI kits..
Mark. |
|
#3
|
||||
|
||||
|
I've had this problem before, try replaceing frame.quit with frame.destroy.
|
|
#4
|
||||
|
||||
|
Quote:
I've just tried it on Linux, and it works just fine. Weird. Baltor : I'll try that... tomorrow. I can barely type now. ![]() |
|
#5
|
|||
|
|||
|
WinMe/Python 2.2.3
It worked fine a few times, then it hanged, and I couldn't even kill the dos window or restart the computer via the start menu. I remember having problems earlier when I experimented with some GUI's, and this was the reason I downloaded WxPython. Haven't done anything with WxPython so I don't know if it's any better. But I suspect it is a Tk/WinME problem. |
|
#6
|
||||
|
||||
|
Ok, maybe this is a windows/tk thing then guys
. its still there in 2.3 so i don't hold out much hope of it going away any time soon.. Anyone nowtice that it hangs more often when you've printed to the console window? In any case, if your doing anything more complex than messing arround with GUI's i'd really try some of the other great kits like wxWindows and QT. But i'm no TK fan though obviously so ![]() Mark. Last edited by netytan : October 10th, 2003 at 04:45 AM. |
|
#7
|
|||
|
|||
|
I'm trying out Python too and I'm having the same problem with a Windows 98 computer.
Quote:
I tried that, but it still doesn't quite seem to work. The QUIT button will make the buttons disappear, but the window remains. Clicking the close button in the window closes it. I guess that's better than hanging, though. Just to mess around, though, I tried changing it to "root.destroy." That seems to work. I'm quite new to Python, so if there's any reason that might a bad idea for some reason, please say so. |
|
#8
|
||||
|
||||
|
I think the general desision here was that destroy() is just as valid a way to close a widow as quit() and works better.. i wouldn't worry about it and its not going to make any differance to the rest of your programe
![]() Mark. |
![]() |
| Viewing: Dev Shed Forums > Programming Languages > Python Programming > Some very basic Tkinter help |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|