def __init__(self, color='red'): pm = QtGui.QPixmap(16, 16) mask = QtGui.QBitmap(16, 16) black = QtCore.Qt.color1 white = QtCore.Qt.color0 clr = QtGui.QColor(color) pm.fill(clr) mask.fill(black) p1 = QtGui.QPainter(mask) p1.setPen(white) p1.drawLine(0, 6, 5, 6) p1.drawLine(0, 8, 5, 8) p1.drawLine(10, 6, 15, 6) p1.drawLine(10, 8, 15, 8) p1.drawLine(6, 0, 6, 5) p1.drawLine(8, 0, 8, 5) p1.drawLine(6, 10, 6, 15) p1.drawLine(8, 10, 8, 15) p1.end() pm.setAlphaChannel(mask) self.cur = QtGui.QCursor(pm, 8, 8)
def __init__(self, color='red'): self.png_data = "\x89PNG\r\n\x1a\n\x00\x00\x00\rIHDR\x00\x00\x00\x10\x00\x00\x00\x10\x08\x04\x00\x00\x00\xb5\xfa7\xea\x00\x00\x00\tpHYs\x00\x00\x0b\x89\x00\x00\x0b\x89\x017\xc9\xcb\xad\x00\x00\x00RIDAT(\xcf\x85\xd0\xe1\x0e\x00\x10\x08\x85\xd1\xef\xfd_\xfa\xfa\x81tW\x96&\x9b\x0e\x1aD\x0e\x84\xeaN\x14\x90t\xeb\x06^a\xaf'\xcf`O#9#\xe5V*\x88~\xae\xf5\x11\xc0\xdfWa`'\xca-$\xf2\x05\x7f2\x00d_=\x80J\xec\xab;\xd2\x80>\x16x0t\x9a\xaf\x1e\xaab\x00\x00\x00\x00IEND\xaeB`\x82" pm = QtGui.QPixmap(16, 16) mask = QtGui.QBitmap(16, 16) white = QtCore.Qt.color0 pm.loadFromData(self.png_data) mask.fill(white) pm.setAlphaChannel(mask) self.cur = QtGui.QCursor(pm, 8, 8)
def configure(self, width, height): self.logger.debug("window size reconfigured to %dx%d" % (width, height)) if hasattr(self, 'scene'): self.scene.setSceneRect(0, 0, width, height) # If we need to build a new pixmap do it here. We allocate one # twice as big as necessary to prevent having to reinstantiate it # all the time. On Qt this causes unpleasant flashing in the display. if (self.pixmap == None) or (self.pixmap.width() < width) or \ (self.pixmap.height() < height): pixmap = QtGui.QPixmap(width * 2, height * 2) #pixmap.fill(QColor("black")) self.pixmap = pixmap self.imgwin.set_pixmap(pixmap) self.set_window_size(width, height, redraw=True)
def resizeEvent(self, event): width, height = self.get_size() #print "making pixmap of %dx%d" % (width, height) pixmap = QtGui.QPixmap(width, height) #pixmap.fill(QtGui.QColor("black")) self.pixmap = pixmap # calculate intervals for range numbers nums = int(width // self._avg_pixels_per_range_num) spacing = 256 // nums self._interval = {} for i in xrange(nums): self._interval[i * spacing] = True self.logger.debug("nums=%d spacing=%d intervals=%s" % (nums, spacing, self._interval)) self.redraw()