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

    Join Date
    Oct 2017
    Posts
    80
    Rep Power
    1

    [Python 3.x + Tkinter] Converting App crasht with exit it, help need!


    Hey Software Developers and GUI Programmers...

    I am working on my first real app in python 3.x and tkinter... so i am an noob in python
    and i try to create an exit button in my file menu in my main menubar...

    This is my script (so my app is still in the begin process... just the tools doesn't still)...

    Edit:

    My script was looks like this...

    Code:
    # Exciner Demo (First Beta Version)
    # Created by Jamie van Cadsand
    # -------------------------------------------------------------------------------------------------------------------------------------------------------
    # Exciner is an "Free and Open Source" Tool for Convert Files
    # This is an Beta Version, just not allowed to use in production
    # _______________________________________________________________________________________________________________________________________________________
    #
    # Type Release: Beta
    # _______________________________________________________________________________________________________________________________________________________
    #
    # [Project] Exciner / Exciner.py
    #
    
    from tkinter import *
    
    # Define the 'Main Window'
    class Run(Frame):
    
        def __init__(self, master=None):
    
            Frame.__init__(self, master)
    
            self.master = master
    
            self.init_window()
    
    
    
        def init_window(self):
    
            self.master.title("Exciner Demo")
            self.pack(fill = BOTH, expand = 1)
    
            menu = Menu(self.master)
            self.master.config(menu = menu)
    
            menu_file = Menu(menu, tearoff = False)
            menu_file.add_command(label = "Exit", command = self.client_exit)
            menu.add_cascade(label = "File", menu = menu_file)
    
            menu_tool = Menu(menu, tearoff = False)
            menu_tool.add_command(label = "Image Type")
            menu_tool.add_command(label = "Image Icon")
            menu_tool.add_command(label = "Image Vector")
            menu_tool.add_separator()
            menu_tool.add_command(label = "Video")
            menu_tool.add_command(label = "Audio")
            menu_tool.add_command(label = "Model")
            menu.add_cascade(label = "Tools", menu = menu_tool)
    
            menu_help = Menu(menu, tearoff = False)
            menu_help.add_command(label = "ReadMe")
            menu_help.add_command(label = "Document")
            menu_help.add_separator()
            menu_help.add_command(label = "Copyright")
            menu_help.add_command(label = "Report Bug")
            menu_help.add_command(label = "Contact Me")
            menu.add_cascade(label = "Help", menu = menu_help)
    
    
        def client_exit(self):
    
            self.master.quit()
    
    
    
    
    root = Tk()
    
    App = Run(root)
    
    root.mainloop()
    So my problem is thad if you press on the "exit" button in my menubar > file > exit...
    My App cracht to quit it.... so i get called 'self.master.quit()' in the client_exit(self) command
    i get defined...

    Can anyone correct my code, just this is fixed on my app ?...
    Thanks for help, Jamie.
    Last edited by JamieVanCadsand; April 6th, 2018 at 10:14 AM.
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2017
    Posts
    80
    Rep Power
    1
    Hh yeah.... this only crach in "PyScripter".... if i use exit() in the client_exit(self) command.....
    I use PyScripter if i works on serius app or software projects....



    Edit:

    Sorry for this topic... this problem is also fixed!.

    Edit:

    Now i use exit() in the client_exit(self) command....

    It looks like this....

    Code:
    # Exciner Demo (First Beta Version)
    # Created by Jamie van Cadsand
    # -------------------------------------------------------------------------------------------------------------------------------------------------------
    # Exciner is an "Free and Open Source" Tool for Convert Files
    # This is an Beta Version, just not allowed to use in production
    #
    # _______________________________________________________________________________________________________________________________________________________
    #
    # Type Release: Beta
    # _______________________________________________________________________________________________________________________________________________________
    #
    # [Project] Exciner / Exciner.py
    # -------------------------------------------------------------------------------------------------------------------------------------------------------
    
    
    
    # Import Tkinter
    from tkinter import *
    from tkinter.messagebox import *
    
    # Define the 'Main Window'
    class Run(Frame):
    
        # Define the 'Main Init'
        def __init__(self, master=None):
    
            # Call 'Frame' to the 'Main Init'
            Frame.__init__(self, master)
    
            # Call the window name to master
            self.master = master
    
            # Call the 'Main Init Window'
            self.init_window()
    
        # Define the 'Main Init Window'
        def init_window(self):
    
            # Set 'Main Init Window Title'
            self.master.title("Exciner Demo")
            self.pack(fill = BOTH, expand = 1)
    
            # Call 'Menubar'
            menu = Menu(self.master)
            self.master.config(menu = menu)
    
            # Call 'File Menu' to the 'Menubar'
            menu_file = Menu(menu, tearoff = False)
            menu_file.add_command(label = "Exit", command = self.client_exit)
            menu.add_cascade(label = "File", menu = menu_file)
    
            # Call 'Tool Menu' to the 'Menubar'
            menu_tool = Menu(menu, tearoff = False)
            menu_tool.add_command(label = "Image")
            menu_tool.add_separator()
            menu_tool.add_command(label = "Video")
            menu_tool.add_command(label = "Audio")
            menu_tool.add_separator()
            menu_tool.add_command(label = "Model")
            menu.add_cascade(label = "Tools", menu = menu_tool)
    
            # Call 'Help Menu' to the 'Menubar'
            menu_help = Menu(menu, tearoff = False)
            menu_help.add_command(label = "ReadMe")
            menu_help.add_command(label = "Document")
            menu_help.add_separator()
            menu_help.add_command(label = "Copyright")
            menu_help.add_command(label = "Report Bug")
            menu_help.add_command(label = "Contact Me")
            menu.add_cascade(label = "Help", menu = menu_help)
    
        # Define the 'exit' command with build in an askquestion message
        def client_exit(self):
    
            # Call 'Ask Question Message' to ask if the user want defenitive exit this app
            m_exit = askquestion("Exit Exciner", "Do you want to exit it ?")
    
            # Exit this app if 'Yes' is pressed
            if m_exit == 'yes':
    
                # Exit exciner defenitive
                exit()
    
            # Nothing happens if else
            else:
    
                # Cancel the exit ommand
                None
    
    
    # Setup the main window
    root = Tk()
    
    # Run the app
    App = Run(root)
    
    # Mainloop the main window
    root.mainloop()
    Last edited by JamieVanCadsand; April 6th, 2018 at 10:15 AM.

IMN logo majestic logo threadwatch logo seochat tools logo