Application
- class pydm.PyDMApplication(ui_file=None, command_line_args=[], display_args=[], perfmon=False, hide_nav_bar=False, hide_menu_bar=False, hide_status_bar=False, read_only=False, macros=None, use_main_window=True, stylesheet_path=None, fullscreen=False, home_file=None)[source]
PyDMApplication handles loading PyDM display files, opening new windows, and most importantly, establishing and managing connections to channels via data plugins.
- Parameters:
ui_file (str, optional) – The file path to a PyDM display file (.ui, .py, or .adl).
command_line_args (list, optional) – A list of strings representing arguments supplied at the command line. All arguments in this list are handled by QApplication, in addition to PyDMApplication.
display_args (list, optional) – A list of command line arguments that should be forwarded to the Display class. This is only useful if a Related Display Button is opening up a .py file with extra arguments specified, and probably isn’t something you will ever need to use when writing code that instantiates PyDMApplication.
perfmon (bool, optional) – Whether or not to enable performance monitoring using ‘psutil’. When enabled, CPU load information on a per-thread basis is periodically printed to the terminal.
hide_nav_bar (bool, optional) – Whether or not to display the navigation bar (forward/back/home buttons) when the main window is first displayed.
hide_menu_bar (bool, optional) – Whether or not to display the menu bar (File, View) when the main window is first displayed.
hide_status_bar (bool, optional) – Whether or not to display the status bar (general messages and errors) when the main window is first displayed.
read_only (bool, optional) – Whether or not to launch PyDM in a read-only state.
macros (dict, optional) – A dictionary of macro variables to be forwarded to the display class being loaded.
use_main_window (bool, optional) – If ui_file is note given, this parameter controls whether or not to create a PyDMMainWindow in the initialization (Default is True).
fullscreen (bool, optional) – Whether or not to launch PyDM in a full screen mode.
homefile (str, optional) – The path to a PyDM file to return to whenever the home button is clicked in the navigation bar.
- add_connection(channel)[source]
Add a new connection to a channel.
- Parameters:
channel (PyDMChannel) –
- close_widget_connections(widget)[source]
Given a widget to start from, traverse the tree of child widgets, and try to close connections to any widgets with channels.
- Parameters:
widget (QWidget) –
- establish_widget_connections(widget)[source]
Given a widget to start from, traverse the tree of child widgets, and try to establish connections to any widgets with channels.
Display subclasses which dynamically create widgets may need to use this method.
- Parameters:
widget (QWidget) –
- get_CPU_usage()[source]
Prints total CPU usage (in percent), as well as per-thread usage, to the terminal.
- make_main_window(stylesheet_path=None, home_file=None, macros=None, command_line_args=None)[source]
Instantiate a new PyDMMainWindow, add it to the application’s list of windows. Typically, this function is only called as part of starting up a new process, because PyDMApplications only have one window per process.
- new_pydm_process(ui_file, macros=None, command_line_args=None)[source]
Spawn a new PyDM process and open the supplied file. Commands to open new windows in PyDM typically actually spawn an entirely new PyDM process. This keeps each window isolated, so that one window cannot slow down or crash another.
- Parameters:
ui_file (str) – The path to a .ui, .py, or .adl file to open in the new process.
macros (dict, optional) – A dictionary of macro variables to supply to the display file to be opened.
command_line_args (list, optional) – A list of command line arguments to pass to the new process. Typically, this argument is used by related display buttons to pass in extra arguments. It is probably rare that code you write needs to use this argument.
- plugin_for_channel(channel)[source]
Given a PyDMChannel object, determine the appropriate plugin to use.
- Parameters:
channel (PyDMChannel) –
- Return type:
- remove_connection(channel)[source]
Remove a connection to a channel.
- Parameters:
channel (PyDMChannel) –