Starting off a Tic Tac Toe game in Pythonista, but I can't quite figure out how to get the computer to randomly pick a button then draw the image. Any help?
# coding: utf-8
import ui
import random
global buttons
buttons = ['button1', 'button2', 'button3', 'button4', 'button5', 'button6', 'button7', 'button8','button9']
def computer_pick():
global buttons
computer = random.choice(buttons)
name = 'name: %s' % computer
computer = ui.Button(name)
computer.image = ui.Image.named('ionicons-ios7-circle-outline-32')
def button_tapped(sender):
global buttons
sender.image = ui.Image.named('ionicons-close-32')
buttons.remove(sender.name)
print buttons
computer_pick()
v = ui.load_view('tic-tac-toe')
v.present('sheet')
I just want help with this, I'd like to figure the rest out on my own :)