How can I pass a variable from class in another class in python? I'm a beginner, I just started learning python and tkinter. Example:
File main.py:
if __name__ == "__main__":
root = Tk()
window = Articles(root)
root.mainloop()
when run this code, articles.py work; Window it's open.
File articles.py
class Articles:
def __init__(self, master)
self.master = master
#...
#Here is many widgets. No matter, it's works. :)
#....
#When I want to double-click on one of the rows in the treeview, it should send me the <item>
#variable in the ArticleInfo class and display it in a label when the popup window opens.
mytree.bind('Double-1', self.get_article_id)
def get_article_id(self):
item = self.myTree.identify("item", event.x, event.y)
File article_info.py
class ArticleInfo:
def __init__(self):
t = Toplevel()
myvar_from_articlesclass = ???
Label(t, text=myvar_from_articlesclass).pack()
I tried many options from what I found on the net, but I was getting different errors.