Last active
January 8, 2023 20:31
-
-
Save esnosy/8d64cfff844f5cda0323d162523fceef to your computer and use it in GitHub Desktop.
How to use PyQt6 in Blender
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# tip: you can run Blender using an alternative Python environment to get access to PyQt6 | |
# for example I created a conda environment with PyQt6 installed, then executed blender with these args: | |
# ~/Downloads/blender-3.4.1-linux-x64/blender --env-system-python /home/iyad/miniconda3/envs/pyqt6/ | |
from PyQt6.QtWidgets import QApplication, QLabel | |
import bpy | |
# Process Qt event loop using a Blender timer | |
# note we do not use app.exec() at the end of the script, it will block Blender | |
def event_loop_timer(): | |
QApplication.processEvents() | |
return 0 | |
# Only create a QApplication if there are no other instances of QApplication | |
# otherwise it crashes as only one instance of QApplication is allowed by Qt | |
if QApplication.startingUp(): | |
app = QApplication([]) | |
bpy.app.timers.register(event_loop_timer) | |
label = QLabel("Qt inside Blender!") | |
label.show() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment