How to hide an ActionButton in Kivy?

前端 未结 4 968
醉梦人生
醉梦人生 2020-12-21 04:04

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

4条回答
  •  暖寄归人
    2020-12-21 05:00

    I'm still learning kivy but it appears that, surprisingly, there is no property or member function to do this. Instead, you have to remove the widget from its parent, or set its color alpha to 0 (which will only work in cases where you have one color).

    Update:

    The traceback indicates that self.next still has a parent when self.ids.av.add_widget(self.next) is called. Since this call is preceded by a self.ids.av.clear_widgets(), the only way that self.next is still in widget tree is that it is actually not a child of self.ids.av. Maybe it is a child of the default layout used by av, and layout doesn't immediately get garbage collected. Try

    print 'next in av.children:', self.next in self.ids.av.children
    print 'parent of next:', self.next.parent
    # self.ids.av.clear_widgets()
    # self.ids.av.add_widget(self.next)
    parent = self.next.parent
    parent.remove_widget(self.next)
    parent.add_widget(self.next)
    

提交回复
热议问题