How to add plugins to PySide6-designer?
-
@Tim-Tu said in How to add plugins to PySide6-designer?:
export PYSIDE_DESIGNER_PLUGINS="registertictactoe.py"
Per the docs https://doc-snapshots.qt.io/qtforpython-dev/tutorials/basictutorial/uifiles.html#custom-widgets-in-qt-designer
Registering this with Qt Designer is done by providing a registration script named
register*.py
and pointing the path-type environment variablePYSIDE_DESIGNER_PLUGINS
to the directory."to the directory". So try
export PYSIDE_DESIGNER_PLUGINS="."
or the full path. -
@JonB Thanks, that is my wrong.
But that maybe pyside's bug. I have checked the code, and I found it tried to get the path of pyside6 by
pyside_dir = Path(ref_mod.__file__).resolve().parent
. But actually it just returnsNone
.>>> import PySide6 >>> print(PySide6.__file__) None
I can solve this problem by creating
__init__.py
at/site-packages/PySide6/
. Should I report this problem? -
Unluckily, it still can't work.
❯ ll total 28K -rw-rw-r-- 1 tim tim 435 Feb 16 09:24 main.py -rw-rw-r-- 1 tim tim 446 Feb 16 09:24 registertictactoe.py -rw-rw-r-- 1 tim tim 119 Feb 16 09:24 taskmenuextension.pyproject -rw-rw-r-- 1 tim tim 4.9K Feb 16 09:24 tictactoe.py -rw-rw-r-- 1 tim tim 1.7K Feb 16 09:24 tictactoeplugin.py -rw-rw-r-- 1 tim tim 2.3K Feb 16 09:24 tictactoetaskmenu.py ❯ export PYSIDE_DESIGNER_PLUGINS="." ❯ pyside6-designer ERROR: ld.so: object 'libpython3.10.so' from LD_PRELOAD cannot be preloaded (cannot open shared object file): ignored.
-
@Tim-Tu
Dunno. Verifylocate libpython3.10.so
returns some matches (mine returns a dozen). Whether the error message means it cannot find it or it can but cannot load it (check output fromldd
) I do not know. Nor whetherignored
means it doesn't matter. I'm afraid I don't use this stuff. -
It still doesn't work on my code, here is my
register_widgets.py
:from PySide6.QtDesigner import QPyDesignerCustomWidgetCollection import os, sys from pathlib import Path import qfluentwidgets plugins_dir = os.path.dirname(qfluentwidgets.__file__) + '/plugins' sys.path.append(plugins_dir) print(plugins_dir) # plugins = [] def get_modules(py): # I don't know why, but they are nessary from PySide6.QtDesigner import QDesignerCustomWidgetInterface from inspect import getmembers modules = [] for name, obj in getmembers(py): # for name, obj in py.__dict__.items(): print(f"Loading {name}") if isinstance(obj, QDesignerCustomWidgetInterface): modules.append(obj) return modules for filename in os.listdir(plugins_dir): if filename.endswith('.py') and not filename.startswith('_'): # plugins += get_modules(__import__(file_path)) py = __import__(f"qfluentwidgets.plugins.{filename}".replace('.py', '')) for plug in get_modules(py): QPyDesignerCustomWidgetCollection.addCustomWidget(plug)
-
-
@Tim-Tu
Hey!
Sorry for replying to a closed topic, but would be so kind as to provide me with the code you used to register the plugin? I am also trying to get qfluentwidgets to work on my designer but having some problems, this would save a lot of trouble!
Thanks -
@Hassaan11 Hi, I'm sorry for my late reply. Should you still require the information, kindly visit my repository.