0

I am working on Tkinter and I am new. I am making a GUI which has three frames. I am using an entry widget in the first frame. I want to ge the text entered in the entry widget to get into the second frame. I want to ge the text entered in txt widget in A to vno in B How to get string entered by user in text box widget in one class to a variable in second class?

import tkinter

classA(tk.Frame)
    ....
    txt = tk.Entry
    .....

classB(tk.Frame)
    ....
    vno = txt.get()
    ....
furas
  • 134,197
  • 12
  • 106
  • 148
  • first you have to use `self.` to create class/instance variables which you can access from other classes. – furas Jan 03 '20 at 08:39
  • you can send instance of one class as argument to other class - `ClassB(...., class_a_instance)` and then you have access to its variables. You can also use `.parent.class_a_instance` to access other class. You can also create variable in parent and and send value from one class to parent, and get values from parent in other class. – furas Jan 03 '20 at 08:42
  • 1
    Pick one from [`[python] "variable from one class to another"`](https://stackoverflow.com/search?q=is%3Aquestion+answers%3A1+%5Bpython%5D+%22variable+from+one+class+to+another%22) – stovfl Jan 03 '20 at 09:15

0 Answers0