PDielec.GUI.App
#
App Module
Module Contents#
Classes#
A class representing the main application window. |
Attributes#
- class PDielec.GUI.App.App(args, progressbar)[source]#
Bases:
PyQt5.QtWidgets.QMainWindow
A class representing the main application window.
This class initializes the main application window with various configurations based on command line arguments and environment variables. It includes functionalities to read scripts, handle command line inputs, set up multiprocessing or threading as needed, and manage application events.
Parameters#
- argslist
List of command line arguments passed to the application.
- progressbarQProgressBar
A progress bar object to display progress of operations in the application.
Attributes#
- program_exitbool
Flag indicating whether the application should exit after executing any script.
- debugbool
Debugging mode flag.
- scriptingbool
Flag indicating whether the application is running in scripting mode.
- scriptnamestr
The name of the script file to be executed if scripting mode is enabled.
- versionstr
The version of the PDielec package.
- titlestr
The window title.
- leftint
The x-coordinate of the window’s position.
- topint
The y-coordinate of the window’s position.
- widthint
The width of the window.
- heightint
The height of the window.
- notebookNoteBook
The notebook widget that acts as the central widget of the application.
Methods#
- print_usage()
Prints usage information for the command line interface.
- setMyWindowTitle(title)
Sets the window title to a formatted string including the version and the given title.
- readScript(scriptname, spreadsheet_name=’’)
Executes the commands from a script file and optionally sets the spreadsheet file name.
- closeEvent(event)
Handles the close event, ensuring that multiprocessing pools are properly closed.
- closeEvent(event)[source]#
Handle the close event of the application.
This method is called automatically when the close event is fired, typically when the user tries to close the application window. It ensures that the multiprocessing pool is properly terminated before the application shuts down.
Parameters#
event : QCloseEvent
Returns#
- None
The close event.
Notes#
This function must be a method of a class that inherits from a PyQt or PySide widget which has a closeEvent method to override, such as QMainWindow, QDialog, etc.
The self.notebook.pool is an instance of a multiprocessing pool, which needs to be closed and joined properly to ensure all processes are terminated cleanly before the application exits.
The super(App, self).closeEvent(event) call makes sure that any close event operations defined in the base class (from which the current class is derived) are also executed.
When the application is about to close, this method ensures clean termination of multiprocessing resources and performs any additional base class close event handling.
- print_usage()[source]#
Print usage information for the PDielec package’s graphical user interface.
This function prints the general usage information, available commands, and options for the graphical user interface to the PDielec package.
Parameters#
None
Returns#
None
Notes#
The usage information includes:
program: The name of the program which created the output file. Supported programs are ‘vasp’, ‘phonopy’, ‘gulp’, ‘castep’, ‘abinit’, and ‘qe’. The program is guessed from the filename if not specified.
filename: The name of the output file.
spreadsheet file: An optional name of a spreadsheet file (must end with .xlsx). If provided, both program and filename must be specified.
-scenario type: Changes the default scenario to “type”, which can be either “powder” or “crystal”.
-spreadsheet file: An alternative way to specify the spreadsheet file.
-program: An alternative way to specify the program.
-script file: Specifies that initial commands are read from a script file.
-nosplash: No splash screen is presented, which is useful for batch running.
-threading: Use threads instead of multiprocessing.
-cpus 0: Specify the number of processors or tasks; 0 uses all available.
-version: Prints the version of the code.
-exit: Exit the program after executing any script.
-help: Prints out help information.
-debug: Switches on debugging information.
- readScript(scriptname, spreadsheet_name='')[source]#
Read and execute a script, optionally changing the working directory to the script’s location and optionally setting a spreadsheet name.
Parameters#
- scriptnamestr
The file path of the script to be executed.
- spreadsheet_namestr, optional
The name of the spreadsheet, default is blank
Returns#
- None
The name of the spreadsheet to set in the notebook settings, by default an empty string which implies no spreadsheet name will be set.
Notes#
This function changes the current working directory to the directory of the script if its directory part is non-empty. It executes the script in the current Python environment using exec(). It also sets various notebook flags such as scripting and overwriting.
After executing the script, it potentially updates the spreadsheet name in the notebook’s mainTab settings if a non-empty spreadsheet_name is provided. It refreshes the notebook and processes pending Qt events with QCoreApplication.processEvents().
- setMyWindowTitle(title)[source]#
Set the window title with the provided title appended to the PDGui version.
Parameters#
title : str
Returns#
- None
The title to be appended after the PDGui version.
Notes#
This function modifies the window title attribute of the instance and then updates the actual window title to reflect this change. The version of the PDGui is prefixed to the given title.
- PDielec.GUI.App.app#
- PDielec.GUI.App.version#