I'm looking to make some custom gui elements. Has anyone had success using pyside to use Qt to communicate with Blender?
There is at least a video showing someone compiled PyQt into Blender:
And a facebook post:
So it seems possible, at least with a modified Blender binary.
I have tried to get PySide working inside Blender, but i have had trouble getting PySide working correctly in python 3.4 standalone, so i gave up on PySide and moved to PyQt4.
First of all, i have it working on mac OSX 10.8 with blender 2.71. but i would say the process below would be almost the same on linux, but for windows may be easier, as you can download QT4 and PyQT4 binaries
i would suggest setting up a Virtual environment, as i previously had issues with different versions of python running on my machine, and it mucked up the install path, and version of python used to compile PyQt.
You need to make sure you install PyQT with the exact version of python that blender is using (2.71 uses 3.4, 2.70 uses 3.3)
I used the following versions.
- Python 3.4.1
- Qt 4.8.6
- pyQT 4.11.1
Once you have the correct python version, and virtualenv set up and working this is the code i use inside blender to open a PyQT window.
import sys sys.path.append('*venv directory* /py3.4/lib/python3.4/site-packages') import bpy from PyQt4 import QtGui, QtCore class ExampleQtWindow(QtGui.QDialog): def __init__(self): super(ExampleQtWindow, self).__init__() self.mainLayout = QtGui.QVBoxLayout(self) self.buttonLayout = QtGui.QHBoxLayout() self.CreateButton = QtGui.QPushButton("print info") QtCore.QObject.connect(self.CreateButton, QtCore.SIGNAL('clicked()'), self.testCommand) self.mainLayout.addWidget(self.CreateButton) self.setLayout(self.mainLayout) def testCommand(self): print(bpy.data.objects) # register class stuff class PyQtEvent(): _timer = None _window = None def execute(self): self._application = QtGui.QApplication.instance() if self._application is None: self._application = QtGui.QApplication(['']) self._eventLoop = QtCore.QEventLoop() self.window = ExampleQtWindow() self.window.show() print("running in background") new_window = PyQtEvent() new_window.execute()