Kivy ActionDropDown 打不开
Kivy ActionDropDown does not open
在下面的 kivy gui 中,当我按下按钮 'Pen' 时,应该会出现 ActionDropDown
。我没有看到它打开。但是 'Pen' 按钮的行为就好像 DropDown
是用它打开的(例如,您不能在第一次尝试时按下它)。怎么了?
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()
问题出在这里:
<PenDropDown>:
Button:
text: 'Close this'
Button:
text: 'btn1'
我需要为下拉菜单中的按钮添加高度信息:
<PenDropDown>:
Button:
text: 'Close this'
height: 48
size_hint_y : None
Button:
text: 'btn1'
height: 48
size_hint_y : None
在下面的 kivy gui 中,当我按下按钮 'Pen' 时,应该会出现 ActionDropDown
。我没有看到它打开。但是 'Pen' 按钮的行为就好像 DropDown
是用它打开的(例如,您不能在第一次尝试时按下它)。怎么了?
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()
问题出在这里:
<PenDropDown>:
Button:
text: 'Close this'
Button:
text: 'btn1'
我需要为下拉菜单中的按钮添加高度信息:
<PenDropDown>:
Button:
text: 'Close this'
height: 48
size_hint_y : None
Button:
text: 'btn1'
height: 48
size_hint_y : None