python - How to hide an ActionButton in Kivy? -


I am trying to modify the visibility of the current view of the action button (using the screen manager). I could not find the visible property or something that could just toggle visibility (neither for actionbutton nor for general widgets)

Suggestions to change the texture of the button, but I do not want to believe that on such a hack to accomplish such a simple task, besides, the background of my app will be variable .

Regardless of its unnecessary complexity, I modified the widget to work in my case (Actionbars and Actionbuttons), so I cleared the widget from ActionView and then adding ActionButton I tried to collect both a weak and self member, I got the following error with both:

  widget expression: , it is already used by parents and lt; 0x7fcd3fe22870 & gt; on kivy.uix.actionbar.ActionView object   

Any ideas will be greatly appreciated. I am working with Dev version, but it does not work with 1.8.

Edit I tried the following code:

  & lt; AppActionBar & gt; ActionView: id: av ActionButton: id: btn_next text: 'next screen' icon: 'data / icons / next_ dark.png' important: true_reale: app.go_next ()   

this The function is run after loading the view:

  def _initialize (self): self.next = self.ids.btn_next .__ self__ # This is the result if I do not use .__ Self__   

This code raises the exceptions posted above:

  self.ids.av.clear_widgets () self.ids.av.add_widget ( Self.next)   

There is a full exception trace:

  self._mainloop () file "/usr/local/lib/python2.7/dist -packages / kiv Y / core /window/window_pygame.py ", line 266, _mainloop EventLoop.idle () file" /usr/local/lib/python2.7/dist-packages/kivy/base.py ", line 330, inactive Clock In the .tick_draw () file, "/usr/local/lib/python2.7/dist-packages/kivy/clock.py", line 429, remove yourself in the tick. _process_events_before_frame () file "/usr/local/lib/python2.7/dist-packages/kivy/clock.py", in line 562, _process_events_before_frame if event.tick (self._last_tick) is incorrect: the file "/ Usr / local / Lib / python2.7 / dist-packages / kivy / clock.py ", the file" /usr/local/lib/python2.7/dist-packages/Kivy/ "in line 309, tick reset = callback (self._dt) Uix / boxlayout.py ", line 174, do_layout c.width = w file" properties.pyx ", line 345, in kivy.properties.Property.__ set__ (kivy / properties.c: 3589) file" Properties .pyx " Kivy.properties.Property.dispatch (kivy / properties.c: 4657) file, in line 377, in kivy.properties.Property.set (kivy / properties.c: 4064) file "properties.pyx", line 431, " /usr/local/lib/python2.7/dist-packages/kivy/uix/actionbar.py ", w In the file "/usr/local/lib/python2.7/ Dist-packages / kivy / uix / actionbar.py" in line 552, on_width self._layout_all (), line 441, _layout_all "/ usr / Local / lib / python2.7 / dist-packages / kivy / uix / boxlayout.py ", line 212, add_widget in return super (b oslleout, self). Add_widget (widget, index) file "/usr/local/lib/python2.7/dist-packages/kivy/uix/layout.py", line 78, add_widget in return super (layout, self). Add_widget (widget, index) file "/usr/local/lib/python2.7/dist-packages/kivy/uix/widget.py", line 466, add_widget% (widget, default) widget option: & lt; 0x7fecb5d6ed50 & gt; On the kivy.uix.actionbar.ActionButton object, it is already used by parents and lt; 0x7fecb5d6e8d8 on kivy.uix.actionbar.ActionView object & gt;    

The widgets are better hidden by adding or deleting widgets. Just set the position to include an offscreen coordinate:

  # Save MyWidget.pos's old y-coordinate. Root.saved_y = MyWidget.y # Now take the widget off-screen (remember That this situation is right now (an alias for X, Y) MyWidget.y = 5000   

(I have tested this solution, it works.)

Comments

Popular posts from this blog

Pass DB Connection parameters to a Kettle a.k.a PDI table Input step dynamically from Excel -

multithreading - PhantomJS-Node in a for Loop -

c++ - MATLAB .m file to .mex file using Matlab Compiler -