Jan-28-2018, 04:48 PM
Hi I am new to python and have been trying to develop a tkinter application. My question is, how can you use a variable from a class method to another class method? I have tried global and it doesnt work and keep showing error that the name is not found.
Example
class Page1(tk.frame)
def A(self)
global left
#assess csv file for a value and assign to variable left
left=row[2]
...
class Page2(tk.frame)
...
def B(self)
self.x= left
...
When compile, Error is shown as left is not defined. I am also unable to create instances for Page1 and Page2 as the main application runs in the manner below,
app=Mainclass()
app.mainloop()
Class Page1 and Page2 are fired from app object (instance of Mainclass)
Example
class Page1(tk.frame)
def A(self)
global left
#assess csv file for a value and assign to variable left
left=row[2]
...
class Page2(tk.frame)
...
def B(self)
self.x= left
...
When compile, Error is shown as left is not defined. I am also unable to create instances for Page1 and Page2 as the main application runs in the manner below,
app=Mainclass()
app.mainloop()
Class Page1 and Page2 are fired from app object (instance of Mainclass)