bec_widgets.cli.client_utils ============================ .. py:module:: bec_widgets.cli.client_utils .. autoapi-nested-parse:: Client utilities for the BEC GUI. Attributes ---------- .. autoapisummary:: bec_widgets.cli.client_utils.GUIRegistryStateMessage bec_widgets.cli.client_utils.IGNORE_WIDGETS bec_widgets.cli.client_utils.RegistryState bec_widgets.cli.client_utils.config Classes ------- .. autoapisummary:: bec_widgets.cli.client_utils.AvailableWidgetsNamespace bec_widgets.cli.client_utils.BECGuiClient bec_widgets.cli.client_utils.RepeatTimer bec_widgets.cli.client_utils.WidgetNameSpace Functions --------- .. autoapisummary:: bec_widgets.cli.client_utils._filter_output bec_widgets.cli.client_utils._get_output bec_widgets.cli.client_utils._start_plot_process bec_widgets.cli.client_utils.wait_for_server Module Contents --------------- .. py:class:: AvailableWidgetsNamespace Namespace for available widgets in the BEC GUI. .. py:method:: __repr__() .. py:class:: BECGuiClient(**kwargs) Bases: :py:obj:`bec_widgets.cli.rpc.rpc_base.RPCBase` BEC GUI client class. Container for GUI applications within Python. .. py:method:: _add_widget(state: dict, parent: object) -> bec_widgets.cli.rpc.rpc_base.RPCReference | None Add a widget to the namespace :param state: The state of the widget from the _server_registry. :type state: dict :param parent: The parent object. :type parent: object .. py:method:: _check_if_server_is_alive() Checks if the process is alive .. py:method:: _do_raise_all() Bring GUI windows to the front. .. py:method:: _do_show_all() .. py:method:: _gui_post_startup() .. py:method:: _handle_registry_update(msg: dict[str, bec_lib.messages.GUIRegistryStateMessage], parent: BECGuiClient) -> None :staticmethod: .. py:method:: _hide_all() .. py:method:: _new_impl(*, name: str | None, geometry: tuple[int, int, int, int] | None, launch_script: str, startup_profile: str | Literal['restore', 'skip'] | None, **kwargs) .. py:method:: _raise_all() .. py:method:: _show_all() .. py:method:: _start(wait: bool = False) -> None .. py:method:: _start_server(wait: bool = False) -> None Start the GUI server, and execute callback when it is launched .. py:method:: _update_dynamic_namespace(server_registry: dict) Update the dynamic name space with the given server registry. Setting the server registry to an empty dictionary will remove all widgets from the namespace. :param server_registry: The server registry :type server_registry: dict .. py:method:: change_theme(theme: Literal['light', 'dark'] | None = None) -> None Apply a GUI theme or toggle between dark and light. :param theme: Theme to apply. If None, the current theme is fetched from the GUI and toggled. :type theme: Literal["light", "dark"] | None .. py:method:: close() Deprecated. Use kill_server() instead. .. py:method:: connect_to_gui_server(gui_id: str) -> None Connect to a GUI server .. py:method:: delete(name: str) -> None Delete a dock area and its parent window. :param name: The name of the dock area. :type name: str .. py:method:: delete_all() -> None Delete all dock areas. .. py:method:: hide() Hide the GUI window. .. py:method:: kill_server() -> None Kill the GUI server. .. py:method:: new(name: str | None = None, wait: bool = True, geometry: tuple[int, int, int, int] | None = None, launch_script: str = 'dock_area', startup_profile: str | Literal['restore', 'skip'] | None = None, **kwargs) -> bec_widgets.cli.client.AdvancedDockArea Create a new top-level dock area. :param name: The name of the dock area. Defaults to None. :type name: str, optional :param wait: Whether to wait for the server to start. Defaults to True. :type wait: bool, optional :param geometry: The geometry of the dock area (pos_x, pos_y, w, h). :type geometry: tuple[int, int, int, int] | None :param launch_script: The launch script to use. Defaults to "dock_area". :type launch_script: str :param startup_profile: Startup mode for the dock area: - None: start in transient empty workspace - "restore": restore last-used profile - "skip": skip profile initialization - "": load the named profile :type startup_profile: str | Literal["restore", "skip"] | None :param \*\*kwargs: Additional keyword arguments passed to the dock area. :returns: The new dock area. :rtype: client.AdvancedDockArea .. rubric:: Examples >>> gui.new() # Start with an empty unsaved workspace >>> gui.new(startup_profile="restore") # Restore last profile >>> gui.new(startup_profile="my_profile") # Load explicit profile .. py:method:: raise_window(wait: bool = True) -> None Bring GUI windows to the front. If the GUI server is not running, it will be started. :param wait: Whether to wait for the server to start. Defaults to True. :type wait: bool .. py:method:: show(wait=True) -> None Show the GUI window. If the GUI server is not running, it will be started. :param wait: Whether to wait for the server to start. Defaults to True. :type wait: bool .. py:method:: start(wait: bool = False) -> None Start the GUI server. .. py:attribute:: available_widgets .. py:property:: launcher :type: bec_widgets.cli.rpc.rpc_base.RPCBase The launcher object. .. py:property:: window_list :type: list List with dock areas in the GUI. .. py:property:: windows :type: dict Dictionary with dock areas in the GUI. .. py:class:: RepeatTimer(interval, function, args=None, kwargs=None) Bases: :py:obj:`threading.Timer` RepeatTimer class. This constructor should always be called with keyword arguments. Arguments are: *group* should be None; reserved for future extension when a ThreadGroup class is implemented. *target* is the callable object to be invoked by the run() method. Defaults to None, meaning nothing is called. *name* is the thread name. By default, a unique name is constructed of the form "Thread-N" where N is a small decimal number. *args* is a list or tuple of arguments for the target invocation. Defaults to (). *kwargs* is a dictionary of keyword arguments for the target invocation. Defaults to {}. If a subclass overrides the constructor, it must make sure to invoke the base class constructor (Thread.__init__()) before doing anything else to the thread. .. py:method:: run() Method representing the thread's activity. You may override this method in a subclass. The standard run() method invokes the callable object passed to the object's constructor as the target argument, if any, with sequential and keyword arguments taken from the args and kwargs arguments, respectively. .. py:class:: WidgetNameSpace .. py:method:: __repr__() .. py:function:: _filter_output(output: str) -> str Filter out the output from the process. .. py:function:: _get_output(process, logger) -> None .. py:function:: _start_plot_process(gui_id: str, gui_class_id: str, config: dict | str, gui_class: str = 'dock_area', logger=None) -> tuple[subprocess.Popen[str], threading.Thread | None] Start the plot in a new process. Logger must be a logger object with "debug" and "error" functions, or it can be left to "None" as default. None means output from the process will not be captured. .. py:function:: wait_for_server(client: BECGuiClient) Context manager to wait for the server to start. .. py:data:: GUIRegistryStateMessage .. py:data:: IGNORE_WIDGETS :value: ['LaunchWindow'] .. py:type:: RegistryState :canonical: dict[Literal['gui_id', 'name', 'widget_class', 'config', '__rpc__', 'container_proxy'], str | bool | dict] .. py:data:: config