#1
  1. Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2003
    Posts
    67
    Rep Power
    12

    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!
  2. #2
  3. Hello World :)
    Devshed Frequenter (2500 - 2999 posts)

    Join Date
    Mar 2003
    Location
    Hull, UK
    Posts
    2,537
    Rep Power
    69
    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.
  4. #3
  5. Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2003
    Posts
    67
    Rep Power
    12
    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.
    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!
  6. #4
  7. Hello World :)
    Devshed Frequenter (2500 - 2999 posts)

    Join Date
    Mar 2003
    Location
    Hull, UK
    Posts
    2,537
    Rep Power
    69
    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.
  8. #5
  9. Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2003
    Posts
    67
    Rep Power
    12
    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 09:28 PM.
    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!
  10. #6
  11. Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2003
    Posts
    67
    Rep Power
    12
    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.
    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!
  12. #7
  13. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2002
    Location
    Norwich, UK
    Posts
    53
    Rep Power
    12
    Try root.destroy
  14. #8
  15. Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2003
    Posts
    67
    Rep Power
    12
    That worked!
    Thanks!
  16. #9
  17. Hello World :)
    Devshed Frequenter (2500 - 2999 posts)

    Join Date
    Mar 2003
    Location
    Hull, UK
    Posts
    2,537
    Rep Power
    69
    what a strange error.. Mmmm will have to test this on my XP box. glad you found the answer though

    Mark.

IMN logo majestic logo threadwatch logo seochat tools logo