Skip to content

Commit

Permalink
Standalone executable with splash
Browse files Browse the repository at this point in the history
  • Loading branch information
jaxankey committed May 13, 2022
1 parent 9d40f81 commit 711cd62
Show file tree
Hide file tree
Showing 5 changed files with 141 additions and 25 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@ uploads.7z
*.backup
egg_settings
.idea
*.exe
6 changes: 3 additions & 3 deletions uploader/compile.bat
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
call C:/Users/Jack/Miniconda3/Scripts/activate.bat C:/Users/Jack/Miniconda3
pyinstaller --onefile --distpath . uploader.pyw
call C:/Users/Jack/miniconda3/Scripts/activate.bat C:/Users/Jack/miniconda3
pyinstaller --noconfirm --onefile --windowed --splash "./splash/splash.png" --distpath "." "./uploader.py"
rem auto-py-to-exe
del uploader.spec
rmdir /s/q build
rmdir /s/q __pycache__
@pause
114 changes: 114 additions & 0 deletions uploader/splash/drawing.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added uploader/splash/splash.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
45 changes: 23 additions & 22 deletions uploader/uploader.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,16 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import glob, codecs, os, shutil, random, json, pyperclip, webbrowser, stat
import dateutil, subprocess, time, datetime
import spinmob.egg as egg

# Go button for URL

import glob, codecs, os, sys, shutil, random, json, pyperclip, webbrowser, stat
import dateutil, subprocess, time, datetime, importlib

# Change to the directory of this script
os.chdir(os.path.dirname(os.path.abspath(__file__)))
# Change to the directory of this script depending on whether this is a "compiled" version or run as script
if os.path.split(sys.executable)[-1] == 'uploader.exe': os.chdir(os.path.dirname(sys.executable)) # For executable version
else: os.chdir(os.path.dirname(os.path.abspath(__file__)))
print('WORKING DIRECTORY:')
print(os.getcwd())

import spinmob.egg as egg

# Function for loading a json at the specified path
def load_json(path):
"""
Expand Down Expand Up @@ -48,6 +47,12 @@ class Uploader:

def __init__(self, show=True, blocking=True):

# If we're in executable mode, close the splash screen
if '_PYIBoot_SPLASH' in os.environ and importlib.util.find_spec("pyi_splash"):
import pyi_splash # Warning should be ok; we don't get here outside of executable mode.
pyi_splash.update_text('UI Loaded ...')
pyi_splash.close()

# For troubleshooting.
# self.timer_exceptions = egg.gui.TimerExceptions()
# self.timer_exceptions.signal_new_exception.connect(self._signal_new_exception)
Expand All @@ -60,12 +65,6 @@ def __init__(self, show=True, blocking=True):
self._refilling_layouts = False
self._refilling_tracks = False
self._refilling_carsets = False

######################
# Set the working directory to that of the script
a = os.path.abspath(__file__)
d = os.path.dirname(a)
os.chdir(d)

# Make sure we have a carset folder
if not os.path.exists('carsets'): os.mkdir('carsets')
Expand All @@ -89,24 +88,25 @@ def __init__(self, show=True, blocking=True):
self.grid_top = self.window.add(egg.gui.GridLayout(False))
self.window.new_autorow()

self.grid_top.add(egg.gui.Label('Server Config:'))
self.combo_server = self.grid_top.add(egg.gui.ComboBox([],
tip='Select a server configuration.',
tip='Select a server profile.',
signal_changed=self._combo_server_changed)).set_width(200)

self.button_load_server = self.grid_top.add(egg.gui.Button('Load',
tip='Load the selected server configuration.',
tip='Load the selected server profile.',
signal_clicked=self._button_load_server_clicked)).hide()

self.button_save_server = self.grid_top.add(egg.gui.Button('Save',
tip='Save the current server configuration.',
tip='Save the current server profile.',
signal_clicked=self._button_save_server_clicked)).hide()

self.button_clone_server = self.grid_top.add(egg.gui.Button('Clone',
tip='Clones the selected server configuration.',
tip='Clones the selected server profile.',
signal_clicked=self._button_clone_server_clicked))

self.button_delete_server = self.grid_top.add(egg.gui.Button('Delete',
tip='Delete the selected server configuration (and saves it to servers/servername.json.backup in case you bootched).',
tip='Delete the selected server profile (and saves it to servers/servername.json.backup in case you bootched).',
signal_clicked=self._button_delete_server_clicked))

# Tabs
Expand Down Expand Up @@ -302,7 +302,7 @@ def __init__(self, show=True, blocking=True):
tip='Run the pre-command before everything starts.'))
self.checkbox_modify = self.grid2s.add(egg.gui.CheckBox(
'Config', signal_changed=self._any_server_setting_changed,
tip='Modify the server files with the above configuration.'))
tip='Modify the server files with the above profile.'))
self.checkbox_autoweek = self.grid2s.add(egg.gui.CheckBox(
'Auto-Week', signal_changed=self._any_server_setting_changed,
tip='Automatically increment the race time\'s week until the next available date.'))
Expand Down Expand Up @@ -429,10 +429,11 @@ def update_server_list(self):

# Clear existing
self.combo_server.clear()
self.combo_server.add_item('[New Server]')
self.combo_server.add_item('[Create Server Profile]')

if not os.path.exists('servers'): os.makedirs('servers')
paths = glob.glob(os.path.join('servers','*.json'))
paths.sort()
for path in paths: self.combo_server.add_item(os.path.splitext(os.path.split(path)[-1])[0])

# Now set it to the previous selection
Expand Down Expand Up @@ -491,7 +492,7 @@ def _button_clone_server_clicked(self, *a):
"""
if self.combo_server() == 0: return

name, ok = egg.pyqtgraph.QtGui.QInputDialog.getText(egg.pyqtgraph.QtGui.QWidget(), 'New Server', 'Name your new server:')
name, ok = egg.pyqtgraph.QtGui.QInputDialog.getText(egg.pyqtgraph.QtGui.QWidget(), 'New Server Profile', 'Name your new server profile:')
name = name.strip()

# If someone cancels out do nothing
Expand Down

0 comments on commit 711cd62

Please sign in to comment.