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

    Join Date
    Oct 2017
    Posts
    85
    Rep Power
    1

    [Python 3.x + Tkinter] Entry Button not Work, Error Found!


    Hey GUI Programmers and Software Developers...

    I try to work on my first real app in python 3.x and tkinter... but i get an problem with my entry
    load file buttons.....

    This is my script, written in python 3.x in pyScripter.... windows 7 on my laptop:

    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.master.config(background = 'gray')
    
            # PROJECT LOADER  -------------------------------------------------------------------------------------------------------------------------------------------------
    
            # Call 'Project Loader Variable'
            vname_file = "FileName"
    
            # Call 'Project Loader Title'
            ploader_title = Label(self.master, text = "PROJECT LOADER:", anchor = W, foreground = 'white', background = 'black')
            ploader_title.pack(fill = X, side = TOP)
    
    
    
    
    
            # Call 'Load Project - Image'
    
            eipload_label = Label(self.master, text = "EIP Project File: ", anchor = W, foreground = 'black', background = 'gray')
    
            eipl_var = StringVar()
            eipl_var.set(vname_file)
            eipload_entry = Entry(self.master, textvariable = eipl_var, foreground = 'black', background = 'white')
            eipload_button = Button(self.master, text = "Open to continue", anchor = W, foreground = 'black', background = 'gray', command = self.load_eip_file())
    
            eipload_label.pack(fill = X, side = TOP)
            eipload_entry.pack(fill = X, side = TOP)
            eipload_button.pack(fill = X, side = TOP)
    
            eipl_end = Label(self.master, text = "_", foreground = 'gray', background = 'gray')
            eipl_end.pack(fill = X, side = TOP)
    
            # Call 'Load Project - Audio'
            eapload_label = Label(self.master, text = "EAP Project File: ", anchor = W, foreground = 'black', background = 'gray')
    
            eapl_var = StringVar()
            eapl_var.set(vname_file)
            eapload_entry = Entry(self.master, textvariable = eapl_var, foreground = 'black', background = 'white')
            eapload_button = Button(self.master, text = "Open to continue", anchor = W, foreground = 'black', background = 'gray', command = self.load_eap_file())
    
            eapload_label.pack(fill = X, side = TOP)
            eapload_entry.pack(fill = X, side = TOP)
            eapload_button.pack(fill = X, side = TOP)
    
            eapl_end = Label(self.master, text = "_", foreground = 'gray', background = 'gray')
            eapl_end.pack(fill = BOTH, side = TOP)
    
            # Call 'Load Project - Video'
            evpload_label = Label(self.master, text = "EVP Project File: ", anchor = W, foreground = 'black', background = 'gray')
    
            evpl_var = StringVar()
            evpl_var.set(vname_file)
            evpload_entry = Entry(self.master, textvariable = evpl_var, foreground = 'black', background = 'white')
            evpload_button = Button(self.master, text = "Open to continue", anchor = W, foreground = 'black', background = 'gray', command = self.load_evp_file())
    
            evpload_label.pack(fill = X, side = TOP)
            evpload_entry.pack(fill = X, side = TOP)
            evpload_button.pack(fill = X, side = TOP)
    
            evpl_end = Label(self.master, text = "_", foreground = 'gray', background = 'gray')
            evpl_end.pack(fill = X, side = TOP)
    
    
    
    
    
    
            # MENUBAR ----------------------------------------------------------------------------------------------------------------------------------------------------------
    
            # 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", command = self.open_tool_image)
            menu_tool.add_command(label = "Video", command = self.open_tool_video)
            menu_tool.add_command(label = "Audio", command = self.open_tool_audio)
            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", command = self.open_help_read)
            menu_help.add_command(label = "Document", command = self.open_help_doc)
            menu_help.add_command(label = "Channel", command = self.open_help_channel)
            menu.add_cascade(label = "Help", menu = menu_help)
    
            menu_about = Menu(menu, tearoff = False)
            menu_about.add_command(label = "Report Bug", command = self.open_reporter)
            menu_about.add_command(label = "Do Request", command = self.open_request)
            menu_about.add_command(label = "Copyright", command = self.open_copyright)
            menu_about.add_command(label = "Contact Me", command = self.open_contactbox)
            menu.add_cascade(label = "About", menu = menu_about)
    
    
    
        # _____________________________________________________________________________________________________________________________________________________________________________________
    
    
        # COMMANDS PROJECT LOADER -------------------------------------------------------------------------------------------------------------------------------------------------------------
    
        # Define 'Load EIP' Command [Type: Excine Image Project]
        def load_eip_file(self):
    
            print("Open EIP File [Excine Image Project]: ", eipload_entry.get())
    
    
        # Define 'load EAP' Command [Type: Excine Autio Project]
        def load_eap_file(self):
    
            print("Open EAP File [Excine Audio Project]: ", eapload_entry.get())
    
        # Define 'Load EVP' Command [Type: Excine Video Project]
        def load_evp_file(self):
    
            print("Open EVP FIle [Excine Video Project]: ", evpload_entry.get())
    
    
    
        # COMMANDS MENUBAR --------------------------------------------------------------------------------------------------------------------------------------------------------------------
    
        # Define the 'tool_image' command
        def open_tool_image(self):
    
            print("Open Image Editor")
    
    
        # Define the 'tool_video' command
        def open_tool_video(self):
    
            print("Open Video Editor")
    
    
        # Define the 'tool_audio' command
        def open_tool_audio(self):
    
            print("Open Audio Exitor")
    
    
    
    
        # Define the 'help_read' command
        def open_help_read(self):
    
            print("Open ReeadMe")
    
        # Define the 'help_doc' command
        def open_help_doc(self):
    
            print("Open Doc")
    
        # Define the 'help_channel' command
        def open_help_channel(self):
    
            print("Open Channel")
    
    
    
    
        # Define the 'about_report' command
        def open_reporter(self):
    
            print("Open Reporter")
    
        # Define the 'request' command
        def open_request(self):
    
            print("Open Request")
    
        # Define the 'copytight' command
        def open_copyright(self):
    
            print("Open Copyright")
    
        # Define the 'contactbox' command
        def open_contactbox(self):
    
            print("Open Contactbox")
    
    
    
        # 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()




    And this is my error:
    Traceback (most recent call last):
    File "C:\Users\Gebruiker\Desktop\JamieVanCadsand\Apps\Project\Project Exciner\Exciner.py", line 249, in <module>
    App = Run(root)
    File "C:\Users\Gebruiker\Desktop\JamieVanCadsand\Apps\Project\Project Exciner\Exciner.py", line 33, in __init__
    self.init_window()
    File "C:\Users\Gebruiker\Desktop\JamieVanCadsand\Apps\Project\Project Exciner\Exciner.py", line 62, in init_window
    eipload_button = Button(self.master, text = "Open to continue", anchor = W, foreground = 'black', background = 'gray', command = self.load_eip_file())
    File "C:\Users\Gebruiker\Desktop\JamieVanCadsand\Apps\Project\Project Exciner\Exciner.py", line 148, in load_eip_file
    print("Open EIP File [Excine Image Project]: ", eipload_entry.get())
    NameError: name 'eipload_entry' is not defined

    So i am an noob in python and i don't know how i can fix this problem...

    Oh yeah... my first idea of this app was to make convert files possible, but
    this is an old idea... But this not my problem for this topic...

    My problem for this topic is the above stand error they i want to ask help to
    correct my code to fix this error...

    My app is still in the begin fase, just the tools doesn't still (for the tools i work later
    on it).... i get still an lot work to do on the demo (or first beta) release of my app....

    So... the problem is the error i get in my load project file buttons... but please,
    let it for the rest how it is.... the features to load files self must be comming later...

    Just only fix this error..., can anyone correct my code please ?...
    I use print(...) in my load project commands for the running prompt...

    The load project features must be comming later.....

    Thanks for help, Jamie
    Last edited by JamieVanCadsand; April 6th, 2018 at 02:25 PM.
  2. #2
  3. Contributing User
    Devshed God 1st Plane (5500 - 5999 posts)

    Join Date
    Aug 2011
    Posts
    5,971
    Rep Power
    509
    In this statement
    eipload_button = Button(self.master, text = "Open to continue", anchor = W, foreground = 'black', background = 'gray', command = self.load_eip_file())
    you have called the self.load_eip_file method.
    If that method worked and returned a callable the system might be okay.
    You probably intended
    Code:
           eipload_button = Button(self.master, text = "Open to continue", anchor = W, foreground = 'black', background = 'gray', command = self.load_eip_file)
    In other words, remove () following self.load_eip_file
    [code]Code tags[/code] are essential for python code and Makefiles!

IMN logo majestic logo threadwatch logo seochat tools logo