Skip to content

Commit

Permalink
[002_private_public_attributes], issue #2, OS platform
Browse files Browse the repository at this point in the history
Unified management of OS platform andhandled the display of the titlebar icon in the main window
  • Loading branch information
lelaus committed Aug 14, 2024
1 parent 6891feb commit 2251c1e
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 13 deletions.
7 changes: 3 additions & 4 deletions tugui/gui_configuration.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
from ast import List
from enum import Enum
import os
import platform
import re

from dataclasses import dataclass, field
from typing import Dict, Tuple, List
from typing_extensions import Self

from plot_settings import GroupType
from support import IDGA
from support import IDGA, OS_PLATFORM


@dataclass
Expand Down Expand Up @@ -192,13 +191,13 @@ def init_GuiPlotFieldsConfigurator_attrs() -> Self:
# ---------------------------------------------------------------------------
# Check the executables existence in the "bin" folder on the basis of the
# current OS
if platform.system() == "Linux":
if OS_PLATFORM == "Linux":
print("LINUX HERE!")
gui_config.tuplot_path = os.path.join(os.getcwd(), "../resources/exec" + os.sep + "tuplotgui")
gui_config.tustat_path = os.path.join(os.getcwd(), "../resources/exec" + os.sep + "tustatgui")
gui_config.__check_exe_file_existence(gui_config.tuplot_path, "tuplotgui")
gui_config.__check_exe_file_existence(gui_config.tustat_path, "tustatgui")
elif platform.system() == "Windows":
else:
print("WINDOWS HERE!")
gui_config.tuplot_path = os.path.join(os.getcwd(), "../resources/exec" + os.sep + "TuPlotGUI.exe")
gui_config.tustat_path = os.path.join(os.getcwd(), "../resources/exec" + os.sep + "TuStatGUI.exe")
Expand Down
23 changes: 15 additions & 8 deletions tugui/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,10 @@
from tu_interface import DatGenerator, InpHandler, MicReader, PliReader, StaReader, TuInp, MacReader
from gui_configuration import GuiPlotFieldsConfigurator
from gui_widgets import CustomNotebook, EntryVariable, StatusBar, provide_label_image
from support import IANT
from support import IANT, ERROR_LEVEL, OS_PLATFORM, SUPPORTED_OS_PLATFORMS
from shutil import copyfile
from typing import Union

ERROR_LEVEL: bool = 0

class TuPostProcessingGui(ThemedTk):
"""
Class that builds a GUI for enabling the user to plot the quantities produced by
Expand All @@ -35,6 +33,12 @@ class TuPostProcessingGui(ThemedTk):
- a status bar (bottom) showing log messages.
"""
def __init__(self, window_title: str, width: int, height: int) -> None:
# Check whether the OS platform is supported
if OS_PLATFORM not in SUPPORTED_OS_PLATFORMS:
error_message = f"The {OS_PLATFORM} OS is not yet supported!"
messagebox.showerror("Error", error_message)
raise RuntimeError(error_message)

# Call the superclass constructor
super().__init__()

Expand All @@ -44,11 +48,14 @@ def __init__(self, window_title: str, width: int, height: int) -> None:
# Set the working directory to the tugui main module location
self.__set_working_dir()

# Set the window icon
icon = PhotoImage(file=os.path.join(os.getcwd(), "../resources/icons/tuoutgui.gif"))
self.iconphoto(False, icon)
# self.tk.call('wm', 'iconphoto', self._w, icon)
# self.iconphoto(True, PhotoImage(file=os.path.join(os.getcwd(), "resources/tuoutgui.ico")))
# Set the titlebar icon
if OS_PLATFORM == "Linux":
self.iconphoto(False, PhotoImage(file = os.path.join(
os.getcwd(),"../resources/icons/tuoutgui.gif")))
else:
# FIXME: to add the file "tuoutgui.ico" in the right location
self.iconphoto(True, PhotoImage(file = os.path.join(
os.getcwd(), "../resources/icons/tuoutgui.ico")))

# Instantiate and configure the 'GuiPlotFieldsConfigurator' class in a try-except
try:
Expand Down
12 changes: 11 additions & 1 deletion tugui/support.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
import platform
from enum import Enum
from typing import Tuple
from typing import List, Tuple

# Flag defining the level of error management
ERROR_LEVEL: bool = 0

# List of supported OS
SUPPORTED_OS_PLATFORMS: List[str] = ["Linux", "Windows"]

# Variable storing the OS platform tugui is running on
OS_PLATFORM: str = platform.system()

class IDGA(Enum):
"""
Expand Down

0 comments on commit 2251c1e

Please sign in to comment.