Aug-08-2020, 01:21 AM
Dear Python Users:
I've added some submenus to the option buttons.
1) First start the program.
2) Press the red "Press here to start button"
5 option buttons will come up.
3) Press option1. 3 finalsel buttons come up (but the options buttons don't disappear).
In the "final function" there are 5 commented out commands at the beginning of the function.
I am a beginner but I am sure these commands don't work because of namespace and/or scope issues.
Is there a way to get the option buttons to disappear without using global variables?
I've added some submenus to the option buttons.
1) First start the program.
2) Press the red "Press here to start button"
5 option buttons will come up.
3) Press option1. 3 finalsel buttons come up (but the options buttons don't disappear).
In the "final function" there are 5 commented out commands at the beginning of the function.
I am a beginner but I am sure these commands don't work because of namespace and/or scope issues.
Is there a way to get the option buttons to disappear without using global variables?
import tkinter as tk root = tk.Tk() root.geometry("800x800") #Secondmenu brings up a second set of buttons. How do I make the "Press here to starbutton" disappear before this second set of buttons come up def secondmenu(): start.pack_forget() Option1 = tk.Button(root, text="Option1", bg="white", \ fg="firebrick", relief = "groove", font = "Helvitica 30",command = final).pack() Option2 = tk.Button(root, text="Option2", bg="white", \ fg="firebrick", relief = "groove", font = "Helvitica 30",command = final).pack() Option3 = tk.Button(root, text="Option3", bg="white", \ fg="firebrick", relief = "groove", font = "Helvitica 30",command = final).pack() Option4 = tk.Button(root, text="Option4", bg="white", \ fg="firebrick", relief = "groove", font = "Helvitica 30",command = final).pack() Option5 = tk.Button(root, text="Option5", bg="white", \ fg="firebrick", relief = "groove", font = "Helvitica 30",command = final).pack() def final (): #Option1.pack_forget() #Option2.pack_forget() #Option3.pack_forget() #Option4.pack_forget() #Option5.pack_forget() finalsel1= tk.Button(root, text="finalsel1", bg="white", \ fg="firebrick", relief="groove", font="Helvitica 30", ).pack() finalsel2 = tk.Button(root, text="finalsel2", bg="white", \ fg="firebrick", relief="groove", font="Helvitica 30", ).pack() finalsel3 = tk.Button(root, text="finalsel3", bg="white", \ fg="firebrick", relief="groove", font="Helvitica 30", ).pack() #This is the button you will see when you start the program start = tk.Button(root, text="Press here to start", bg="red", fg="black", font = "Helvitica 30",command = secondmenu) start.pack() root.mainloop()