2017-03-12 10 views
0

In der kivy gui unten, wenn ich den Knopf 'Pen' drücke, sollte ein ActionDropDown kommen. Ich sehe es nicht öffnen. Aber der 'Stift'-Knopf verhält sich so, als ob ein DropDown damit geöffnet wäre (z. B. kann man beim ersten Versuch nicht darauf drücken). Was ist falsch?Kivy ActionDropDown öffnet nicht

from kivy.uix.boxlayout import BoxLayout 
from kivy.uix.actionbar import ActionDropDown 
from kivy.app import App 
from kivy.lang import Builder 
from kivy.uix.screenmanager import Screen 

Builder.load_string(""" 
<NoteScreen>: 
    BoxLayout: 
     orientation: 'vertical' 

     NoteScreenMenu: 

     Label: 
      text: 'i am a label' 

<NoteScreenMenu>: 
    orientation: 'horizontal' 
    size_hint_y: None 
    height: 48 

    ActionBar: 
     pos_hint: dict(top=1) 

     ActionView: 
      use_separator: True 

      ActionPrevious: 
       title: 'Drawing Screen' 
       with_previous: False 

      ActionOverflow: 

      ActionButton: 
       id: pen_button 
       text: 'Pen' 
       on_release: root.pen_drop_down.open(self) 

      ActionButton: 
       text: 'Eraser' 

<PenDropDown>: 
    Button: 
     text: 'Close this' 
    Button: 
     text: 'btn1' 
""") 


class NoteScreen(Screen): 
    pass 


class NoteScreenMenu(BoxLayout): 
    def __init__(self, **kwargs): 
     super(NoteScreenMenu, self).__init__(**kwargs) 
     self.pen_drop_down = PenDropDown() 


class PenDropDown(ActionDropDown): 
    pass 


class TheApp(App): 
    def build(self): 
     return NoteScreen(name='note') 


if __name__ == '__main__': 
    TheApp().run() 

Antwort

0

Das Problem war hier:

<PenDropDown>: 
    Button: 
     text: 'Close this' 
    Button: 
     text: 'btn1' 

Ich brauchte Höheninformationen zu Tasten in der Dropdown-Liste hinzuzufügen:

<PenDropDown>: 
    Button: 
     text: 'Close this' 
     height: 48 
     size_hint_y : None 

    Button: 
     text: 'btn1' 
     height: 48 
     size_hint_y : None