Reputation: 1
I'm trying to build a program that takes a physical input and do some stuff(obj and motors) and while those two function are executing I need to disable a button. I tried something like this but nothing happens. Is there a way to enable/disable a button with a python function? Thanks in advance.
async def action():
await MainMenu.disable()
await obj()
motors()
print('action is finished, starting loop agian')
await MainMenu.enable()
class MainMenu(Screen):
running = BooleanProperty(False)
async def disable():
running = BooleanProperty(True)
return running
async def enable():
running = BooleanProperty(False)
return running
pass
kv file
<MainMenu>:
Button:
text: 'button that needs to be disabled'
disabled: root.running
Upvotes: 0
Views: 204
Reputation: 39012
You are not assigning values to the running
Property correctly. In your methods, just do something like:
self.running = True
or
self.running = False
This code should work:
class MainMenu(Screen):
running = BooleanProperty(False)
def disable(self):
self.running = True
def enable(self):
self.running = False
Upvotes: 1