0
我想更改按下按钮时启动的功能。已绑定按钮on_press
的Python文件:
class UpdateScreen(Screen):
swimbot = {}
def swimbot_connected(self):
wallouh = list(AdbCommands.Devices())
if not wallouh:
self.ids['text_label'].text = 'Plug your Swimbot and try again'
else:
for devices in AdbCommands.Devices():
output = devices.serial_number
if re.match("^(.*)swimbot", output):
self.ids['mylabel'].text = 'Etape 2: Do you need an update ?'
self.ids['action_button'].text = 'Check'
self.ids['action_button'].bind(on_press = self.check_need_update())
else:
self.ids['text_label'].text = 'Plug your Swimbot and try again'
千伏文件:
<UpdateScreen>:
BoxLayout:
id: update_screen_layout
orientation: 'vertical'
Label:
id: mylabel
text: "Etape 1: Connect your Swimbot"
font_size: 26
Label:
id: text_label
text: "Truc"
font_size: 24
FloatLayout:
size: root.size
pos: root.pos
Button:
id: action_button
pos_hint: {'x': .05, 'y':.25}
size_hint: (.9, .4)
text: "Try"
font_size: 24
on_press: root.swimbot_connected()
但我认为这不是做这种正确的做法:
self.ids['action_button'].bind(on_press = self.check_need_update())
有了,我直接去到check_need_update(),它不会等待我按下按钮。