-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
46 lines (38 loc) · 1.2 KB
/
Copy pathmain.py
File metadata and controls
46 lines (38 loc) · 1.2 KB
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
# Main function
import argparse
from cli import CLI
from ui import app
from gui import pygameApp
def runningInStreamlit():
"""Detect whether this script was launched via `streamlit run`."""
try:
from streamlit.runtime.scriptrunner import get_script_run_ctx
except ImportError:
try:
from streamlit.script_run_context import get_script_run_ctx
except ImportError:
try:
from streamlit.report_thread import get_report_ctx as get_script_run_ctx
except ImportError:
return False
return get_script_run_ctx() is not None
def main():
# `streamlit run main.py` always wins: hand off to the Streamlit app
if runningInStreamlit():
app()
return
# Otherwise, pick the interface via --mode when invoked with `python main.py`
parser = argparse.ArgumentParser(description="Veiled Chess")
parser.add_argument(
"--mode",
choices=["cli", "gui"],
default="cli",
help="Interface to run: cli (default) or gui (PyGame)",
)
args = parser.parse_args()
if args.mode == "gui":
pygameApp()
else:
CLI()
if __name__ == '__main__':
main()