conservative conversion of some python2-isms to py3-compatible code
This commit is contained in:
+6
-4
@@ -20,7 +20,7 @@ class Canvas(QWidget):
|
||||
shapeMoved = pyqtSignal()
|
||||
drawingPolygon = pyqtSignal(bool)
|
||||
|
||||
CREATE, EDIT = range(2)
|
||||
CREATE, EDIT = list(range(2))
|
||||
|
||||
epsilon = 11.0
|
||||
|
||||
@@ -456,12 +456,14 @@ class Canvas(QWidget):
|
||||
return QPointF(min(max(0, x2), max(x3, x4)), y3)
|
||||
return QPointF(x, y)
|
||||
|
||||
def intersectingEdges(self, (x1, y1), (x2, y2), points):
|
||||
def intersectingEdges(self, x1y1, x2y2, points):
|
||||
"""For each edge formed by `points', yield the intersection
|
||||
with the line segment `(x1,y1) - (x2,y2)`, if it exists.
|
||||
Also return the distance of `(x2,y2)' to the middle of the
|
||||
edge along with its index, so that the one closest can be chosen."""
|
||||
for i in xrange(4):
|
||||
x1, y1 = x1y1
|
||||
x2, y2 = x2y2
|
||||
for i in range(4):
|
||||
x3, y3 = points[i]
|
||||
x4, y4 = points[(i+1) % 4]
|
||||
denom = (y4-y3) * (x2 - x1) - (x4 - x3) * (y2 - y1)
|
||||
@@ -506,7 +508,7 @@ class Canvas(QWidget):
|
||||
def keyPressEvent(self, ev):
|
||||
key = ev.key()
|
||||
if key == Qt.Key_Escape and self.current:
|
||||
print 'ESC press'
|
||||
print('ESC press')
|
||||
self.current = None
|
||||
self.drawingPolygon.emit(False)
|
||||
self.update()
|
||||
|
||||
Reference in New Issue
Block a user