Skip to content

Instantly share code, notes, and snippets.

@esnosy
Last active January 8, 2023 20:31
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save esnosy/8d64cfff844f5cda0323d162523fceef to your computer and use it in GitHub Desktop.
Save esnosy/8d64cfff844f5cda0323d162523fceef to your computer and use it in GitHub Desktop.
How to use PyQt6 in Blender
# 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