From 160b1ee45f2625f23152b393ffd776ff1991e3dd Mon Sep 17 00:00:00 2001 From: Luke Campagnola Date: Wed, 21 Aug 2013 10:40:19 -0600 Subject: [PATCH] Python3 bugfixes --- pyqtgraph/exporters/Exporter.py | 2 +- pyqtgraph/exporters/ImageExporter.py | 2 +- pyqtgraph/flowchart/Flowchart.py | 7 ++++--- pyqtgraph/opengl/GLViewWidget.py | 2 +- 4 files changed, 7 insertions(+), 6 deletions(-) diff --git a/pyqtgraph/exporters/Exporter.py b/pyqtgraph/exporters/Exporter.py index 43a8c330..6371a3b9 100644 --- a/pyqtgraph/exporters/Exporter.py +++ b/pyqtgraph/exporters/Exporter.py @@ -119,7 +119,7 @@ class Exporter(object): else: childs = root.childItems() rootItem = [root] - childs.sort(lambda a,b: cmp(a.zValue(), b.zValue())) + childs.sort(key=lambda a: a.zValue()) while len(childs) > 0: ch = childs.pop(0) tree = self.getPaintItems(ch) diff --git a/pyqtgraph/exporters/ImageExporter.py b/pyqtgraph/exporters/ImageExporter.py index bdb8b9be..d1d78e7d 100644 --- a/pyqtgraph/exporters/ImageExporter.py +++ b/pyqtgraph/exporters/ImageExporter.py @@ -42,7 +42,7 @@ class ImageExporter(Exporter): def export(self, fileName=None, toBytes=False, copy=False): if fileName is None and not toBytes and not copy: - filter = ["*."+str(f) for f in QtGui.QImageWriter.supportedImageFormats()] + filter = ["*."+bytes(f).decode('UTF-8') for f in QtGui.QImageWriter.supportedImageFormats()] preferred = ['*.png', '*.tif', '*.jpg'] for p in preferred[::-1]: if p in filter: diff --git a/pyqtgraph/flowchart/Flowchart.py b/pyqtgraph/flowchart/Flowchart.py index be0d86e5..81f9e163 100644 --- a/pyqtgraph/flowchart/Flowchart.py +++ b/pyqtgraph/flowchart/Flowchart.py @@ -376,10 +376,10 @@ class Flowchart(Node): #tdeps[t] = lastNode if lastInd is not None: dels.append((lastInd+1, t)) - dels.sort(lambda a,b: cmp(b[0], a[0])) + #dels.sort(lambda a,b: cmp(b[0], a[0])) + dels.sort(key=lambda a: a[0], reverse=True) for i, t in dels: ops.insert(i, ('d', t)) - return ops @@ -491,7 +491,8 @@ class Flowchart(Node): self.clear() Node.restoreState(self, state) nodes = state['nodes'] - nodes.sort(lambda a, b: cmp(a['pos'][0], b['pos'][0])) + #nodes.sort(lambda a, b: cmp(a['pos'][0], b['pos'][0])) + nodes.sort(key=lambda a: a['pos'][0]) for n in nodes: if n['name'] in self._nodes: #self._nodes[n['name']].graphicsItem().moveBy(*n['pos']) diff --git a/pyqtgraph/opengl/GLViewWidget.py b/pyqtgraph/opengl/GLViewWidget.py index d8f70055..fe52065a 100644 --- a/pyqtgraph/opengl/GLViewWidget.py +++ b/pyqtgraph/opengl/GLViewWidget.py @@ -167,7 +167,7 @@ class GLViewWidget(QtOpenGL.QGLWidget): else: items = item.childItems() items.append(item) - items.sort(lambda a,b: cmp(a.depthValue(), b.depthValue())) + items.sort(key=lambda a: a.depthValue()) for i in items: if not i.visible(): continue