|
36 | 36 |
|
37 | 37 | Commands: |
38 | 38 | examples sets up some examples for AeoLiS. |
| 39 | + gui starts the AeoLiS graphical user interface (GUI). |
39 | 40 | run runs model for simulating supply-limited aeolian sediment... |
40 | 41 | wind A wind time series generation tool for the aeolis model. |
41 | 42 |
|
|
45 | 46 |
|
46 | 47 | aeolis run <path_to_model_configuration_file.txt> |
47 | 48 |
|
| 49 | +> Start the GUI |
| 50 | +
|
| 51 | + aeolis gui |
| 52 | +
|
| 53 | + Or with a configuration file: |
| 54 | +
|
| 55 | + aeolis gui <path_to_model_configuration_file.txt> |
| 56 | +
|
48 | 57 | > To generate a wind time series |
49 | 58 |
|
50 | 59 | aeolis wind <path_to_wind.txt> |
@@ -208,6 +217,56 @@ def examples( |
208 | 217 | print("Done. Examples copied to: \n %s" % destination_path) |
209 | 218 |
|
210 | 219 |
|
| 220 | +@aeolis_app.command(name="gui", help="starts the AeoLiS graphical user interface (GUI).") |
| 221 | +def gui( |
| 222 | + config: Annotated[ |
| 223 | + Optional[str], |
| 224 | + typer.Argument( |
| 225 | + help="optional configuration file to load on startup" |
| 226 | + ), |
| 227 | + ] = None, |
| 228 | +): |
| 229 | + print_license() |
| 230 | + |
| 231 | + try: |
| 232 | + import tkinter as tk |
| 233 | + from aeolis.gui import AeolisGUI |
| 234 | + import aeolis.inout |
| 235 | + except ImportError as e: |
| 236 | + print(f"Error: Failed to import required GUI modules: {e}") |
| 237 | + print("Make sure tkinter is installed on your system.") |
| 238 | + sys.exit(1) |
| 239 | + |
| 240 | + # Load configuration if provided, otherwise use defaults |
| 241 | + if config and os.path.isfile(config): |
| 242 | + print(f"Loading configuration from: {config}") |
| 243 | + dic = aeolis.inout.read_configfile(config) |
| 244 | + configfile = config |
| 245 | + else: |
| 246 | + if config: |
| 247 | + print(f"Warning: Configuration file '{config}' not found. Using defaults.") |
| 248 | + print("Starting GUI with default configuration...") |
| 249 | + dic = {} |
| 250 | + configfile = "No file selected" |
| 251 | + |
| 252 | + # Create and start the GUI |
| 253 | + root = tk.Tk() |
| 254 | + |
| 255 | + # Set the configfile in the gui module |
| 256 | + import aeolis.gui as gui_module |
| 257 | + gui_module.configfile = configfile |
| 258 | + |
| 259 | + app = AeolisGUI(root, dic) |
| 260 | + |
| 261 | + # Make window appear on top at startup |
| 262 | + root.lift() |
| 263 | + root.attributes('-topmost', True) |
| 264 | + root.after_idle(root.attributes, '-topmost', False) |
| 265 | + root.focus_force() |
| 266 | + |
| 267 | + root.mainloop() |
| 268 | + |
| 269 | + |
211 | 270 | def print_license(): |
212 | 271 | print("AeoLiS Copyright (c) 2023 AeoLiS Development Team") |
213 | 272 | print("This program comes with ABSOLUTELY NO WARRANTY.") |
|
0 commit comments