Details
-
Bug
-
Resolution: Out of scope
-
Not Evaluated
-
None
-
6.2.3
-
None
-
Arch Linux
Description
When I pretty print a widget before calling show, it appears. But when I don't pretty print, it does not appear.
Context: the icecream package is a pretty printer that does some magic that makes debugging python code a lot more pleasant.
#!/usr/bin/env python3 import sys from icecream import ic import PySide6 from PySide6 import QtWidgets from PySide6.QtCore import QLibraryInfo, qVersion from PySide6.QtWidgets import QMainWindow from PySide6.QtMultimediaWidgets import QVideoWidget class MyWindow(QMainWindow): def __init__(self): super().__init__() def showEvent(self, evt): # If you replace method2 with method1 or method0, no window will appear for QVideoWidget self.method2() def method0(self): self.setWindowTitle('Method 0') camera_view = QVideoWidget() camera_view.show() def method1(self): self.setWindowTitle('Method 1') camera_view = QVideoWidget() print(camera_view) camera_view.show() def method2(self): self.setWindowTitle('Method 2') camera_view = QVideoWidget() ic(camera_view) camera_view.show() def main(): print('Python {}.{}'.format(sys.version_info[0], sys.version_info[1])) print(QLibraryInfo.build()) print(f"PySide6 version: {PySide6.__version__}") app = QtWidgets.QApplication(sys.argv) window = MyWindow() window.show() sys.exit(app.exec()) if __name__ == "__main__": main()
Console output for method0:
Python 3.10 Qt 6.2.3 (x86_64-little_endian-lp64 shared (dynamic) release build; by GCC 11.1.0) PySide6 version: 6.2.3
Console output for method1:
Python 3.10 Qt 6.2.3 (x86_64-little_endian-lp64 shared (dynamic) release build; by GCC 11.1.0) PySide6 version: 6.2.3 <PySide6.QtMultimediaWidgets.QVideoWidget(0x55b245d66460) at 0x7f025254a280>
Console output for method2:
Python 3.10 Qt 6.2.3 (x86_64-little_endian-lp64 shared (dynamic) release build; by GCC 11.1.0) PySide6 version: 6.2.3 ic| camera_view: <PySide6.QtMultimediaWidgets.QVideoWidget(0x55d475d566b0) at 0x7fa364f46680>
Visually, method2 shows and additional window called test2.py (the name I gave to the script) that contains only a black rectangle. See screenshots on imgur.
There is a high chance that the problem is that icecream does some "black magic" and not that PySide6 did anything wrong. If this is the case, I would suggest adding some comment to the official documentation about being careful with pretty printers like icecream.