|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
Get inside! Sample the range of functionality easily built with JMSL Library for Time Series Data Analysis, Heat Maps, Portfolio Optimization, Monte Carlo Simulation, Stock Price Charting and more. Download Now! |
|
#1
|
||||
|
||||
|
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! |
|
#2
|
||||
|
||||
|
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. |
|
#3
|
||||
|
||||
|
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. |
|
#4
|
||||
|
||||
|
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. |
|
#5
|
||||
|
||||
|
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. |
|
#6
|
||||
|
||||
|
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. |
|
#7
|
|||
|
|||
|
Try root.destroy
|
|
#8
|
||||
|
||||
|
That worked!
Thanks! |
|
#9
|
||||
|
||||
|
what a strange error.. Mmmm will have to test this on my XP box. glad you found the answer though
![]() Mark. |
![]() |
| Viewing: Dev Shed Forums > Programming Languages > Python Programming > Tkinker comand problem... |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|