kigadgets.util

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

wx

Functions

kireload(→ None)

Reload a module. If it is not in sys.modules, it will be imported.

notify(→ Optional[int])

Show text in a popup window while in the GUI.

query_user(→ Optional[str])

Simple GUI dialog asking for a single value.

get_app_window(→ Optional[Any])

Get a parent for action plugin dialogs.

in_GUI(→ bool)

Module Contents

kigadgets.util.wx = None
kigadgets.util.kireload(mod: Any) None

Reload a module. If it is not in sys.modules, it will be imported.

kigadgets.util.notify(*args: Any) int | None

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)
kigadgets.util.query_user(prompt: str | None = None, default: str | int | float = '') str | None

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)
kigadgets.util.get_app_window() Any | None

Get a parent for action plugin dialogs. Returns None if outside of GUI

kigadgets.util.in_GUI() bool