我kivy.factory.Factory用来打开弹出窗口,但是当我想关闭它们时它不起作用。
代码:
from kivy.app import App
from kivy.lang import Builder
x = Builder.load_string("""
#:import F kivy.factory.Factory
#:import Window kivy.core.window.Window
Screen:
Button:
text: 'Press to Open First Popup'
on_press:
F.FirstPopup().open()
<FirstPopup@Popup>:
title: 'First Popup'
size_hint: None, None
width: Window.width / 1.4
height: Window.width / 1.4
Button:
text: 'Press to Open Second Popup'
on_press: F.SecondPopup().open()
<SecondPopup@Popup>:
title: 'Second Popup'
size_hint: None, None
width: Window.width / 1.8
height: Window.width / 1.8
Button:
text: 'Press to Close Both Popups'
on_press:
root.dismiss()
F.FirstPopup().dismiss() # < DOSEN'T WORK
""")
class MyApp(App):
def build(self):
return x
MyApp().run()
相关分类