Skip to content

gui#

gui#

dfastbe.gui.application #

Copyright (C) 2025 Stichting Deltares.

This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation version 2.1.

This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public License along with this library; if not, see http://www.gnu.org/licenses/.

contact: delft3d.support@deltares.nl Stichting Deltares P.O. Box 177 2600 MH Delft, The Netherlands

All indications and logos of, and references to, "Delft3D" and "Deltares" are registered trademarks of Stichting Deltares, and remain the property of Stichting Deltares. All rights reserved.

INFORMATION This file is part of D-FAST Bank Erosion: https://github.com/Deltares/D-FAST_Bank_Erosion

GUI #

Source code in src/dfastbe/gui/application.py
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
class GUI:

    def __init__(self):
        self.state = StateStore.initialize()

        self.app = QApplication()
        self.app.setStyle("fusion")
        StateManagement["application"] = self.app
        self.window, self.layout = self.create_window()
        StateManagement["window"] = self.window

        self.tabs = QTabWidget(self.window)
        StateManagement["tabs"] = self.tabs
        self.layout.addWidget(self.tabs)

        self.menu_Bar = self.create_menu_bar()
        self.button_bar = self.create_action_buttons()

    @staticmethod
    def create_window():
        win = QMainWindow()
        win.setWindowTitle("D-FAST Bank Erosion")
        win.setGeometry(200, 200, 600, 300)
        win.setWindowIcon(get_icon(f"{ICONS_DIR}/D-FASTBE.png"))

        # win.resize(1000, 800)

        central_widget = QWidget()
        layout = QBoxLayout(QBoxLayout.Direction.TopToBottom, central_widget)
        win.setCentralWidget(central_widget)
        return win, layout

    def create(self) -> None:
        """Construct the D-FAST Bank Erosion user interface."""
        self.general_tab = GeneralTab(self.tabs, self.window)
        self.general_tab.create()

        self.detection_tab = DetectionTab(self.tabs, self.window, self.app)
        self.detection_tab.create()

        self.erosion_tab = ErosionTab(self.tabs, self.window, self.app)
        self.erosion_tab.create()

        self.shipping_tab = ShippingTab(self.tabs)
        self.shipping_tab.create()

        self.bank_tab = BankTab(self.tabs)
        self.bank_tab.create()

    def create_menu_bar(self) -> MenuBar:
        """Add the menus to the menubar."""
        menu = MenuBar(window=self.window, app=self.app)
        menu.create()
        return menu

    def create_action_buttons(self) -> ButtonBar:
        button_bar = ButtonBar(window=self.window, app=self.app, layout=self.layout)
        button_bar.create()
        return button_bar

    def activate(self) -> None:
        """Activate the user interface and run the program."""
        self.window.show()
        sys.exit(self.app.exec())

    def close(self) -> None:
        """Close the dialog and program."""
        plt.close("all")
        self.window.close()
        self.app.closeAllWindows()
        self.app.quit()

activate() -> None #

Activate the user interface and run the program.

Source code in src/dfastbe/gui/application.py
153
154
155
156
def activate(self) -> None:
    """Activate the user interface and run the program."""
    self.window.show()
    sys.exit(self.app.exec())

close() -> None #

Close the dialog and program.

Source code in src/dfastbe/gui/application.py
158
159
160
161
162
163
def close(self) -> None:
    """Close the dialog and program."""
    plt.close("all")
    self.window.close()
    self.app.closeAllWindows()
    self.app.quit()

create() -> None #

Construct the D-FAST Bank Erosion user interface.

Source code in src/dfastbe/gui/application.py
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
def create(self) -> None:
    """Construct the D-FAST Bank Erosion user interface."""
    self.general_tab = GeneralTab(self.tabs, self.window)
    self.general_tab.create()

    self.detection_tab = DetectionTab(self.tabs, self.window, self.app)
    self.detection_tab.create()

    self.erosion_tab = ErosionTab(self.tabs, self.window, self.app)
    self.erosion_tab.create()

    self.shipping_tab = ShippingTab(self.tabs)
    self.shipping_tab.create()

    self.bank_tab = BankTab(self.tabs)
    self.bank_tab.create()

create_menu_bar() -> MenuBar #

Add the menus to the menubar.

Source code in src/dfastbe/gui/application.py
142
143
144
145
146
def create_menu_bar(self) -> MenuBar:
    """Add the menus to the menubar."""
    menu = MenuBar(window=self.window, app=self.app)
    menu.create()
    return menu

main(config: Optional[Path] = None) -> None #

Start the user interface using default settings or optional configuration.

Parameters:

Name Type Description Default
config

Optional[str] Optional name of configuration file.

required
Source code in src/dfastbe/gui/application.py
166
167
168
169
170
171
172
173
174
175
176
177
178
179
def main(config: Optional[Path] = None) -> None:
    """
    Start the user interface using default settings or optional configuration.

    Args:
        config : Optional[str]
            Optional name of configuration file.
    """
    gui = GUI()
    gui.create()
    if config is not None:
        ConfigurationLoader(config_path=config)

    gui.activate()