I need to use pyside for my plugin's GUI.
And i run Pyside in another C4Dthread.
It is possible to successfully open the Pyside window in C4D.
but there seem to be some problems.
-1.When I opened the Pyside window in C4D, the main thread seemed to be blocked, which made it impossible for me to interact with the C4D scene.
-2.When I first open the Pyside window, it will open normally, but when I close it and open it again, it will flicker on the screen and open it again, that is to say; After closing the window for the first time, I need to click twice to open the window.
And this is my code example:
class Window(QMainWindow): def __init__(self): super(Window,self).__init__() self.InitUI() def InitUI(self): self.setWindowTitle("Pyside Test") self.resize(500,400) self.move(200,200) label = QLabel(self) label.setText("Pyside Test") label.setAlignment(Qt.AlignCenter) class UIThread(C4DThread): def Main(self): # Put in your code here # which you want to run # in another thread app = QApplication.instance() if not app: app = QApplication() win = Window() win.show() app.exec_() def main(): thread = UIThread() thread.Start(c4d.THREADMODE_ASYNC, c4d.THREADPRIORITY_NORMAL) # Do some other operations here thread.Wait(True) # Wait until the main method is done print "Pyside for c4d" thread.End(True)