Skip to content

Commit c4182d2

Browse files
committed
Fixed obvious errors(/poor implementations) in untested code parts
1 parent 47692fc commit c4182d2

9 files changed

Lines changed: 21 additions & 19 deletions

File tree

qwt/legend.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ def title(self):
130130
if isinstance(titleValue, QwtText):
131131
text = titleValue
132132
else:
133-
text.setText(titleValue)
133+
text = QwtText(titleValue)
134134
return text
135135

136136
def icon(self):

qwt/plot.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1504,8 +1504,8 @@ def insertLegend(self, legend, pos=None, ratio=-1):
15041504
elif lpos == self.BottomLegend:
15051505
previousInChain = self.footerLabel()
15061506

1507-
if previousInChain:
1508-
qwtSetTabOrder(previousInChain, legend, True)
1507+
if previousInChain is not None:
1508+
qwtSetTabOrder(previousInChain, legend, True)
15091509

15101510
self.updateLayout()
15111511

qwt/plot_curve.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -324,6 +324,7 @@ def setPen(self, *args):
324324
"""
325325
if len(args) == 3:
326326
color, width, style = args
327+
pen = QPen(color, width, style)
327328
elif len(args) == 1:
328329
pen, = args
329330
else:

qwt/plot_layout.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,7 @@ def setAlignCanvasToScales(self, *args):
253253
self.__data.alignCanvasToScales[axis] = on
254254
elif len(args) == 2:
255255
axisId, on = args
256-
if axis in QwtPlot.validAxes:
256+
if axisId in QwtPlot.validAxes:
257257
self.__data.alignCanvasToScales[axisId] = on
258258
else:
259259
raise TypeError("%s().setAlignCanvasToScales() takes 1 or 2 "\

qwt/plot_marker.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -475,7 +475,8 @@ def setLinePen(self, *args):
475475
width = args[1]
476476
if len(args) > 2:
477477
style = args[2]
478-
self.setLinePen(QPen(color, width, style))
478+
pen = QPen(color, width, style)
479+
self.setLinePen(pen)
479480
else:
480481
raise TypeError("%s().setLinePen() takes 1, 2 or 3 argument(s) "\
481482
"(%s given)" % (self.__class__.__name__, len(args)))

qwt/plot_renderer.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -281,14 +281,11 @@ def renderTo(self, plot, dest):
281281
raster graphics formats.
282282
283283
:param qwt.plot.QwtPlot plot: Plot widget
284-
:param str fileName: Path of the file, where the document will be stored
285-
:param str format: Format for the document
286-
:param QSizeF sizeMM: Size for the document in millimeters.
287-
:param int resolution: Resolution in dots per Inch (dpi)
284+
:param dest: QPaintDevice, QPrinter or QSvgGenerator instance
288285
289286
.. seealso::
290287
291-
:py:meth:`renderTo()`, :py:meth:`render()`,
288+
:py:meth:`render()`,
292289
:py:meth:`qwt.painter.QwtPainter.setRoundingAlignment()`
293290
"""
294291
if isinstance(dest, QPaintDevice):
@@ -308,6 +305,8 @@ def renderTo(self, plot, dest):
308305
rect.setRect(0, 0, dest.width(), dest.height())
309306
if rect.isEmpty():
310307
rect.setRect(0, 0, 800, 600)
308+
else:
309+
raise TypeError("Unsupported destination type %s" % type(dest))
311310
p = QPainter(dest)
312311
self.render(plot, p, rect)
313312

@@ -501,7 +500,7 @@ def renderScale(self, plot, painter, axisId, startDist, endDist,
501500
y = rect.bottom() - 1.0 - baseDist
502501
w = rect.width() - startDist - endDist
503502
align = QwtScaleDraw.TopScale
504-
elif axisId == QwtPlot.xBottom:
503+
else: # QwtPlot.xBottom
505504
x = rect.left() + startDist
506505
y = rect.top() + baseDist
507506
w = rect.width() - startDist - endDist

qwt/symbol.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,8 @@ def qwtDrawTriangleSymbols(painter, type, points, numPoint, symbol):
196196
triangle = [QPointF(x1, y2), QPointF(x, y1), QPointF(x2, y2)]
197197
elif type == QwtTriangle.Down:
198198
triangle = [QPointF(x1, y1), QPointF(x, y2), QPointF(x2, y1)]
199+
else:
200+
raise TypeError("Unknown triangle type %s" % type)
199201
painter.drawPolygon(QPolygonF(triangle))
200202

201203

qwt/tests/CurveDemo1.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -92,16 +92,14 @@ def paintEvent(self, event):
9292
def drawContents(self, painter):
9393
# draw curves
9494
r = self.contentsRect()
95-
dy = r.height()/len(self.curves)
95+
dy = int(r.height()/len(self.curves))
9696
r.setHeight(dy)
9797
for curve in self.curves:
9898
self.xMap.setPaintInterval(r.left(), r.right())
9999
self.yMap.setPaintInterval(r.top(), r.bottom())
100-
engine = painter.device().paintEngine()
101-
if engine is not None and engine.hasFeature(QPaintEngine.Antialiasing):
102-
painter.setRenderHint(
103-
QPainter.Antialiasing,
104-
curve.testRenderHint(QwtPlotItem.RenderAntialiased))
100+
painter.setRenderHint(
101+
QPainter.Antialiasing,
102+
curve.testRenderHint(QwtPlotItem.RenderAntialiased))
105103
curve.draw(painter, self.xMap, self.yMap, r)
106104
self.shiftDown(r, dy)
107105
# draw titles

qwt/tests/ImagePlotDemo.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,9 +98,10 @@ def draw(self, painter, xMap, yMap, rect):
9898
# copy
9999
image = self.image.copy(x1, y1, x2-x1, y2-y1)
100100
# zoom
101-
image = image.scaled(xMap.p2()-xMap.p1()+1, yMap.p1()-yMap.p2()+1)
101+
image = image.scaled(int(xMap.p2()-xMap.p1()+1),
102+
int(yMap.p1()-yMap.p2()+1))
102103
# draw
103-
painter.drawImage(xMap.p1(), yMap.p2(), image)
104+
painter.drawImage(int(xMap.p1()), int(yMap.p2()), image)
104105

105106

106107
class ImagePlot(QwtPlot):

0 commit comments

Comments
 (0)