我建立了一个应用程序,这是拍照,去另一个空屏幕上运行我的主要代码的背景。当我的主代码处于第一个if条件时,我想在空屏幕上显示一个文本输入框;当代码处于第二个if条件时,我想隐藏这个框。我的代码在下面。我写了“废话”来回答我的问题。你知道吗
class CheckScreen(Screen):
def deneme(self):
#MY MAIN CODE
#...
if(BLABLABLA)
self.isShownMenu = BooleanProperty(True)
else
self.isShownMenu = BooleanProperty(False)
GUI = Builder.load_string("""
#BLABLABLA1
#...
<SingleLineTextInput@TextInput>:
pos_hint: {'center_x': .5, 'center_y': .4}
size_hint: 0.5, 0.05
multiline: False
<CheckScreen>:
#BLABLABLA2
#...
SingleLineTextInput:
opacity: 1 if root.isShownMenu else 0
""")
class TestCamera(App):
def build(self):
return GUI
TestCamera().run()
当我运行这个程序时,即使我在条件中将True改为False,应用程序也总是显示文本输入。我的问题在哪里?你知道吗
您的布尔属性需要在类级别定义:
根据需要使用
True
或False
。然后在代码中只引用self.isShownMenu
,如:相关问题 更多 >
编程相关推荐