Kivy:从另一个弹出窗口中关闭一个弹出窗口

我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()


叮当猫咪
浏览 237回答 1
1回答
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

Python