【发布时间】:2017-10-05 12:29:56
【问题描述】:
我有一个有 3 个屏幕的应用程序。在其中我已经禁用了按钮,我希望无法根据我的 py 文件中的 IF 语句中的某些条件。
这是我的 main.kv
#:import FadeTransition kivy.uix.screenmanager.FadeTransition
ScreenManagement:
transition: FadeTransition()
MainScreen:
ProjectScreen:
ScopeScreen:
<MainScreen>:
name: 'main'
scope_button : scope_bttn
BoxLayout:
orientation: "vertical"
spacing:10
padding:10
#some wigedt..
Button:
on_press: app.root.current = 'project'
text: 'Project Specification'
Button:
on_press: app.root.current = 'scope'
text: 'Project Scope'
disabled: True
id: scope_bttn
<ProjectScreen>:
name: 'project'
Button:
on_release: app.root.current = 'main'
text: 'Back'
Button:
text: 'Process'
on_press: root.create_project()
on_release: app.root.current = 'main'
<ScopeScreen>:
name: 'scope'
#some widgets
这是我的 main.py 的相关部分
class MainScreen(Screen):
pass
class ProjectScreen(Screen):
def create_project(self):
If something True:
here I would like to change property of scope_bttn.disable to true
class ScopeScreen(Screen):
pass
class ScreenManagement(ScreenManager):
pass
presentation = Builder.load_file("main.kv")
class MainApp(App):
def build(self):
return presentation
ConfiguratorApp = MainApp()
ConfiguratorApp.run()
我知道我应该使用 id,但我找不到正确的教程。我是 kivy 和 python 的新手。
我们将不胜感激。
【问题讨论】:
标签: python-3.x widget kivy