The part that has the problem is that I ask the user for an input in one class, the I wish to use the value obtained from that entry in another class, However, this code always give me 0 no matter what I have entered. I think it is probably because that when another class is executed, the value stored in the entry of the previous class disappear. But I don't know how to go around it. Could any coding master help me a little bit here?
......
class PageOne(tk.Frame):
def __init__(self, parent, controller):
tk.Frame.__init__(self,parent)
BackButton = tk.Button(self, text="Back",font=TNR24,command=lambda: controller.show_frame(MainPage))
PrintButton = tk.Button(self, text="Print it", command=self.print_message)
ExitButton = tk.Button(self,text="EXIT",command=exit_window)
ProceedButton=tk.Button(self, text="Proceed", command=lambda: controller.show_frame(PageTwo))
self.NumOfVertices= tk.IntVar()
global VertexNumber
VertexNumber=self.NumOfVertices.get()
NumOfVerticesEntry=tk.Entry(self,textvariable=self.NumOfVertices)
ProceedButton.pack()
BackButton.pack()
ExitButton.place(x=1240, y=670, width=40, height=30)
PrintButton.pack()
NumOfVerticesEntry.pack()
def print_message(self):
print self.NumOfVertices.get()
class PageTwo(tk.Frame):
def __init__(self, parent, controller):
tk.Frame.__init__(self,parent)
lable=tk.Label(self,text=VertexNumber)
......
The code is quite long so I only took the part which I need help on. VertexNumber is the variable that I want to store and use in the class Pagetwo. But it always turns into 0 no matter what I entered. Is there any ways to store that variable permanently immediately after the user enters it?