I'm very new to pyside, qt and python.
I managed to setup a project with a basic window and a push button which closes the app.
My problem is, that somehow vscode won't show all properties available, even though the code runs with them fine.
Note how a bunch of other properties are suggested, except for the signal
clicked
. If I hover over clicked
, it tells me clicked: Any
Only during debugging, vscode tells me what clicked is:
Current setup:
pyside2
installedms-python.python
and ms-python.vscode-pylance
ui/MainWindow.ui
file and corresponding generated ui/MainWindow_ui.ui
file with pyside2-uic
You can generate the stubs manually by running
pyside6-genpyi all
PySide2 have the same tools, it's not just for PySide6.
EDIT: PySide2 didn't seems to have to same tooling, there's a new pyside2-stubs
since May 21, 2022, https://pypi.org/project/PySide2-stubs/
I use PDM to handle my project, with the last one I execute:
pdm run pyside6-genpyi all
And PyLance detect all my stubs:
If you got error with the Signal
, it's because Qt/PySide do some magic tricks and convert Signal
to SignalInstance
. My solution is to cast SignalInstance
to get to right hint.
from typing import cast
from PySide6.QtCore import Signal, SignalInstance
class ConnectionPanel(QtWidgets.QWidget):
connected = cast(SignalInstance, Signal())
disconnected = cast(SignalInstance, Signal())