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