Python Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming LanguagesPython Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
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  
Old October 9th, 2003, 12:47 PM
SolarBear's Avatar
SolarBear SolarBear is offline
onCsdfeu
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2003
Location: Canada
Posts: 100 SolarBear User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 h 7 m 43 sec
Reputation Power: 6
Send a message via ICQ to SolarBear Send a message via MSN to SolarBear
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

Reply With Quote
  #2  
Old October 9th, 2003, 05:18 PM
netytan's Avatar
netytan netytan is offline
Hello World :)
Dev Shed Frequenter (2500 - 2999 posts)
 
Join Date: Mar 2003
Location: Hull, UK
Posts: 2,529 netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level) 
Time spent in forums: 1 Week 2 Days 17 h 19 m 5 sec
Reputation Power: 63
Send a message via ICQ to netytan Send a message via AIM to netytan Send a message via MSN to netytan Send a message via Yahoo to netytan
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.
__________________
programming language development: www.netytan.com Hula


Reply With Quote
  #3  
Old October 9th, 2003, 07:36 PM
Baltor's Avatar
Baltor Baltor is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2003
Posts: 67 Baltor User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 41 m
Reputation Power: 5
I've had this problem before, try replaceing frame.quit with frame.destroy.

Reply With Quote
  #4  
Old October 10th, 2003, 12:26 AM
SolarBear's Avatar
SolarBear SolarBear is offline
onCsdfeu
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2003
Location: Canada
Posts: 100 SolarBear User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 h 7 m 43 sec
Reputation Power: 6
Send a message via ICQ to SolarBear Send a message via MSN to SolarBear
Quote:
Originally posted by netytan
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.

I've just tried it on Linux, and it works just fine. Weird.

Baltor : I'll try that... tomorrow. I can barely type now.

Reply With Quote
  #5  
Old October 10th, 2003, 03:00 AM
ilves ilves is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: May 2003
Location: Norway
Posts: 41 ilves User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 3 h 52 m 22 sec
Reputation Power: 6
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.
__________________
Good web hosting info - articles about web hosting
hb's web dev blog

Reply With Quote
  #6  
Old October 10th, 2003, 04:38 AM
netytan's Avatar
netytan netytan is offline
Hello World :)
Dev Shed Frequenter (2500 - 2999 posts)
 
Join Date: Mar 2003
Location: Hull, UK
Posts: 2,529 netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level) 
Time spent in forums: 1 Week 2 Days 17 h 19 m 5 sec
Reputation Power: 63
Send a message via ICQ to netytan Send a message via AIM to netytan Send a message via MSN to netytan Send a message via Yahoo to netytan
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.

Reply With Quote
  #7  
Old November 13th, 2003, 06:35 PM
Travis E. Travis E. is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Nov 2003
Posts: 1 Travis E. User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
I'm trying out Python too and I'm having the same problem with a Windows 98 computer.

Quote:
Originally posted by Baltor
I've had this problem before, try replaceing frame.quit with frame.destroy.


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.

Reply With Quote
  #8  
Old November 14th, 2003, 04:38 AM
netytan's Avatar
netytan netytan is offline
Hello World :)
Dev Shed Frequenter (2500 - 2999 posts)
 
Join Date: Mar 2003
Location: Hull, UK
Posts: 2,529 netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level) 
Time spent in forums: 1 Week 2 Days 17 h 19 m 5 sec
Reputation Power: 63
Send a message via ICQ to netytan Send a message via AIM to netytan Send a message via MSN to netytan Send a message via Yahoo to netytan
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.

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesPython Programming > Some very basic Tkinter help


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 3 hosted by Hostway