From 60dacf3f2c3973372d86692ca88c75ac97213193 Mon Sep 17 00:00:00 2001 From: Debanjum Singh Solanky Date: Thu, 18 Aug 2022 20:50:25 +0300 Subject: [PATCH] Show splash screen on app start. Only supported on Windows, Linux --- .github/workflows/release.yml | 2 +- Khoj.spec | 82 +++++++++++++++++++++++++---------- src/main.py | 12 +++++ 3 files changed, 72 insertions(+), 24 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 88ef1adf..a664f12e 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -35,7 +35,7 @@ jobs: shell: bash run: | if [ "$RUNNER_OS" == "Linux" ]; then - sudo apt install libegl1 libxcb-xinerama0 -y + sudo apt install libegl1 libxcb-xinerama0 python3-tk -y fi python -m pip install --upgrade pip pip install pyinstaller diff --git a/Khoj.spec b/Khoj.spec index e7c7c1f9..38219b3c 100644 --- a/Khoj.spec +++ b/Khoj.spec @@ -43,30 +43,66 @@ a.datas = [entry for entry in a.datas if not entry[0] in torch_lib_paths] pyz = PYZ(a.pure, a.zipped_data, cipher=block_cipher) -exe = EXE( - pyz, - a.scripts, - a.binaries, - a.zipfiles, - a.datas, - [], - name='Khoj', - debug=False, - bootloader_ignore_signals=False, - strip=False, - upx=True, - upx_exclude=[], - runtime_tmpdir=None, - console=False, - disable_windowed_traceback=False, - argv_emulation=False, - target_arch='x86_64', - codesign_identity=None, - entitlements_file=None, - icon='src/interface/web/assets/icons/favicon.icns', -) +if system() != 'Darwin': + # Add Splash screen to show on app launch + splash = Splash( + 'src/interface/web/assets/icons/favicon-144x144.png', + binaries=a.binaries, + datas=a.datas, + text_pos=(10, 50), + text_size=12, + text_color='blue', + minify_script=True, + always_on_top=True + ) -if system() == 'Darwin': + exe = EXE( + pyz, + a.scripts, + a.binaries, + a.zipfiles, + a.datas, + splash, + splash.binaries, + [], + name='Khoj', + debug=False, + bootloader_ignore_signals=False, + strip=False, + upx=True, + upx_exclude=[], + runtime_tmpdir=None, + console=False, + disable_windowed_traceback=False, + argv_emulation=False, + target_arch='x86_64', + codesign_identity=None, + entitlements_file=None, + icon='src/interface/web/assets/icons/favicon.icns', + ) +else: + exe = EXE( + pyz, + a.scripts, + a.binaries, + a.zipfiles, + a.datas, + [], + name='Khoj', + debug=False, + bootloader_ignore_signals=False, + strip=False, + upx=True, + upx_exclude=[], + runtime_tmpdir=None, + console=False, + disable_windowed_traceback=False, + argv_emulation=False, + target_arch='x86_64', + codesign_identity=None, + entitlements_file=None, + icon='src/interface/web/assets/icons/favicon.icns', + ) app = BUNDLE( exe, name='Khoj.app', diff --git a/src/main.py b/src/main.py index ef8f90ae..586676be 100644 --- a/src/main.py +++ b/src/main.py @@ -67,6 +67,18 @@ def run(): # Start Application server.start() gui.aboutToQuit.connect(server.terminate) + + # Close Splash Screen if still open + if system() != 'Darwin': + try: + import pyi_splash + # Update the text on the splash screen + pyi_splash.update_text("Khoj setup complete") + # Close Splash Screen + pyi_splash.close() + except: + pass + gui.exec()