Why my python tkinter Button is not accessed
Question:
I am trying to do my computer science project with tkinter, it is a dice game, I have 3 UI window, the button on second one, when you click it, it will help you run function:"conti" but my VisualStudio said my button is not accessed.
This is my code
def GameWind():
GW = tkinter.Tk()
GW.geometry("1000x1000")
GW.resizable(0,0)
GW.title("In Game")
GW.mainloop()
#Introduce window
def Introduce():
Intro = tkinter.Tk()
Intro.geometry("700x300")
Intro.resizable(0,0)
Intro.title("Introduce")
ttk.Label(Intro,text ="...").pack()
photo = tk.PhotoImage(file = "Sources ImagesRULES.gif",master=Intro)
ttk.Label(Intro,image = photo).pack()
def conti():
GameWind
Intro.quit
GameB=tk.Button(Intro,text="Continue",command=conti,master=Intro).pack()
Intro.mainloop()
But when I run it:
I try to search online for multiple hours, I found nothing.
Answers:
As matswecja already mentioned in her comment you are not using GameB variable. Also .pack()
method returns None. To Resolve the issue just remove the GameB=
I am trying to do my computer science project with tkinter, it is a dice game, I have 3 UI window, the button on second one, when you click it, it will help you run function:"conti" but my VisualStudio said my button is not accessed.
This is my code
def GameWind():
GW = tkinter.Tk()
GW.geometry("1000x1000")
GW.resizable(0,0)
GW.title("In Game")
GW.mainloop()
#Introduce window
def Introduce():
Intro = tkinter.Tk()
Intro.geometry("700x300")
Intro.resizable(0,0)
Intro.title("Introduce")
ttk.Label(Intro,text ="...").pack()
photo = tk.PhotoImage(file = "Sources ImagesRULES.gif",master=Intro)
ttk.Label(Intro,image = photo).pack()
def conti():
GameWind
Intro.quit
GameB=tk.Button(Intro,text="Continue",command=conti,master=Intro).pack()
Intro.mainloop()
But when I run it:
I try to search online for multiple hours, I found nothing.
As matswecja already mentioned in her comment you are not using GameB variable. Also .pack()
method returns None. To Resolve the issue just remove the GameB=