Код:
Код: Выделить всё
# Current color is set by the player further back in the code
\\\\\\ Pythonista
# Changes buttons colour to the current color
def guess_tapped(sender, col):
sender.background_color = col
# This creates the row of guess squares. 1st one is displayed then up to
# 7 subsquent ones displayed until the player guesses rightguess
guess = []
for j in range(6):
guess_sq = ui.Button()
guess_sq.frame = (25 + (j * 65), 250, 50, 50)
guess_color = 'lightgray'
guess_sq.background_color = guess_color
guess_sq.hidden = False
guess.append(guess_sq.background_color)
main_view.add_subview(guess_sq)
print(f'Current color1- {current_color}') # This displays the current color
#This should send the request to change the colour of the button
guess[0].action = lambda sender: guess_tapped(sender, current_color)
guess[1].action = lambda sender: guess_tapped(sender, current_color
guess[2].action = lambda sender: guess_tapped(sender, current_color)
guess[3].action = lambda sender: guess_tapped(sender, current_color)
guess[4].action = lambda sender: guess_tapped(sender, current_color)
guess[5].action = lambda sender: guess_tapped(sender, current_color)
Где я ошибаюсь?
Мобильная версия