Update app.py
Browse files
app.py
CHANGED
@@ -91,7 +91,11 @@ def click_handler(evt, state):
|
|
91 |
if state is None:
|
92 |
state = (initialize_board(), -1, None, None, [])
|
93 |
board, player, lu, la, history = state
|
94 |
-
|
|
|
|
|
|
|
|
|
95 |
cell = 400 // 8
|
96 |
c, r = int(x // cell), int((y - cell * 2) // cell)
|
97 |
|
@@ -130,4 +134,4 @@ with gr.Blocks() as demo:
|
|
130 |
new_btn=gr.Button("New Game")
|
131 |
img.select(click_handler,inputs=[state],outputs=[img,state])
|
132 |
new_btn.click(fn=reset_handler,outputs=[state,img])
|
133 |
-
demo.launch()
|
|
|
91 |
if state is None:
|
92 |
state = (initialize_board(), -1, None, None, [])
|
93 |
board, player, lu, la, history = state
|
94 |
+
# Handle evt.index callable vs attribute
|
95 |
+
if callable(evt.index):
|
96 |
+
x, y = evt.index()
|
97 |
+
else:
|
98 |
+
x, y = evt.index
|
99 |
cell = 400 // 8
|
100 |
c, r = int(x // cell), int((y - cell * 2) // cell)
|
101 |
|
|
|
134 |
new_btn=gr.Button("New Game")
|
135 |
img.select(click_handler,inputs=[state],outputs=[img,state])
|
136 |
new_btn.click(fn=reset_handler,outputs=[state,img])
|
137 |
+
demo.launch()
|