guizero

AttributeError: 'str' object has no attribute 'disable'

淺唱寂寞╮ 提交于 2020-01-22 03:08:06
问题 I am currently learning guizero and I ran into an issue fairly quickly with making a function that disables buttons when clicked. The entire code is a bit much so below is the code that's applicable to the situation. buttons = ["button0", "button1"] def disable(n): buttons[n].disable() menu = Box(app, layout="grid", grid=[1,0]) button0 = PushButton(menu, command=lambda: disable(0), text="x", grid=[0,0]) button1 = PushButton(menu, command=lambda: disable(1), text="x", grid=[1,0]) Unfortunately

How to know who is winner in Tic Tac Toe in python using guizero

夙愿已清 提交于 2020-01-15 04:11:08
问题 I have created a game called Tic Tac Toe. There are 2 players one of them are Xs one of them are Os all you have to do is get your symbol 3 in a row without the other person blocking you. The Gui for the game looks like this: Code: from guizero import App, TextBox, PushButton, Text, info empty = ' ' player = "X" def clicked(z): button = buttonlist[int(z)] # Finds out which button was pressed global empty, player if button.text != empty: pass # If button already pushed do nothing else: # Marks