【发布时间】:2019-11-12 10:40:21
【问题描述】:
我创建了一个弹出窗口。通常我们使用 pop.dismiss 来关闭弹窗。但我想在该弹出窗口中添加一些按钮。我有 4 个按钮。当按下这些按钮中的 2 个时,它们应该显示另一个小部件(boxlayout)。 但是当我触摸这些按钮时,应用程序崩溃了。
但是,这 4 个按钮中的其他 2 个在触摸时会显示另一个弹出窗口。它运行良好而不会崩溃。
- 从弹出窗口>按钮触摸>显示另一个弹出窗口>没有崩溃
- 从弹出窗口>按钮这 4 个按钮中的任何一个> 以显示 boxlayout 小部件> 应用程序崩溃了!
谁能解释一下?我应该如何解决这个问题?
(.py) 文件
class abc(Popup):
def about_app(self):
self.clear_widgets()
self.add_widget(about())
def about_leo(self):
self.clear_widgets()
self.add_widget(page1())
def help(self):
pops=help_popup()
pops.open()
def website(self):
pops=website()
pops.open()
(.kv) 文件
<abc>:
title: 'LEO CLUB'
title_color: 1, 0, 0, 1
title_size: 50
title_align:'center'
background: 'popup.png'
size_hint: .6, 0.8
pos_hint: {'right': .6, 'top': 1}
BoxLayout:
BoxLayout:
orientation:'vertical'
Button:
bold: True
text: "About LEO"
background_color: 0, 0, 0, 0
on_release: root.about_leo()
Button:
bold:True
text: "About App"
background_color: 0, 0, 0, 0
on_release: root.about_app()
Button:
bold: True
text: "Website"
background_color: 0, 0, 0, 0
on_release: root.website()
Button:
bold: True
text: "Help"
background_color: 0, 0, 0, 0
on_release: root.help()
【问题讨论】:
-
您是要添加我的代码吗?
-
我做到了。现在请帮助我