I am trying to build a Tinker window that a user would have that includes:
- 1 Dropdown field
- 1 Text Box that a user can only input numbers (ie. 10.5)
Once the user selects the button, it should save both the value of the field in the dropdown & the value in the text box as 2 separate variables that will be used later down in the script.
I have been able to build out the script (below) that includes the dropdown aspect, however, I am having trouble including an input text box.
Is anyone able to help review what I am doing wrong?
from tkinter import *
REPORTS = [
"1", "2", "3", "4", "5"
]
ReportSelection_Win = Tk()
variable = StringVar(ReportSelection_Win)
variable.set(REPORTS[0]) # default value
Lbl_Headline = Label(ReportSelection_Win, text = "Change Report")#Create Label
Lbl_Headline.grid(column=0, row=0, padx=10, pady=10) #Show Label
Drop_Reports = OptionMenu(ReportSelection_Win, variable, *REPORTS)
Drop_Reports.grid(column=0, row=1, padx=10, pady=0)
def Select_Report():
global Selected_Report
Selected_Report = variable.get()
Btt_Confirm_2 = Button(ReportSelection_Win, text="Run Analysis", command = lambda: [Select_Report()])
Btt_Confirm_2.grid(column=0, row=2, padx=10, pady=10)
ReportSelection_Win.mainloop()
#----------------------------Selected Report-----------------------------------
print(Selected_Report)
I have built out the script but I keep getting errors any time I try to add the input text box