Skip to content
This repository has been archived by the owner on May 30, 2024. It is now read-only.

Commit

Permalink
Build into exe
Browse files Browse the repository at this point in the history
  • Loading branch information
maxtyson123 committed Mar 16, 2023
1 parent 03bd351 commit 85c18be
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 18 deletions.
18 changes: 7 additions & 11 deletions Maxs_Modules/network.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,19 @@
import json
import time
import types
import socket
import selectors

from Maxs_Modules.files import UserData
from Maxs_Modules.tools import install_package
from Maxs_Modules.debug import debug_message, error
from Maxs_Modules.renderer import render_text

import socket
import selectors

try:
import requests
except ImportError:
install_package("requests")
import requests

# - - - - - - - Classes - - - - - - - -#

Expand Down Expand Up @@ -755,14 +759,6 @@ def api_get_questions(amount: int, category: int, difficulty: str, question_type
@return: A list of dictionaries containing the questions
"""

# Get the setup data

try:
import requests
except ImportError:
install_package("requests")
import requests

redo = True
api_fix = 0

Expand Down
2 changes: 1 addition & 1 deletion Maxs_Modules/renderer.py
Original file line number Diff line number Diff line change
Expand Up @@ -625,7 +625,7 @@ def render_quiz_header(game) -> None:
render_text(f"Time Limit: {time_limit} seconds")


def gui_init():
def init_gui():
# Import here to prevent circular imports
from Maxs_Modules.network import get_free_port, get_ip

Expand Down
3 changes: 1 addition & 2 deletions Maxs_Modules/tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@


# - - - - - - - Variables - - - - - - -#
imported_timeout = False



# - - - - - - - Functions - - - - - - -#
Expand Down Expand Up @@ -116,7 +116,6 @@ def get_user_input_of_type(type_to_convert: object, input_message: str = "", mus
except ImportError:
install_package("inputimeout")
from inputimeout import inputimeout, TimeoutOccurred

# Check if the time limit has been reached
if time.time() - start_time > max_time:
return None
Expand Down
1 change: 1 addition & 0 deletions build.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
py -m eel main.py web --onefile --hidden-import=pip --hidden-import=natsort --hidden-import=requests --hidden-import=inputimeout --hidden-import=eel
20 changes: 16 additions & 4 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
# [x] Clean Up aka more efficient and correct commenting
# [x] GUI Base, port the current render to a simple GUI
# [x] GUI Extended, Buttons instead of text based, css and other styling
# [ ] Clean Up
# [.] Clean Up
# [ ] Bug Hunting

# - - - - - - - Imports - - - - - - -#
Expand All @@ -19,7 +19,7 @@
import sys

from Maxs_Modules.network import get_ip
from Maxs_Modules.renderer import Menu, Colour, clear, render_text, get_input, gui_init, gui_close
from Maxs_Modules.renderer import Menu, Colour, clear, render_text, get_input, init_gui, gui_close
from Maxs_Modules.debug import debug_message, init_debug, close_debug_session, error, handle_arg
from Maxs_Modules.game import get_saved_games, Game
from Maxs_Modules.files import UserData
Expand Down Expand Up @@ -360,15 +360,27 @@ def main() -> None:
render_text("Thank you for playing Quiz Game by Max Tyson (13 DGT)")


def init_main() -> None:
# Check if the desired folders exist and create them if they don't
if not os.path.exists("UserData"):
os.mkdir("UserData")

if not os.path.exists("UserData/Games"):
os.mkdir("UserData/Games")

if not os.path.exists("ProgramData"):
os.mkdir("ProgramData")


if __name__ == "__main__":
# Set up the program
init_debug()
gui_init()
init_main()
init_gui()

# Run the main program and catch the exit to stop the debug session
try:
main()
finally:
gui_close()
close_debug_session()

0 comments on commit 85c18be

Please sign in to comment.