#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2012
    Posts
    18
    Rep Power
    0

    Python Graphics Module Close Button


    How do I make it so that when it's closed by the windows close button by the user, the program doesn't crash?
  2. #2
  3. Contributing User
    Devshed Demi-God (4500 - 4999 posts)

    Join Date
    Aug 2011
    Posts
    4,850
    Rep Power
    481
    try root.destroy

    You may have to read sources to figure out what "root" is.
    [code]Code tags[/code] are essential for python code and Makefiles!
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2012
    Posts
    18
    Rep Power
    0
    Upon looking at the code again, I honestly can't figure out what the root is, is there perhaps a way in which to disable the default Windows close button?
  6. #4
  7. Contributing User
    Devshed Demi-God (4500 - 4999 posts)

    Join Date
    Aug 2011
    Posts
    4,850
    Rep Power
    481
    what is the graphics module?

    if you mean this thing then it's either

    graphics._root . destroy()

    or

    _root.destroy()

    depending on how you imported it.

    I suppose you'll also need to catch the event from the window manager.
    [code]Code tags[/code] are essential for python code and Makefiles!
  8. #5
  9. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2012
    Posts
    18
    Rep Power
    0
    I've tried stuff like

    Code:
    if RegisterScreen.isClose():
            _root.destroy()
    But it doesn't work. I've really no Idea how to capture the event of the user clicking the X button.
  10. #6
  11. Contributing User
    Devshed Demi-God (4500 - 4999 posts)

    Join Date
    Aug 2011
    Posts
    4,850
    Rep Power
    481
    search the internet for "tkinter window manager event".
    [code]Code tags[/code] are essential for python code and Makefiles!
  12. #7
  13. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2012
    Posts
    18
    Rep Power
    0
    I don't think that would work with the current program I've written, even though TKinter is imported, it is using the graphics method of displaying a window, and TKinter functions aren't applicable.

IMN logo majestic logo threadwatch logo seochat tools logo