关于 Popup Windows 和 Screens 的 Kivy
Kivy regarding Popup Windows and Screens
我有一个问题,在 Kivy 中是否可以从弹出窗口切换到另一个屏幕window?
这是一个解决方案
from kivy.lang.builder import Builder
from kivy.app import App
from kivy.uix.popup import Popup
kv = """
#:import Factory kivy.factory.Factory
<ChangePopup>:
size_hint: (None, None)
size: (200, 200)
Button:
text: "Change screen"
on_press: app.root.current = 'screen2'; root.dismiss()
ScreenManager:
Screen:
BoxLayout:
orientation: 'vertical'
Label:
text: "Screen1"
Button:
text: "Open Popup to change to Screen2"
on_press: Factory.ChangePopup().open()
Screen:
name: 'screen2'
Label:
text: "Screen2"
"""
class ChangePopup(Popup):
pass
sm = Builder.load_string(kv)
class NewApp(App):
def build(self):
return sm
if __name__ == '__main__':
NewApp().run()
我有一个问题,在 Kivy 中是否可以从弹出窗口切换到另一个屏幕window?
这是一个解决方案
from kivy.lang.builder import Builder
from kivy.app import App
from kivy.uix.popup import Popup
kv = """
#:import Factory kivy.factory.Factory
<ChangePopup>:
size_hint: (None, None)
size: (200, 200)
Button:
text: "Change screen"
on_press: app.root.current = 'screen2'; root.dismiss()
ScreenManager:
Screen:
BoxLayout:
orientation: 'vertical'
Label:
text: "Screen1"
Button:
text: "Open Popup to change to Screen2"
on_press: Factory.ChangePopup().open()
Screen:
name: 'screen2'
Label:
text: "Screen2"
"""
class ChangePopup(Popup):
pass
sm = Builder.load_string(kv)
class NewApp(App):
def build(self):
return sm
if __name__ == '__main__':
NewApp().run()