The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.
|
 |
|
Dev Shed Forums
> Programming Languages
> Python Programming
|
Tkinker comand problem...
Discuss Tkinker comand problem... in the Python Programming forum on Dev Shed. Tkinker comand problem... Python Programming forum discussing coding techniques, tips and tricks, and Zope related information. Python was designed from the ground up to be a completely object-oriented programming language.
|
|
 |
|
|
|
|

Dev Shed Forums Sponsor:
|
|
|

August 27th, 2003, 05:58 PM
|
 |
Contributing User
|
|
Join Date: Aug 2003
Posts: 67
Time spent in forums: 41 m
Reputation Power: 10
|
|
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!
|

August 27th, 2003, 07:03 PM
|
 |
Hello World :)
|
|
Join Date: Mar 2003
Location: Hull, UK
|
|
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.
|

August 27th, 2003, 07:27 PM
|
 |
Contributing User
|
|
Join Date: Aug 2003
Posts: 67
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.
|

August 27th, 2003, 07:45 PM
|
 |
Hello World :)
|
|
Join Date: Mar 2003
Location: Hull, UK
|
|
|
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.
|

August 27th, 2003, 08:25 PM
|
 |
Contributing User
|
|
Join Date: Aug 2003
Posts: 67
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.
|

August 27th, 2003, 08:32 PM
|
 |
Contributing User
|
|
Join Date: Aug 2003
Posts: 67
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.
|

August 27th, 2003, 08:50 PM
|
|
Contributing User
|
|
Join Date: Dec 2002
Location: Norwich, UK
Posts: 53
Time spent in forums: 9 h 1 m 53 sec
Reputation Power: 11
|
|
|
Try root.destroy
|

August 27th, 2003, 08:56 PM
|
 |
Contributing User
|
|
Join Date: Aug 2003
Posts: 67
Time spent in forums: 41 m
Reputation Power: 10
|
|
|
That worked!
Thanks!
|

August 28th, 2003, 03:21 AM
|
 |
Hello World :)
|
|
Join Date: Mar 2003
Location: Hull, UK
|
|
what a strange error.. Mmmm will have to test this on my XP box. glad you found the answer though
Mark.
|
Developer Shed Advertisers and Affiliates
| Thread Tools |
Search this Thread |
|
|
|
| Display Modes |
Rate This Thread |
Linear Mode
|
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
|