Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,23 +1,49 @@
|
|
| 1 |
import streamlit as st
|
|
|
|
| 2 |
|
| 3 |
-
|
| 4 |
-
|
|
|
|
|
|
|
|
|
|
| 5 |
return input
|
| 6 |
|
| 7 |
def validate_userInput(user_input):
|
| 8 |
if user_input.isdigit():
|
| 9 |
return True
|
| 10 |
else:
|
| 11 |
-
return
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 12 |
|
| 13 |
#UIApp starts here
|
| 14 |
st.set_page_config(page_title="Python - Tic Tac Toe", page_icon=":python:")
|
| 15 |
st.header("Python - Tic Tac Toe")
|
|
|
|
| 16 |
|
| 17 |
user_input=get_userInput()
|
| 18 |
response=validate_userInput(user_input)
|
| 19 |
|
|
|
|
| 20 |
submit=st.button('Submit')
|
|
|
|
|
|
|
|
|
|
| 21 |
if submit:
|
| 22 |
st.subheader("")
|
| 23 |
-
st.write(response)
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
import streamlit as st
|
| 2 |
+
import pandas as pd
|
| 3 |
|
| 4 |
+
#Globals
|
| 5 |
+
legal_numbers = [1,2,3,4,5,6,7,8,9]
|
| 6 |
+
|
| 7 |
+
def get_userInput():
|
| 8 |
+
input = st.text_input("Enter a number between 1 to 9: ", key="input")
|
| 9 |
return input
|
| 10 |
|
| 11 |
def validate_userInput(user_input):
|
| 12 |
if user_input.isdigit():
|
| 13 |
return True
|
| 14 |
else:
|
| 15 |
+
return "Please enter a digit between 1 to 9."
|
| 16 |
+
|
| 17 |
+
def display_board():
|
| 18 |
+
df = pd.DataFrame(
|
| 19 |
+
[
|
| 20 |
+
{" X ", " O ", " X "},
|
| 21 |
+
{" ", " ", " "},
|
| 22 |
+
{" ... ", " ... ", " ... "},
|
| 23 |
+
]
|
| 24 |
+
)
|
| 25 |
+
st.dataframe(df, use_container_width=True)
|
| 26 |
+
|
| 27 |
+
#def update_legalNumbers():
|
| 28 |
+
|
| 29 |
+
|
| 30 |
|
| 31 |
#UIApp starts here
|
| 32 |
st.set_page_config(page_title="Python - Tic Tac Toe", page_icon=":python:")
|
| 33 |
st.header("Python - Tic Tac Toe")
|
| 34 |
+
st.text("Legal Numbers: ", legal_numbers.join(","))
|
| 35 |
|
| 36 |
user_input=get_userInput()
|
| 37 |
response=validate_userInput(user_input)
|
| 38 |
|
| 39 |
+
#UI Buttons
|
| 40 |
submit=st.button('Submit')
|
| 41 |
+
replay=st.button('Replay')
|
| 42 |
+
|
| 43 |
+
#Button functionality
|
| 44 |
if submit:
|
| 45 |
st.subheader("")
|
| 46 |
+
st.write(response)
|
| 47 |
+
|
| 48 |
+
if replay:
|
| 49 |
+
display_board()
|