Python 3 bugfixes
This commit is contained in:
commit
881589468d
@ -13,6 +13,7 @@ Contributors:
|
|||||||
Michael Cristopher Hogg
|
Michael Cristopher Hogg
|
||||||
Ulrich Leutner
|
Ulrich Leutner
|
||||||
Felix Schill
|
Felix Schill
|
||||||
|
Guillaume Poulin
|
||||||
|
|
||||||
Requirements:
|
Requirements:
|
||||||
PyQt 4.7+ or PySide
|
PyQt 4.7+ or PySide
|
||||||
|
@ -1,13 +1,12 @@
|
|||||||
import sys, os, subprocess, time
|
import sys, os, subprocess, time
|
||||||
|
|
||||||
try:
|
if __name__ == "__main__" and (__package__ is None or __package__==''):
|
||||||
from . import initExample
|
parent_dir = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
|
||||||
except ValueError:
|
sys.path.insert(0, parent_dir)
|
||||||
#__package__ = os.path.split(os.path.dirname(__file__))[-1]
|
import examples
|
||||||
sys.excepthook(*sys.exc_info())
|
__package__ = "examples"
|
||||||
print("examples/ can not be executed as a script; please run 'python -m examples' instead.")
|
|
||||||
sys.exit(1)
|
|
||||||
|
|
||||||
|
from . import initExample
|
||||||
from pyqtgraph.Qt import QtCore, QtGui, USE_PYSIDE
|
from pyqtgraph.Qt import QtCore, QtGui, USE_PYSIDE
|
||||||
|
|
||||||
if USE_PYSIDE:
|
if USE_PYSIDE:
|
||||||
|
@ -316,7 +316,7 @@ def dbg():
|
|||||||
Create a console window and begin watching for exceptions.
|
Create a console window and begin watching for exceptions.
|
||||||
"""
|
"""
|
||||||
mkQApp()
|
mkQApp()
|
||||||
import console
|
from . import console
|
||||||
c = console.ConsoleWidget()
|
c = console.ConsoleWidget()
|
||||||
c.catchAllExceptions()
|
c.catchAllExceptions()
|
||||||
c.show()
|
c.show()
|
||||||
|
@ -5,6 +5,7 @@ Copyright 2010 Luke Campagnola
|
|||||||
Distributed under MIT/X11 license. See license.txt for more infomation.
|
Distributed under MIT/X11 license. See license.txt for more infomation.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
from __future__ import division
|
||||||
from .python2_3 import asUnicode
|
from .python2_3 import asUnicode
|
||||||
Colors = {
|
Colors = {
|
||||||
'b': (0,0,255,255),
|
'b': (0,0,255,255),
|
||||||
@ -1863,9 +1864,9 @@ def isosurface(data, level):
|
|||||||
for i in [0,1,2]:
|
for i in [0,1,2]:
|
||||||
vim = vertexInds[:,3] == i
|
vim = vertexInds[:,3] == i
|
||||||
vi = vertexInds[vim, :3]
|
vi = vertexInds[vim, :3]
|
||||||
viFlat = (vi * (np.array(data.strides[:3]) / data.itemsize)[np.newaxis,:]).sum(axis=1)
|
viFlat = (vi * (np.array(data.strides[:3]) // data.itemsize)[np.newaxis,:]).sum(axis=1)
|
||||||
v1 = dataFlat[viFlat]
|
v1 = dataFlat[viFlat]
|
||||||
v2 = dataFlat[viFlat + data.strides[i]/data.itemsize]
|
v2 = dataFlat[viFlat + data.strides[i]//data.itemsize]
|
||||||
vertexes[vim,i] += (level-v1) / (v2-v1)
|
vertexes[vim,i] += (level-v1) / (v2-v1)
|
||||||
|
|
||||||
### compute the set of vertex indexes for each face.
|
### compute the set of vertex indexes for each face.
|
||||||
@ -1891,7 +1892,7 @@ def isosurface(data, level):
|
|||||||
#p = debug.Profiler('isosurface', disabled=False)
|
#p = debug.Profiler('isosurface', disabled=False)
|
||||||
|
|
||||||
## this helps speed up an indexing operation later on
|
## this helps speed up an indexing operation later on
|
||||||
cs = np.array(cutEdges.strides)/cutEdges.itemsize
|
cs = np.array(cutEdges.strides)//cutEdges.itemsize
|
||||||
cutEdges = cutEdges.flatten()
|
cutEdges = cutEdges.flatten()
|
||||||
|
|
||||||
## this, strangely, does not seem to help.
|
## this, strangely, does not seem to help.
|
||||||
|
@ -1014,6 +1014,10 @@ class ObjectProxy(object):
|
|||||||
def __rmod__(self, *args):
|
def __rmod__(self, *args):
|
||||||
return self._getSpecialAttr('__rmod__')(*args)
|
return self._getSpecialAttr('__rmod__')(*args)
|
||||||
|
|
||||||
|
def __hash__(self):
|
||||||
|
## Required for python3 since __eq__ is defined.
|
||||||
|
return id(self)
|
||||||
|
|
||||||
class DeferredObjectProxy(ObjectProxy):
|
class DeferredObjectProxy(ObjectProxy):
|
||||||
"""
|
"""
|
||||||
This class represents an attribute (or sub-attribute) of a proxied object.
|
This class represents an attribute (or sub-attribute) of a proxied object.
|
||||||
|
@ -185,7 +185,7 @@ class GLViewWidget(QtOpenGL.QGLWidget):
|
|||||||
ver = glGetString(GL_VERSION)
|
ver = glGetString(GL_VERSION)
|
||||||
if ver is not None:
|
if ver is not None:
|
||||||
ver = ver.split()[0]
|
ver = ver.split()[0]
|
||||||
if int(ver.split('.')[0]) < 2:
|
if int(ver.split(b'.')[0]) < 2:
|
||||||
print(msg + " The original exception is printed above; however, pyqtgraph requires OpenGL version 2.0 or greater for many of its 3D features and your OpenGL version is %s. Installing updated display drivers may resolve this issue." % ver)
|
print(msg + " The original exception is printed above; however, pyqtgraph requires OpenGL version 2.0 or greater for many of its 3D features and your OpenGL version is %s. Installing updated display drivers may resolve this issue." % ver)
|
||||||
else:
|
else:
|
||||||
print(msg)
|
print(msg)
|
||||||
|
@ -23,8 +23,8 @@ from pyqtgraph import importAll
|
|||||||
|
|
||||||
importAll('items', globals(), locals())
|
importAll('items', globals(), locals())
|
||||||
\
|
\
|
||||||
from MeshData import MeshData
|
from .MeshData import MeshData
|
||||||
## for backward compatibility:
|
## for backward compatibility:
|
||||||
#MeshData.MeshData = MeshData ## breaks autodoc.
|
#MeshData.MeshData = MeshData ## breaks autodoc.
|
||||||
|
|
||||||
import shaders
|
from . import shaders
|
||||||
|
@ -93,7 +93,7 @@ class GLLinePlotItem(GLGraphicsItem):
|
|||||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA)
|
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA)
|
||||||
glHint(GL_LINE_SMOOTH_HINT, GL_NICEST);
|
glHint(GL_LINE_SMOOTH_HINT, GL_NICEST);
|
||||||
|
|
||||||
glDrawArrays(GL_LINE_STRIP, 0, self.pos.size / self.pos.shape[-1])
|
glDrawArrays(GL_LINE_STRIP, 0, int(self.pos.size / self.pos.shape[-1]))
|
||||||
finally:
|
finally:
|
||||||
glDisableClientState(GL_COLOR_ARRAY)
|
glDisableClientState(GL_COLOR_ARRAY)
|
||||||
glDisableClientState(GL_VERTEX_ARRAY)
|
glDisableClientState(GL_VERTEX_ARRAY)
|
||||||
|
@ -146,7 +146,7 @@ class GLScatterPlotItem(GLGraphicsItem):
|
|||||||
else:
|
else:
|
||||||
glNormal3f(self.size, 0, 0) ## vertex shader uses norm.x to determine point size
|
glNormal3f(self.size, 0, 0) ## vertex shader uses norm.x to determine point size
|
||||||
#glPointSize(self.size)
|
#glPointSize(self.size)
|
||||||
glDrawArrays(GL_POINTS, 0, pos.size / pos.shape[-1])
|
glDrawArrays(GL_POINTS, 0, int(pos.size / pos.shape[-1]))
|
||||||
finally:
|
finally:
|
||||||
glDisableClientState(GL_NORMAL_ARRAY)
|
glDisableClientState(GL_NORMAL_ARRAY)
|
||||||
glDisableClientState(GL_VERTEX_ARRAY)
|
glDisableClientState(GL_VERTEX_ARRAY)
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
from OpenGL.GL import *
|
from OpenGL.GL import *
|
||||||
from GLMeshItem import GLMeshItem
|
from .GLMeshItem import GLMeshItem
|
||||||
from .. MeshData import MeshData
|
from .. MeshData import MeshData
|
||||||
from pyqtgraph.Qt import QtGui
|
from pyqtgraph.Qt import QtGui
|
||||||
import pyqtgraph as pg
|
import pyqtgraph as pg
|
||||||
|
@ -1,4 +1,7 @@
|
|||||||
import OpenGL
|
try:
|
||||||
|
from OpenGL import NullFunctionError
|
||||||
|
except ImportError:
|
||||||
|
from OpenGL.error import NullFunctionError
|
||||||
from OpenGL.GL import *
|
from OpenGL.GL import *
|
||||||
from OpenGL.GL import shaders
|
from OpenGL.GL import shaders
|
||||||
import re
|
import re
|
||||||
@ -219,17 +222,20 @@ class Shader(object):
|
|||||||
if self.compiled is None:
|
if self.compiled is None:
|
||||||
try:
|
try:
|
||||||
self.compiled = shaders.compileShader(self.code, self.shaderType)
|
self.compiled = shaders.compileShader(self.code, self.shaderType)
|
||||||
except OpenGL.NullFunctionError:
|
except NullFunctionError:
|
||||||
raise Exception("This OpenGL implementation does not support shader programs; many features on pyqtgraph will not work.")
|
raise Exception("This OpenGL implementation does not support shader programs; many OpenGL features in pyqtgraph will not work.")
|
||||||
except RuntimeError as exc:
|
except RuntimeError as exc:
|
||||||
## Format compile errors a bit more nicely
|
## Format compile errors a bit more nicely
|
||||||
if len(exc.args) == 3:
|
if len(exc.args) == 3:
|
||||||
err, code, typ = exc.args
|
err, code, typ = exc.args
|
||||||
if not err.startswith('Shader compile failure'):
|
if not err.startswith('Shader compile failure'):
|
||||||
raise
|
raise
|
||||||
code = code[0].split('\n')
|
code = code[0].decode('utf_8').split('\n')
|
||||||
err, c, msgs = err.partition(':')
|
err, c, msgs = err.partition(':')
|
||||||
err = err + '\n'
|
err = err + '\n'
|
||||||
|
msgs = re.sub('b\'','',msgs)
|
||||||
|
msgs = re.sub('\'$','',msgs)
|
||||||
|
msgs = re.sub('\\\\n','\n',msgs)
|
||||||
msgs = msgs.split('\n')
|
msgs = msgs.split('\n')
|
||||||
errNums = [()] * len(code)
|
errNums = [()] * len(code)
|
||||||
for i, msg in enumerate(msgs):
|
for i, msg in enumerate(msgs):
|
||||||
@ -357,7 +363,7 @@ class ShaderProgram(object):
|
|||||||
|
|
||||||
def uniform(self, name):
|
def uniform(self, name):
|
||||||
"""Return the location integer for a uniform variable in this program"""
|
"""Return the location integer for a uniform variable in this program"""
|
||||||
return glGetUniformLocation(self.program(), name)
|
return glGetUniformLocation(self.program(), name.encode('utf_8'))
|
||||||
|
|
||||||
#def uniformBlockInfo(self, blockName):
|
#def uniformBlockInfo(self, blockName):
|
||||||
#blockIndex = glGetUniformBlockIndex(self.program(), blockName)
|
#blockIndex = glGetUniformBlockIndex(self.program(), blockName)
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
from pyqtgraph.Qt import QtCore, QtGui
|
from pyqtgraph.Qt import QtCore, QtGui
|
||||||
try:
|
try:
|
||||||
from pyqtgraph.Qt import QtOpenGL
|
from pyqtgraph.Qt import QtOpenGL
|
||||||
|
from OpenGL.GL import *
|
||||||
HAVE_OPENGL = True
|
HAVE_OPENGL = True
|
||||||
except ImportError:
|
except ImportError:
|
||||||
HAVE_OPENGL = False
|
HAVE_OPENGL = False
|
||||||
@ -59,7 +60,6 @@ class RawImageWidget(QtGui.QWidget):
|
|||||||
p.end()
|
p.end()
|
||||||
|
|
||||||
if HAVE_OPENGL:
|
if HAVE_OPENGL:
|
||||||
from OpenGL.GL import *
|
|
||||||
class RawImageGLWidget(QtOpenGL.QGLWidget):
|
class RawImageGLWidget(QtOpenGL.QGLWidget):
|
||||||
"""
|
"""
|
||||||
Similar to RawImageWidget, but uses a GL widget to do all drawing.
|
Similar to RawImageWidget, but uses a GL widget to do all drawing.
|
||||||
|
@ -128,7 +128,7 @@ class Renderer(GraphicsView):
|
|||||||
self.shm = mmap.mmap(-1, mmap.PAGESIZE, self.shmtag) # use anonymous mmap on windows
|
self.shm = mmap.mmap(-1, mmap.PAGESIZE, self.shmtag) # use anonymous mmap on windows
|
||||||
else:
|
else:
|
||||||
self.shmFile = tempfile.NamedTemporaryFile(prefix='pyqtgraph_shmem_')
|
self.shmFile = tempfile.NamedTemporaryFile(prefix='pyqtgraph_shmem_')
|
||||||
self.shmFile.write('\x00' * mmap.PAGESIZE)
|
self.shmFile.write(b'\x00' * (mmap.PAGESIZE+1))
|
||||||
fd = self.shmFile.fileno()
|
fd = self.shmFile.fileno()
|
||||||
self.shm = mmap.mmap(fd, mmap.PAGESIZE, mmap.MAP_SHARED, mmap.PROT_WRITE)
|
self.shm = mmap.mmap(fd, mmap.PAGESIZE, mmap.MAP_SHARED, mmap.PROT_WRITE)
|
||||||
atexit.register(self.close)
|
atexit.register(self.close)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user