I changed what I posted before to the radio button method. This seems to be better if the number of employees is small. I'm using Spyder (python3.7).
#Search for employee number with radio button
import tkinter as tk
root = tk.Tk()
root.geometry('300x150')
root.title('Employee')
radioValue = tk.IntVar()
#Enter the employee name in text and the employee number in value
rdioOne = tk.Radiobutton(root, text='Tanaka',
variable=radioValue, value=101)
rdioTwo = tk.Radiobutton(root, text='Suzuki',
variable=radioValue, value=202)
rdioThree = tk.Radiobutton(root, text='Nomura',
variable=radioValue, value=303)
rdioOne.grid(column=0, row=0)
rdioTwo.grid(column=0, row=1)
rdioThree.grid(column=0, row=2)
#Employee number display method
labelValue = tk.Label(root, textvariable=radioValue)
labelValue.grid(column=2, row=0, sticky="E", padx=40)
root.mainloop()
Recommended Posts