title: How to dynamically add/remove widgets from Gtk 3 Window
body: <p>I am using python3 with Gtk3 and i need to basically <code>remove</code> some widgets from my <code>Gtk.Window</code> and replace them with other widgets when a <code>Gtk.Button</code> is <code>clicked</code>.I have tried using <code>Gtk.ListBox</code>es with <code>Gtk.ListBoxRow</code>s and so far i can remove all the <code>Row</code>s from the <code>ListBox</code> but when i try to add them back,essentially <strong>nothing</strong> happens.This is part of my code:</p>
  
  <pre><code>def left_view(self, box):
      listbox = box
  
      row0 = Gtk.ListBoxRow()
      row0.set_halign(Gtk.Align.START)
      listbox.add(row0)
      #Adding HorizontalBox to place widgets
      hbox = Gtk.Box(spacing=10,orientation=Gtk.Orientation.HORIZONTAL)
      row0.add(hbox)
      prod_name = Gtk.Label()
      stock_count = Gtk.Label()
      prod_name.set_text('Product Name')
      stock_count.set_text('Stock   ')
      self.prod_name_input = Gtk.Entry()
      self.stock_count_input = Gtk.Entry()
  
      #Packaging 101
      hbox.pack_start(prod_name, True, True, 0)
      hbox.pack_start(self.prod_name_input, True, True, 0)
      hbox.pack_start(stock_count, True, True, 0)
      hbox.pack_start(self.stock_count_input, True, True, 0)
  </code></pre>
  
  <p>the function will be given a <code>Gtk.ListBox</code> as the argument.And what i have so far when trying to <code>remove()</code> and <code>add()</code> things to the listbox is:</p>
  
  <pre><code>def remover(self,widget):
          vbox = widget.get_parent()
          base = vbox.get_parent()
          children = base.get_children()
          listbox = children[1]
          for row in listbox.get_children():
              listbox.remove(row)
          with open('product_info.json', 'r') as d:
              data = d.read()
              j = json.loads(data)
              d.close()
          self.keys = list(j.keys())
          row0 = Gtk.ListBoxRow()
          listbox.add_child(row0)
          scrollwindow = Gtk.ScrolledWindow()
          scrollwindow.set_hexpand(True)
          scrollwindow.set_vexpand(True)
          row0.add_child(scrollwindow)
          tview = Gtk.TextView()
          scrollwindow.add(tview)
          textbuffer = tview.get_buffer()
          for item in range(0, len(self.keys)):
              textbuffer.insert_at_cursor('   %s\t\t %s \n' %(item, self.keys[item]))
  </code></pre>
  
  <p>By the way,If there is a simpler way of just replacing widgets on the go in PyGObject,please do let me know coz most of the answers that i saw on the related questions where totally useless</p>