Anurag-Sharma
Anurag-Sharma

Reputation: 4398

Kivy: 'NoneType' object has no attribute 'bind'

I was testing out the ActionBar widget of Kivy, here is my program -

 from kivy.app import App
 from kivy.lang import Builder
 from kivy.uix.boxlayout import BoxLayout

 Builder.load_string('''
 <RootWidget>:
      ActionBar:
          pos_hint: {'top':1}
      ActionView:
          ActionButton:
              text: "Button"
''')


class RootWidget(BoxLayout):
     pass

class MainApp(App):
     def build(self):
         return RootWidget()

if __name__ == "__main__":
     MainApp().run()

Nothing much going on here, I just added an ActionBar inside the BoxLayout.
Here is the traceback which I am getting on executing the program.

Upvotes: 1

Views: 3400

Answers (2)

Jean-Pierre Schnyder
Jean-Pierre Schnyder

Reputation: 1934

Here's a working example of the use of ActionBar:

actionbardemo.kv

ActionBarDemo:

    # Reference actionbardemo.py
    #: import main actionbardemo

        <ActionBarDemo>:
            orientation: "vertical"
            padding: 10
            spacing: 10
            canvas.before:
                Color:
                    rgb: [0.22,0.22,0.22]
                Rectangle:
                    pos: self.pos
                    size: self.size

            BoxLayout:
                size_hint_y: None
                ActionBar:
                    pos_hint: {'top':1}
                    ActionView:
                        use_separator: True
                        ActionPrevious:
                        ActionOverflow:
                            ActionButton:
                                text: 'Menu 1'
                                on_press: root.menuOne()
                            ActionButton:
                                text: 'Menu 2'
                                on_press: root.menuTwo()
            BoxLayout:
            TextInput:

actionbardemo.py

from kivy.app import App
from kivy.uix.boxlayout import BoxLayout
from kivy.uix.popup import Popup
from kivy.uix.label import Label

class ActionBarDemo(BoxLayout):
    def menuOne(menu):
        popup = Popup(title='Popup', content=Label(text='Menu one'), size_hint=(None, None), size=(400, 400))
        popup.open()

    def menuTwo(menu):
        popup = Popup(title='Popup', content=Label(text='Menu two'), size_hint=(None, None), size=(400, 400))
        popup.open()

class ActionBarDemoApp(App):
    def build(self):
        return ActionBarDemo()

if __name__== '__main__':
    dbApp = ActionBarDemoApp()

    dbApp.run()

Result:

Demo on an Android smartphone

Upvotes: 1

hchandad
hchandad

Reputation: 522

try sth like this:

 <RootWidget>:
      ActionBar:
          pos_hint: {'top':1}
          ActionPrevious:
          ActionView:
              ActionButton:
                  text: "Button"

in your case the ActionView is treated as a child of RootWidget , also notice the ActionPrevious .

Upvotes: 2

Related Questions