Spaces:
Runtime error
Runtime error
alperugurcan
commited on
Commit
•
49bca44
1
Parent(s):
648fc8c
Update app.py
Browse files
app.py
CHANGED
@@ -87,20 +87,25 @@ css = """
|
|
87 |
#board {
|
88 |
max-width: 400px;
|
89 |
margin: 20px auto;
|
|
|
90 |
}
|
91 |
#board table {
|
92 |
width: 100%;
|
93 |
table-layout: fixed;
|
|
|
|
|
94 |
}
|
95 |
#board td {
|
96 |
text-align: center;
|
97 |
-
font-size:
|
98 |
-
padding:
|
99 |
width: 14.28%;
|
|
|
|
|
100 |
}
|
101 |
.button-row {
|
102 |
max-width: 400px;
|
103 |
-
margin: 0 auto;
|
104 |
display: flex;
|
105 |
justify-content: space-between;
|
106 |
gap: 10px;
|
@@ -108,6 +113,7 @@ css = """
|
|
108 |
.button-row button {
|
109 |
flex: 1;
|
110 |
min-width: 40px;
|
|
|
111 |
}
|
112 |
"""
|
113 |
|
@@ -118,8 +124,9 @@ def create_ui():
|
|
118 |
|
119 |
state = gr.State({"game_over": False})
|
120 |
|
121 |
-
with gr.
|
122 |
-
|
|
|
123 |
|
124 |
board = gr.Dataframe(
|
125 |
value=format_board(initialize_game()),
|
@@ -129,15 +136,16 @@ def create_ui():
|
|
129 |
wrap=True,
|
130 |
elem_id="board",
|
131 |
row_count=BOARD_SIZE[0],
|
132 |
-
col_count=BOARD_SIZE[1]
|
|
|
|
|
133 |
)
|
134 |
|
135 |
message = gr.Textbox(value="Your turn!", label="Status")
|
136 |
new_game = gr.Button("New Game")
|
137 |
|
138 |
def reset_game():
|
139 |
-
|
140 |
-
return format_board(initialize_game()), "Your turn!", state
|
141 |
|
142 |
new_game.click(
|
143 |
reset_game,
|
@@ -148,7 +156,7 @@ def create_ui():
|
|
148 |
button.click(
|
149 |
play_game,
|
150 |
inputs=[board, gr.Number(value=i, visible=False), state],
|
151 |
-
outputs=[board, message]
|
152 |
)
|
153 |
|
154 |
return demo
|
|
|
87 |
#board {
|
88 |
max-width: 400px;
|
89 |
margin: 20px auto;
|
90 |
+
overflow: visible !important;
|
91 |
}
|
92 |
#board table {
|
93 |
width: 100%;
|
94 |
table-layout: fixed;
|
95 |
+
border-collapse: separate;
|
96 |
+
border-spacing: 4px;
|
97 |
}
|
98 |
#board td {
|
99 |
text-align: center;
|
100 |
+
font-size: 28px;
|
101 |
+
padding: 8px;
|
102 |
width: 14.28%;
|
103 |
+
height: 40px;
|
104 |
+
vertical-align: middle;
|
105 |
}
|
106 |
.button-row {
|
107 |
max-width: 400px;
|
108 |
+
margin: 0 auto 20px auto;
|
109 |
display: flex;
|
110 |
justify-content: space-between;
|
111 |
gap: 10px;
|
|
|
113 |
.button-row button {
|
114 |
flex: 1;
|
115 |
min-width: 40px;
|
116 |
+
height: 40px;
|
117 |
}
|
118 |
"""
|
119 |
|
|
|
124 |
|
125 |
state = gr.State({"game_over": False})
|
126 |
|
127 |
+
with gr.Box(elem_classes="button-container"):
|
128 |
+
with gr.Row(elem_classes="button-row"):
|
129 |
+
buttons = [gr.Button(str(i), size="sm") for i in range(BOARD_SIZE[1])]
|
130 |
|
131 |
board = gr.Dataframe(
|
132 |
value=format_board(initialize_game()),
|
|
|
136 |
wrap=True,
|
137 |
elem_id="board",
|
138 |
row_count=BOARD_SIZE[0],
|
139 |
+
col_count=BOARD_SIZE[1],
|
140 |
+
max_rows=BOARD_SIZE[0],
|
141 |
+
height=300
|
142 |
)
|
143 |
|
144 |
message = gr.Textbox(value="Your turn!", label="Status")
|
145 |
new_game = gr.Button("New Game")
|
146 |
|
147 |
def reset_game():
|
148 |
+
return format_board(initialize_game()), "Your turn!", {"game_over": False}
|
|
|
149 |
|
150 |
new_game.click(
|
151 |
reset_game,
|
|
|
156 |
button.click(
|
157 |
play_game,
|
158 |
inputs=[board, gr.Number(value=i, visible=False), state],
|
159 |
+
outputs=[board, message, state]
|
160 |
)
|
161 |
|
162 |
return demo
|