Skip to content

Commit

Permalink
Splash screen added
Browse files Browse the repository at this point in the history
  • Loading branch information
aloytag committed Jun 24, 2024
1 parent 585be48 commit b80b792
Show file tree
Hide file tree
Showing 5 changed files with 330 additions and 4 deletions.
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ build-backend = "hatchling.build"

[project]
name = "electricalsim"
version = "0.0.8.7.dev9"
version = "0.0.8.7.dev10"
author = "Dr. Ing. Ariel S. Loyarte"
authors = [
{ name="Dr. Ing. Ariel S. Loyarte", email="[email protected]" },
Expand Down
21 changes: 20 additions & 1 deletion src/electricalsim/Electrical_Grid_Simulator.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
from lib.auxiliary import QVLine, QMainWindow2, return_config
from lib.calculations import Run_PF
from icons import rc_icons
from version import VERSION

if sys.version_info < (3, 10):
from importlib_metadata import entry_points
Expand Down Expand Up @@ -47,6 +48,22 @@ def main():

qdarktheme.enable_hi_dpi()
app = QtWidgets.QApplication(sys.argv)

icon_splash_svg = os.path.join(directory, 'icons', 'splash_screen.svg')
data_splash = None
with open(icon_splash_svg, 'r') as banner:
data_splash = banner.read().replace('&lt;VERSION&gt;', VERSION)
directory_splash2, _ = os.path.split(config_file_path)
icon_splash_svg2 = os.path.join(directory_splash2, 'egs_splash_screen.svg')
banner2 = open(icon_splash_svg2, 'w')
banner2.write(data_splash)
banner2.close()

pixmap_splash = QtGui.QPixmap(icon_splash_svg2)
splash = QtWidgets.QSplashScreen(pixmap_splash)
splash.show()
app.processEvents()

theme = config['general']['theme']
if theme in ('dark', 'light', 'auto'):
qdarktheme.setup_theme(theme, additional_qss="QToolTip { border: 0px; }")
Expand Down Expand Up @@ -503,7 +520,9 @@ def page_changed_on_toolbox(index):
# Show main window:
# main_window.show()
window.show()

# splash.finish(window)
if data_splash is not None:
QtCore.QTimer.singleShot(2000, splash, splash.close)
sys.exit(app.exec())


Expand Down
307 changes: 307 additions & 0 deletions src/electricalsim/icons/splash_screen.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 modified src/electricalsim/lib/__pycache__/auxiliary.cpython-311.pyc
Binary file not shown.
4 changes: 2 additions & 2 deletions src/electricalsim/lib/auxiliary.py
Original file line number Diff line number Diff line change
Expand Up @@ -592,14 +592,14 @@ def return_config(app_root_dir):
the config file exists, but it doesn't have the proper sections
and options.
Rertuns the confif file path as a second argument.
Rertuns the config file path as a second argument.
* app_root_dir: Root directory of the applications
Returns:
- First output: the configparser
- Second aoutput: the config file path
- Second output: the config file path
"""
config_dir = user_config_dir('electricalsim')
config_file_path = os.path.join(config_dir, 'config.ini')
Expand Down

0 comments on commit b80b792

Please sign in to comment.