![]() |
[Tkinter] What is this error? - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: GUI (https://python-forum.io/forum-10.html) +--- Thread: [Tkinter] What is this error? (/thread-31973.html) |
What is this error? - Oshadha - Jan-13-2021 Script, from tkinter import * main = Tk() main.title("1. Unit & Dimentions") #root.geometry("1600x800+0+0") #Var Details length = ["meter", "m", "fundamentals"] mass = ["kilogram", "kg", "fundamentals"] time = ["second", "s", "fundamentals"] current = ["ampere", "A", "fundamentals"] temperature = ["kelvin", "K", "fundamentals"] amount_of_substance = ["mole", "mol", "fundamentals"] luminous_intensity = ["candela", "cd", "fundamentals"] Fundamentals = [length, mass, time, current, temperature, amount_of_substance, luminous_intensity] #Text name = Label(main, text = "1. Unit & Dimentions", font = ("arial", 45, "bold"), fg = "Steel Blue", bd = 10) mj = Label(main, text = "A product of MihiraJ.com", font = ("arial", 26, "bold"), fg = "#cc5c54", bd = 10) dev = Label(main, text = "Devloped by Oshadha Mihiranga", font = ("arial", 18, "bold"), fg = "Steel Blue", bd = 10) search = Label(main, text = "Search", font = ("arial", 10, "bold"), fg = "black", bd = 10) result_lbl = Label() #Text boxes search_box = Entry(main, borderwidth = 4, width = 34) #Frames results = LabelFrame(main, text = "Results") rel_results = LabelFrame(main, text = "Related Results") #errors err001 = Label(results, text = "Err001 : Result not Found, Please type again.", fg = "#eb0000") #functions def no_input(): err001.pack(padx = 6, pady = 6, side = LEFT) search_box.delete(0, END) def result_found(name, result): search_box.delete(0, END) result_lbl.config(results, text = "Physical quantity : " + name + "\nUnit : " + result[0] + "\nSymbol : " + result[1], justify = LEFT) def search_start(txt_2_search): if txt_2_search == "": no_input() if txt_2_search == "mass": result_found("Mass", mass) #buttons search_button = Button(main, text = "Start Search", command = lambda : search_start(search_box.get().lower())) #pack name.pack() mj.pack() search.pack() search_box.pack() search_button.pack() results.pack(fill = X) result_lbl.pack(padx = 6, pady = 6, side = LEFT) dev.pack() mainloop() What is this error?It makes no sense to me! RE: What is this error? - deanhystad - Jan-13-2021 I don't get an error when I run your code. It doesn't do anything interesting when the search button is pressed. but there is no error. You cannot set a widget's parent using the config command. result_lbl = Label() result_lbl.config(results, text = "Physical quantity")You need to specify the parent when you create the widget. results = LabelFrame(main, text = "Results") result_lbl = Label(results)If you want to hide or pop up a widget inside a window you can use pack and forget. |