Jan-18-2021, 04:37 AM
(This post was last modified: Jan-18-2021, 04:37 AM by deanhystad.)
I already gave you an example that does exactly what you are asking and the example was based on your code.
https://python-forum.io/Thread-Tkinter-H...#pid134606
This code in particular:
In addition to this method you could use "result_text.configure(text='whatever text goes in label')
You could also create a tkinter StringVar() and assign this as the textvariable when creating the label.
https://python-forum.io/Thread-Tkinter-H...#pid134606
This code in particular:
def search(event): name = search_box.get() unit = units.get(name) if unit: result_text['text'] = f'Physical quantity : {name}\nUnit : {unit[0]}\nSymbol : {unit[1]}' else: result_text['text'] = f'Unit "{name}" not found' search_box.delete(0, END)In particular lines 5 or 7.
In addition to this method you could use "result_text.configure(text='whatever text goes in label')
You could also create a tkinter StringVar() and assign this as the textvariable when creating the label.
result_text = StringVar() Label(results, textvariable = result_text, width= 40, height=3).pack() .. def search(event): name = search_box.get() unit = units.get(name) if unit: result_text.set(f'Physical quantity : {name}\nUnit : {unit[0]}\nSymbol : {unit[1]}') else: result_text.set(f'Unit "{name}" not found') search_box.delete(0, END)