I am new to Tkinter and I want to create a button which when pressed displays a 2nd interface. I have written the following program:
import Tkinter
root = Tkinter.Tk( )
root.title("My First Game")
for r in range(3):
for c in range(3):
Tkinter.Label(root, text= '3', borderwidth=20 ).grid(row=1,column=1)
Tkinter.Label(root, text= '6', borderwidth=20 ).grid(row=1,column=2)
Tkinter.Label(root, text= '4', borderwidth=20 ).grid(row=1,column=3)
Tkinter.Label(root, text= '2', borderwidth=20 ).grid(row=2,column=1)
Tkinter.Label(root, text= '7', borderwidth=20 ).grid(row=2,column=2)
Tkinter.Label(root, text= ' ', borderwidth=20 ).grid(row=2,column=3)
Tkinter.Label(root, text= '5', borderwidth=20 ).grid(row=3,column=1)
Tkinter.Label(root, text= '1', borderwidth=20 ).grid(row=3,column=2)
Tkinter.Label(root, text= '8', borderwidth=20 ).grid(row=3,column=3)
def mainprg():
for r in range(3):
for c in range(3):
Tkinter.Label(root, text= '3', borderwidth=20 ).grid(row=1,column=1)
Tkinter.Label(root, text= '6', borderwidth=20 ).grid(row=1,column=2)
Tkinter.Label(root, text= ' ', borderwidth=20 ).grid(row=1,column=3)
Tkinter.Label(root, text= '2', borderwidth=20 ).grid(row=2,column=1)
Tkinter.Label(root, text= '7', borderwidth=20 ).grid(row=2,column=2)
Tkinter.Label(root, text= '4', borderwidth=20 ).grid(row=2,column=3)
Tkinter.Label(root, text= '5', borderwidth=20 ).grid(row=3,column=1)
Tkinter.Label(root, text= '1', borderwidth=20 ).grid(row=3,column=2)
Tkinter.Label(root, text= '8', borderwidth=20 ).grid(row=3,column=3)
B = Tkinter.Button(text = "Run", command = mainprg)
B.pack()
root.mainloop()
I am trying to display the first interface and the Run button. After pressing the Run button the 2nd interface is to be displayed. But after running the above code, it does not display anything.