title: How to hide an ActionButton in Kivy?
body: <p>I am trying to modify the visibility of an ActionButton accordingly to the current screen (using Screen Manager). I could not find a Visible property or something like that that can simply toggle visibility (neither for ActionButton nor for Widgets in general) .</p>
  
  <p><a href="https://stackoverflow.com/questions/16722971/kivy-how-to-make-widget-behave-like-overflowhidden">A post from 2013</a> suggests changing the texture of the button, but I don't want to rely on such a hack to accomplish such a simple task, besides, the background of my app will be variable.</p>
  
  <p><a href="https://stackoverflow.com/questions/14699280/switching-kivy-widgets">Another post</a> suggest removing the widget and adding it again as needed. Despite its unnecessary complexity. I modified to work in my case (ActionBar and ActionButton), so I clear the widgets from the ActionView and then try to add the ActionButton. I tried storing both a weakref and the <strong>self</strong> member, with both I got the following error:</p>
  
  <pre><code>WidgetException: Cannot add &lt;kivy.uix.actionbar.ActionButton object at 0x7fcd3fe22ce8&gt;, it already has a parent &lt;kivy.uix.actionbar.ActionView object at 0x7fcd3fe22870&gt;
  </code></pre>
  
  <p>Any idea would be greatly appreciated. I am working with the dev version, but it neither work with 1.8.</p>
  
  <p><strong>EDIT</strong>
  I tried the following code:</p>
  
  <pre><code>&lt;AppActionBar&gt;:
      ActionView:
          id: av
  
          ActionButton:
              id: btn_next
              text: 'Next screen'
              icon: 'data/icons/next_dark.png'
              important: True
              on_release: app.go_next()
  </code></pre>
  
  <p>This function is run after the scene is loaded:</p>
  
  <pre><code>def _initialize(self):
    self.next = self.ids.btn_next.__self__ # same result if I don't use .__self__
  </code></pre>
  
  <p>This code raises the exception posted above:</p>
  
  <pre><code>self.ids.av.clear_widgets()
  self.ids.av.add_widget(self.next)
  </code></pre>
  
  <p>Here is the full exception trace:</p>
  
  <pre><code>     self._mainloop()
     File "/usr/local/lib/python2.7/dist-packages/kivy/core/window/window_pygame.py", line 266, in _mainloop
       EventLoop.idle()
     File "/usr/local/lib/python2.7/dist-packages/kivy/base.py", line 330, in idle
       Clock.tick_draw()
     File "/usr/local/lib/python2.7/dist-packages/kivy/clock.py", line 429, in tick_draw
       self._process_events_before_frame()
     File "/usr/local/lib/python2.7/dist-packages/kivy/clock.py", line 562, in _process_events_before_frame
       if event.tick(self._last_tick) is False:
     File "/usr/local/lib/python2.7/dist-packages/kivy/clock.py", line 309, in tick
       ret = callback(self._dt)
     File "/usr/local/lib/python2.7/dist-packages/kivy/uix/boxlayout.py", line 174, in do_layout
       c.width = w
     File "properties.pyx", line 345, in kivy.properties.Property.__set__ (kivy/properties.c:3589)
     File "properties.pyx", line 377, in kivy.properties.Property.set (kivy/properties.c:4064)
     File "properties.pyx", line 431, in kivy.properties.Property.dispatch (kivy/properties.c:4657)
     File "/usr/local/lib/python2.7/dist-packages/kivy/uix/actionbar.py", line 552, in on_width
       self._layout_all()
     File "/usr/local/lib/python2.7/dist-packages/kivy/uix/actionbar.py", line 441, in _layout_all
       super_add(child)
     File "/usr/local/lib/python2.7/dist-packages/kivy/uix/boxlayout.py", line 212, in add_widget
       return super(BoxLayout, self).add_widget(widget, index)
     File "/usr/local/lib/python2.7/dist-packages/kivy/uix/layout.py", line 78, in add_widget
       return super(Layout, self).add_widget(widget, index)
     File "/usr/local/lib/python2.7/dist-packages/kivy/uix/widget.py", line 466, in add_widget
       % (widget, parent))
   WidgetException: Cannot add &lt;kivy.uix.actionbar.ActionButton object at 0x7fecb5d6ed50&gt;, it already has a parent &lt;kivy.uix.actionbar.ActionView object at 0x7fecb5d6e8d8&gt;
  </code></pre>