0
我的kivy應用程序中出現語法錯誤。是否因爲我無法在widget_add中擁有條件?我怎樣才能讓它像這樣工作?kivy語法錯誤 - widget_add中的條件
def status(what):
object = what
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}
)
)
錯誤:
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