Skip to content

Commit

Permalink
[002_private_public_attributes], issue #2, Added new private method i…
Browse files Browse the repository at this point in the history
…n main.py

New private method __set_working_dir() added to be used in TuPostProcessingGUI class constructor for setting working directory
  • Loading branch information
lelaus committed Aug 9, 2024
1 parent 82e40a0 commit 6891feb
Showing 1 changed file with 26 additions and 19 deletions.
45 changes: 26 additions & 19 deletions tugui/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,33 +23,26 @@ class TuPostProcessingGui(ThemedTk):
"""
Class that builds a GUI for enabling the user to plot the quantities produced by
a TU simulation. Two plot types are available:
. the ones showing the TU quantities as function of time, radial and axial position
. the ones coming from a statistical simulation.
Depending on the .pli file produced by the TU simulation, both types or the TuPlot
ones only are available.
This class is structured by providing:
. a menu bar
. an entry for setting the path to the .pli file to process
. the plot configuration area (left side) allowing users to setup what to plot
. the plot area (right side) where the selected curves are shown
. a status bar (bottom window) showing log messages.
- TuPlot: showing the TU quantities as function of time, radial and axial positions;
- TuStat: coming from a statistical simulation.
Depending on the .pli file produced by the TU simulation, both TuPlot and TuStat or the TuPlot
type only are available.
The GUI layout resulting from this class is structured in the following way:
- a menu bar (top);
- an entry for setting the path to the .pli file to process (top, just below the menu bar);
- the plot configuration area (left) allowing users to setup what to plot;
- the plot area (right) where the selected curves are shown;
- a status bar (bottom) showing log messages.
"""
def __init__(self, window_title: str, width: int, height: int) -> None:
"""
App windows's constructor
"""
# Call the superclass constructor
super().__init__()

# Initialize the main GUI window
self.__initialize_gui_window(window_title, width, height)

# Get the absolute path of the current file
abspath = os.path.abspath(__file__)
# Get the file directory path
dname = os.path.dirname(abspath)
# Change the working directory to the one where the current executed file is located
os.chdir(dname)
# 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"))
Expand Down Expand Up @@ -181,6 +174,20 @@ def __initialize_gui_window(self, title: str, width: int, height: int) -> None:
# Set the window geometry
self.geometry(f"{width}x{height}+{left}+{top}")


def __set_working_dir(self) -> None:
"""
Method that sets the working directory to the one where the tugui main
module is located.
"""
# Get the absolute path of the tugui main module
abspath = os.path.abspath(__file__)
# Get the path of the folder where the tugui main module is placed
dname = os.path.dirname(abspath)
# Set the working dir to the one just retrieved
os.chdir(dname)


def display_plot(self) -> None:
"""
Method that enables the display-only mode for plots provided by reading
Expand Down

0 comments on commit 6891feb

Please sign in to comment.