Im currently having an issue getting certain portions of my app to work. I want to add radiobuttons, and a convert button so that users are able to convert from fahrenheit to celsius and vice versa. When adding the specific functions and variables into the second window it seems to gray out the options and prevents the code from executing properly.
I’ve tried adding certain definitions and functions gradually which has worked but am still having difficutlty getting it to the proper format that I would like. Ive been using the global variable to ensure that im only communicating with the second window but still doesn’t seem to process certain functions.
def openNewWindow():
global NewWindow
#Creates a new window using Toplevel
NewWindow = Toplevel(master_window)
#Sets the title of Toplevel widget
NewWindow.title("Dave's weather app")
#Sets the geometry of Toplevel
NewWindow.geometry('350x350')
#Label widget to show in Toplevel
Label(NewWindow, text = "Temperature Conversion", fg = 'gold', bg = 'dark blue', font = ('bold, 12')).pack()
#Configures window color
NewWindow.configure(bg = 'dark blue')
#Temperature input block that allows the user to input a number within the program
label = Label(NewWindow, text = "Enter Temperature:").pack()
entry = Entry(NewWindow).pack()
#Convert button acts as an enter key and allows the program to process the number
convert_btn = Button(NewWindow, text = "Convert", command = convert_temperature).pack()
#Result label outputs
result_label = Label(NewWindow, text = "").pack()
#Defines the formula to convert Celsius to Fahrenheit
def Celsius_to_Fahrenheit(Celsius):
return (1.8) * Celsius + 32
#Defines the formula to convert Fahrenheit to Celsius
def Fahrenheit_to_Celsius(Fahrenheit):
return (0.55) * (Fahrenheit - 32)
#Main NewWindow welcome screen
master_window = Tk()
master_window.title("Welcome Screen")
master_window.configure(bg = 'dark blue')
master_window.geometry('200x200')
#Welcome label for the master window
label = Label(master_window, text = "Welcome!")
label.pack( pady = 10)
#Button to open Dave's weather app
btn1 = Button(master_window, text = "Click to open Dave's Weather app", command = openNewWindow)
btn1.pack(expand = True)
#Welcome screen exit button
btn2 = Button(master_window, text = "Exit", command = exit)
btn2.pack(expand = True)
mainloop()
Reesecup is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.