我正试图让我的python和kivy文件打开一个弹出窗口。它说我的Boxlayout对象没有“open\u popup”属性
以下是我的python代码:
from kivy.app import App
from kivy.properties import BooleanProperty, ListProperty
from kivy.modules import inspector
from kivy.core.window import Window
from kivy.uix.popup import Popup
class CustomPopup(Popup):
pass
class MPMS(App):
def build(self):
inspector.create_inspector(Window, self)
def show_config_popup(self, popup):
pass
def open_popup(self):
the_popup = CustomPopup()
the_popup.open()
if __name__ == '__main__':
app = MPMS()
app.run()
这是我的奇维
BoxLayout:
orientation: 'vertical'
Label:
text: 'MPMS'
BoxLayout:
orientation: 'horizontal'
size_hint: (1, 0.25)
BoxLayout:
orientation: 'vertical'
Button:
id: 'screening_button_mainmenu'
text: 'Screening'
BoxLayout:
orientation: 'vertical'
Button:
id: 'configuration_button_mainmenu'
text: 'Configuration'
on_press: root.open_popup()
<CustomPopup>:
size_hint: .5, .5
auto_dismiss: False
title: "The Popup"
BoxLayout:
orientation: 'horizontal'
Label:
text: 'popup has appeared'
我试着在youtube和其他网站上查找视频,但我看不出它对我有什么帮助,因为我无法将其应用于我的情况。请帮帮我。提前谢谢
这是因为您正在执行
on_press: root.open_popup()
,在这种情况下root
是您的BoxLayout
(该kv
规则的根)。你想要的是因为
open_popup()
方法在App
中相关问题 更多 >
编程相关推荐