Kivy 不显示操作栏
Kivy does not display actionbar
我有以下代码来创建操作栏:
Python代码:
from kivy.app import App
from kivy.lang import Builder
from kivy.core.window import Window
from kivy.uix.actionbar import ActionBar
Window.clearcolor = (1, 1, 1, 1)
class Menu(ActionBar):
pass
class TestApp(App):
def build(self):
return design
design = Builder.load_file('test.kv')
这是 kv 代码:
#: import ActionBar kivy.uix.actionbar
<Menu>:
pos_hint: {'top': 1}
ActionView:
use_separator: True
ActionPrevious:
title: 'Action Bar'
with_previous: False
ActionButton:
important: True
text: 'Add'
ActionButton:
text: 'FAQ'
ActionButton:
text: 'Credits'
当我运行上面的代码时,它只是呈现一个白色window并立即关闭。我做错了什么?
试试这个:
from kivy.core.window import Window
from kivy.base import runTouchApp
from kivy.lang import Builder
Window.clearcolor = (1, 1, 1, 1)
runTouchApp(Builder.load_file('test.kv'))
test.kv:
ActionBar:
pos_hint: {'top':1}
ActionView:
use_separator: True
ActionPrevious:
title: 'Action Bar'
with_previous: False
ActionOverflow:
ActionButton:
icon: 'atlas://data/images/defaulttheme/audio-volume-high'
ActionButton:
important: True
text: 'Important'
ActionButton:
text: 'Btn2'
ActionButton:
text: 'Btn3'
ActionButton:
text: 'Btn4'
ActionGroup:
text: 'Group1'
ActionButton:
text: 'Btn5'
ActionButton:
text: 'Btn6'
ActionButton:
text: 'Btn7'
我有以下代码来创建操作栏:
Python代码:
from kivy.app import App
from kivy.lang import Builder
from kivy.core.window import Window
from kivy.uix.actionbar import ActionBar
Window.clearcolor = (1, 1, 1, 1)
class Menu(ActionBar):
pass
class TestApp(App):
def build(self):
return design
design = Builder.load_file('test.kv')
这是 kv 代码:
#: import ActionBar kivy.uix.actionbar
<Menu>:
pos_hint: {'top': 1}
ActionView:
use_separator: True
ActionPrevious:
title: 'Action Bar'
with_previous: False
ActionButton:
important: True
text: 'Add'
ActionButton:
text: 'FAQ'
ActionButton:
text: 'Credits'
当我运行上面的代码时,它只是呈现一个白色window并立即关闭。我做错了什么?
试试这个:
from kivy.core.window import Window
from kivy.base import runTouchApp
from kivy.lang import Builder
Window.clearcolor = (1, 1, 1, 1)
runTouchApp(Builder.load_file('test.kv'))
test.kv:
ActionBar:
pos_hint: {'top':1}
ActionView:
use_separator: True
ActionPrevious:
title: 'Action Bar'
with_previous: False
ActionOverflow:
ActionButton:
icon: 'atlas://data/images/defaulttheme/audio-volume-high'
ActionButton:
important: True
text: 'Important'
ActionButton:
text: 'Btn2'
ActionButton:
text: 'Btn3'
ActionButton:
text: 'Btn4'
ActionGroup:
text: 'Group1'
ActionButton:
text: 'Btn5'
ActionButton:
text: 'Btn6'
ActionButton:
text: 'Btn7'