Python:在线程中运行QGLWidget绘制方法

2024-09-23 06:36:36 发布

您现在位置:Python中文网/ 问答频道 /正文

对于我的python程序,我有一个QT用户界面,它主要由一个QGLWidget组成,用来显示大量的点(~2000万)。程序现在运行非常不稳定,很难调整窗口大小或移动窗口。你知道吗

因此,我尝试在QGL小部件自己的线程中运行paintGL()方法,方法是:

from thread import start_new_thread

def paintGL(self):
    start_new_thread(paintGLThreading,())

def paintGLThreading(self):
    glClearColor(0.0, 0.0, 0.0, 1.0)
    <OpenGL paint code>

这会引发以下异常:

#Unhandled exception in thread started by <bound method GLWidget.paintGLThreading of <__main__.GLWidget object at 0x00000000043C5F78>>
Traceback (most recent call last):
  File "qtWin.py", line 54, in paintGLThreading
    glClearColor(0.0, 0.0, 0.0, 1.0)
  File "errorchecker.pyx", line 53, in OpenGL_accelerate.errorchecker._ErrorChecker.glCheckError (src\errorchecker.c:1218)
OpenGL.error.GLError: GLError(
        err = 1282,
        description = 'Der Vorgang ist ung\xfcltig.',
        baseOperation = glClearColor,
        cArguments = (0.0, 0.0, 0.0, 1.0)
)

有谁能告诉我怎么做对吗?你知道吗


Tags: 方法inself程序newdefthreadstart