[PyQt] Request for __lshift__ support in QPolygonF for QPointF
Hans-Peter Jansen
hpj at urpla.net
Tue Oct 19 00:18:46 BST 2010
Hi Phil,
any deeper reason, why code like this is not supported:
import math
from PyQt4 import QtCore, QtGui
class StarRating(object):
# enum EditMode
Editable, ReadOnly = range(2)
PaintingScaleFactor = 20
def __init__(self, starCount, maxStarCount = 5):
self._starCount = starCount
self._maxStarCount = maxStarCount
self.starPolygon = QtGui.QPolygonF()
self.starPolygon << QtCore.QPointF(1.0, 0.5)
for i in range(5):
self.starPolygon << QtCore.QPointF(0.5 + 0.5 * math.cos(0.8 * i * 3.14),
0.5 + 0.5 * math.sin(0.8 * i * 3.14))
self.diamondPolygon = QtGui.QPolygonF()
self.diamondPolygon << QtCore.QPointF(0.4, 0.5) \
<< QtCore.QPointF(0.5, 0.4) \
<< QtCore.QPointF(0.6, 0.5) \
<< QtCore.QPointF(0.5, 0.6) \
<< QtCore.QPointF(0.4, 0.5)
This would bring us on a level playing field with C++.
Here's, what has to be done right now:
import math
from PyQt4 import QtCore, QtGui
class StarRating(object):
# enum EditMode
Editable, ReadOnly = range(2)
PaintingScaleFactor = 20
def __init__(self, starCount, maxStarCount = 5):
self._starCount = starCount
self._maxStarCount = maxStarCount
self.starPolygon = QtGui.QPolygonF([QtCore.QPointF(1.0, 0.5)])
for i in range(5):
self.starPolygon.append(
QtCore.QPointF(0.5 + 0.5 * math.cos(0.8 * i * 3.14),
0.5 + 0.5 * math.sin(0.8 * i * 3.14))
)
self.diamondPolygon = QtGui.QPolygonF([
QtCore.QPointF(0.4, 0.5), QtCore.QPointF(0.5, 0.4),
QtCore.QPointF(0.6, 0.5), QtCore.QPointF(0.5, 0.6),
QtCore.QPointF(0.4, 0.5)
])
Given, that this list has to be a list, while a tuple is not accepted,
doesn't improve the situation, either..
As a bonus, it is expectable, that the former code executes marginally
quicker.
Pete
More information about the PyQt
mailing list