python - kivy syntax error - conditions inside widget_add -


i have got syntax error in kivy application. because can't have conditions inside widget_add? how can make work this?

    def status(what):         object =         self.add_widget(             label(                 text='you selected '+object+', please wait...',                 size_hint=(.3, .1)                 if object == "car":                     pos_hint={'center_x': .3, 'center_y': .6}                 elif object == "tree":                     color = (1,0,0,1),                     pos_hint={'center_x': .7, 'center_y': .6}             )         ) 

error:

running "python.exe c:\users\somebody\desktop\kivy\test.py" \n   file "c:\users\slugma\somebody\kivy\test.py", line 51     if object == "vnc":                       ^ syntaxerror: invalid syntax 

you correct, cannot have conditionals inside function's arguments. move if...elif conditional outside (just after object = what line), calculate value of pos_hint, call self.add_widget(label(args)).


Comments

Popular posts from this blog

php - Submit Form Data without Reloading page -

linux - Rails running on virtual machine in Windows -

php - $params->set Array between square bracket -