Python Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

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:
  #1  
Old August 27th, 2003, 05:58 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: 10
Question Tkinker comand problem...

This code:

self.exit = Button(master, text="Exit", command=root.quit)

This code doesn't seem to work. When I press the button it just freezes the program, a "illegal operation" occurs, and it is forced to close. I also tried:

self.exit = Button(master, text="Exit", command=frame.quit)

But that didn't work either. Does anyone know why this is happening.
Thanks.
__________________
Before you criticize someone, walk a mile in their shoes, that way when you do criticize them, you're a mile away and you have their shoes!

Reply With Quote
  #2  
Old August 27th, 2003, 07:03 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,537 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 18 h 17 m 47 sec
Reputation Power: 68
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
Hey Baltor,

I'm not sure this will work as I don't have the rest of your code infront of me but try self.exit = Button(master, text="Exit", command=master.quit) if that doesn't work post the rest of your code and i'll take a look.

Take care,
Mark.

Reply With Quote
  #3  
Old August 27th, 2003, 07:27 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: 10
That didn't work; same problem.
Here is the rest of my code:
Note: It isn't finished so some stuff doesn' work.

Code:
# Dice Roller Program
# By Evan Patterson

from Tkinter import *

class App:

    def __init__(self, master):

        frame = Frame(master)

        # Labels        
        self.label1 = Label(master, text="# of Rolls:")
        self.label2 = Label(master, text="# of Sides:")
        self.label3 = Label(master, text="Results:")
        self.label4 = Label(master, text="Dice Roller\n by Evan Patterson")
        self.label1.grid(sticky=E)
        self.label2.grid(sticky=E)
        self.label3.grid(sticky=E)
        self.label4.grid(row=0, column=2, columnspan=2, rowspan=2)

        # Entries
        self.entry1 = Entry(master)
        self.entry2 = Entry(master)
        self.results = Entry(master)
        self.entry1.grid(row=0, column=1)
        self.entry2.grid(row=1, column=1)
        self.results.grid(row=2, column=1)
    
        # Buttons
        self.exit = Button(master, text="Exit", command=master.quit)
        self.roll = Button(master, text="Roll!", command=self.roll)
        self.roll.grid(row=3, column=2)
        self.exit.grid(row=3, column=3)
        
        # Checkpoint
        self.rollopt = IntVar()
        checkbutton = Checkbutton(master, text="Don't Add Rolls Together", variable=self.rollopt , command=self.roll)
        checkbutton.grid(columnspan=2, column=0, row=3, sticky=W)
                       
    def roll(self):
        if rollopt == 0:
            rollr = random.randint(1, self.entry2)
        
root = Tk()
app = App(root)
root.title("Dice Roller")
root.mainloop()

Thanks for your help.

Reply With Quote
  #4  
Old August 27th, 2003, 07:45 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,537 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 18 h 17 m 47 sec
Reputation Power: 68
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
Balor what version of Python are you running and on what platform because this code works fine for me :S. If you could post the error your getting that might shed some light on whats going on here..

Python 2.3 on Windows ME

Mark.

Reply With Quote
  #5  
Old August 27th, 2003, 08:25 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: 10
I'm running Python 2.3 on Windows XP Home Edition.
This is the error:

Script '[adress of the program]' returned exit code 0.

Then it says;

Runtime Error!
This application has requested the Runtime to terminate in an unusual way. Please contact the programs support team for more information.

Then, after hitting OK, it says:

The instruction at "0x73dd1351" referenced a memory at "0x000000004". The memory could not be read. Click OK to terminate the program.

I have no idea why it is doing this....

Last edited by Baltor : August 27th, 2003 at 08:28 PM.

Reply With Quote
  #6  
Old August 27th, 2003, 08:32 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: 10
BTW, that's on Pythonwin.
In IDLE it just gives you the windows "This program is not responding, etc, etc"
Just a bit more info.

Reply With Quote
  #7  
Old August 27th, 2003, 08:50 PM
sacrilege sacrilege is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Dec 2002
Location: Norwich, UK
Posts: 53 sacrilege User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 9 h 1 m 53 sec
Reputation Power: 11
Try root.destroy

Reply With Quote
  #8  
Old August 27th, 2003, 08:56 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: 10
That worked!
Thanks!

Reply With Quote
  #9  
Old August 28th, 2003, 03:21 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,537 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 18 h 17 m 47 sec
Reputation Power: 68
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
what a strange error.. Mmmm will have to test this on my XP box. glad you found the answer though

Mark.

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesPython Programming > Tkinker comand problem...

Developer Shed Advertisers and Affiliates



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 | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap