Python_Newbie: Take textfield entry, search in excel file for information and show them in another field

Hey Guys,

I’m really new to python programming so I hope you can easily help me.


My plan is to take the entered company code from the entry button. When pressing the submit button oder enter on the keyboard the code should search in the excel file for the whole company name. This company name should be displayed in the 3rd button.

#create Company code
self.entry = customtkinter.CTkEntry(“COMPANY”))
self.entry = customtkinter.CTkEntry(self, placeholder_text=“Enter Company Code”, width=210)
self.entry.grid(row=0, column=2, padx=30, pady=(10, 15), sticky=“w”)

    def func():
        print("Code:", self.entry.get() )

#create Submit-Button
self.main_button_1 = customtkinter.CTkButton(master=self, text=“Submit”, text_color=(“gray10”, “#DCE4EE”), width=10, command=func)
self.main_button_1.grid(row=0, column=2, padx=35, pady=(10,15), sticky=“e”)

    #get Code and Company name
    df= pd.read_excel("C:\\Users\\angelina\\Downloads\Code.xlsx")
    print(df['COMPANY'].where(df['Company-Code'] == 4146))
    Company_Code= (df['COMPANY'].where(df['Company-Code'] == 4146))
    Company_Code= customtkinter.StringVar()
    self.string_input_button3 = customtkinter.CTkButton("COMPANY"))                                     
    self.string_input_button3 = customtkinter.CTkButton(master=self, fg_color="transparent", text='', textvariable=Company_Code,  text_color=("gray10", "#DCE4EE"))
    self.string_input_button3.grid(row=0, column=2, padx=(20,20), pady=(100, 15))

I see that you have some code already and you describe a task. What help are you looking for, exactly? When you try using your existing code, what happens? What seems to be needed in order to get from there to the goal?

Hi Karl,

There is a problem when it should start searching for the company code. When I run my code, it searches directly and do not wait for pressing the Submit button.

Another problem is that the company name do not appears in the 3rd box although I can see the name in the terminal.

Do you have any ideas where do I have to adjust my code?

Okay, so we will definitely have to examine the code to solve that. The next step is to read the pinned thread and make sure the code is properly formatted, so that we can read it properly (in particular, understand how it is indented).