title: Refreshing window content
body: <p>I am developing a demo program based on PyGobject that has parts in its interface like stocks management that should refresh every few seconds. The program has the need to be able to run 24/7 while keeping the displayed information correct.</p>
  
  <p>I have a container which has its content in stacks(and separately there are tabs to change between them):</p>
  
  <pre><code>    def main_content(self):
          box = Gtk.Box(orientation=Gtk.Orientation.VERTICAL)
          self.stack = Gtk.Stack()
          self.stack.get_style_context().add_class("main-container")
          self.stack.props.margin = 20
  
          self.child1_child = self.child1()
          self.child1_child.set_visible(True)
          self.stack.add_named(self.child1_child, "Child1")
  
          self.child2_child = self.child2()
          self.child2_child.set_visible(True)
          self.stack.add_named(self.child2_child, "Child2")
  
          self.child3_child = self.child2()
          self.child3_child.set_visible(True)
          self.stack.add_named(self.child3_child, "Child3")
  
          box.pack_start(self.stack, True, True, 0)
          if self.redraw:
              print("Redrawing")
          self.redraw = True
          return box
  </code></pre>
  
  <p>So, there are functions to generate each stack member, they are assigned to variables, and then set as visible and added to the stack.</p>
  
  <p>Lets suppose that the stack Child1 has a list of stocks, and i don't want it to have more than 5 minutes of delay. I tried to do a redraw function where a list is making the tabs, and this redraw function is either evoked by a <strong>timeout_add</strong> or a tab click :</p>
  
  <pre><code>    def redraw(self):
          selected_stack = self.listbox.get_selected_row().get_index()
  
          # **Possible** solution:
          stack_elements = {0: "Child1", 1: "Child2", 2: "Child3"}
          variables = {0: "child1_child", 1: "child2_child", 2: "stock_child"}
          self.variables[janela].destroy()
          self.variables[janela] = self.stack_elements[janela].lower()
          self.variables[janela].set_visible(True)
          self.stack.add_named(self.variables[janela], stack_elements[janela])
          # Problems: Doesn't works as python code. Just an idea
  
          # **Possible** solution 2:
          self.stack.destroy()
          self.stack = Gtk.Stack()
          self.stack_content = self.main_content()
          self.main_box.pack_start(self.stack_content, True, True, 0)
  </code></pre>
  
  <p>These were just some try-error ideas, i never made an interface with the need to be kept updated, is there any proper way to do so, or a way to make one of my ways work?</p>