如何通过kv打开Popup?
How to open Popup through kv?
应该很容易,但我找不到答案。我需要通过 .kv
文件用按钮打开 Popup
。更少的文字,更多的代码!
#.kv
#...
Button:
on_press:
#Here I need something like
#Popup_open:
#title: 'title'
#...
我知道我可以通过向我的根添加功能来做到这一点 class
#main.py
#...
myclass(object):
def myPopup():
Popup(title='title',message='message').open()
然后调用这个函数
#.kv
#...
Button:
on_press: root.myPopup()
但这对我来说不是最方便的方法
使用两条规则:
#:import Factory kivy.factory.Factory
<YourPopup@Popup>:
title: 'something'
Label:
text: 'content'
<Test>:
Button:
on_press: Factory.YourPopup().open()
应该很容易,但我找不到答案。我需要通过 .kv
文件用按钮打开 Popup
。更少的文字,更多的代码!
#.kv
#...
Button:
on_press:
#Here I need something like
#Popup_open:
#title: 'title'
#...
我知道我可以通过向我的根添加功能来做到这一点 class
#main.py
#...
myclass(object):
def myPopup():
Popup(title='title',message='message').open()
然后调用这个函数
#.kv
#...
Button:
on_press: root.myPopup()
但这对我来说不是最方便的方法
使用两条规则:
#:import Factory kivy.factory.Factory
<YourPopup@Popup>:
title: 'something'
Label:
text: 'content'
<Test>:
Button:
on_press: Factory.YourPopup().open()