so, I was working for an application and wanted to create a page which asks the user to enter the location .
I am using customtkinter , for this I created a Frame “f2” and a label “l8” where label is just “please enter your location” and I wanted to create this effect where if u press on button “b5” with the text “CITY”
it would create a scrollableFrame named “se1” which is inside a function “Scrollable1” , the scrollable frame is created just below the button city and would contain button with names of city (which i’ll add later) and I also created another button “b6” (this is just a part of my project so the variable names are like this) with text “STATE” which on click would generate a scrollable Frame as well named “se2” which is inside a function called “Scrollable2” .
so , further on I wanted to create an effect where only one of the scrollable frame remains on screen , for ex : if I press city button then a scrollable frame should appear below it and then if I press state button the scrollable frame from city should dissapear and scrollable frame from state button should appear meaning only one of the scrollable frame should remain on screen . so I created a code for it which I have mentioned below :
import customtkinter
customtkinter.set_appearance_mode("System")
root = customtkinter.CTk()
root.geometry("610x600")
root.resizable(False, False)
root.configure(fg_color="black")
def Scrollable1():
global se1
se1 = customtkinter.CTkScrollableFrame(f2, )
se1.grid(row=2, column=1)
b5.configure(state="disabled")
try:
if se2 in globals():
f2.destroy(se2)
except:
pass
def Scrollable2():
global se2
se2 = customtkinter.CTkScrollableFrame(f2, )
se2.grid(row=4, column=1)
b6.configure(state="disabled")
try:
if se1 in globals():
f2.destroy(se1)
except:
pass
global f2
global b5
global b6
f2 = customtkinter.CTkFrame(root, fg_color="black", width=600, height=585)
f2.grid(row=0, column=0)
l8 = customtkinter.CTkLabel(f2, text="Please select your Location", text_color="white", font= ("Helvetica", 15))
l8.grid(row=0, column=1, pady=20)
b5 = customtkinter.CTkButton(f2, text="CITY", text_color="white", fg_color="black", width=250, height=30, border_width=1, border_color="white", hover_color="black", command=Scrollable1)
b5.grid(row=1, column=1, pady=10)
b6 = customtkinter.CTkButton(f2, text="STATE", text_color="white", fg_color="black", width=250, height=30, border_width=1, border_color="white", hover_color="black", command=Scrollable2)
b6.grid(row=3, column=1, pady=10)
root.mainloop()
However, when I run this it doesnt work can anyone tell me where I have done it wrong ??
would really appreciate it.