Get access to another window textEntry (Python)

87 views Asked by At

I'm using PyCharm and Glade user interface designer. My project contains two windows: Main and Secondary. Secondary window starts from Main. After some manipulation in Secondary window I should close it. But before I'm saving some data in a list. And when Secondary window is closed I want to fill some textEntry on Main window with my data from list.

What is the best way to handle it? I'm newbie in Python. Probably better to catch the signal when secondary window is closed? Or fill textEntryof Main window right in the code of another window?

1

There are 1 answers

0
tobias47n9e On BEST ANSWER

I think you have two options, pass the list or a function that modifies the list to the secondary window.

For example this is how the function could be passed:

class Main():
    def __init__(self):
      s = Secondary(self.modify_list)
      mylist = []

      .
      .

      s.run()

      .
      .

   def modify_list(self, new_values):
       mylist = new_values

class Secondary():
   def __init__(self, modify_list):
       self.modify_list = modify_list

   .
   .

   def apply(self):
       new_text = self.entry.get_buffer()
       self.modify_list(new_text)

Let me know if that worked for you!