kigadgets.util ============== .. py:module:: kigadgets.util .. autoapi-nested-parse:: Utilities for interacting with pcbnew in GUI and headless modes. "kireload" is useful for on-the-fly updates to action plugin scripts without manually refreshing plugins.:: from kigadgets import kireload class MyScript(pcbnew.ActionPlugin): def Run(self): import myscript.core kireload(myscript.core) # Any source changes in myscript/core.py have now been picked up myscript.core.run() "notify" and "query_user" decide whether to show a GUI dialog or print to console based on whether the code is running in GUI mode or headless mode. Attributes ---------- .. autoapisummary:: kigadgets.util.wx Functions --------- .. autoapisummary:: kigadgets.util.kireload kigadgets.util.notify kigadgets.util.query_user kigadgets.util.get_app_window kigadgets.util.in_GUI Module Contents --------------- .. py:data:: wx :value: None .. py:function:: kireload(mod: Any) -> None Reload a module. If it is not in sys.modules, it will be imported. .. py:function:: notify(*args: Any) -> Optional[int] Show text in a popup window while in the GUI. Arguments act the same as print(args). Not the best debugging tool ever created, but it is handy for debugging action plugins:: notify('Debug info:', 'x =', x) .. py:function:: query_user(prompt: Optional[str] = None, default: Union[str, int, float] = '') -> Optional[str] Simple GUI dialog asking for a single value. Returns what was entered by the user as a string:: retstr = query_user('Enter a drill width in mm', 0.5) if retstr is None: # User cancelled return else: drill = float(retstr) .. py:function:: get_app_window() -> Optional[Any] Get a parent for action plugin dialogs. Returns None if outside of GUI .. py:function:: in_GUI() -> bool