def configure_window(self, width, height): self.logger.debug("window size reconfigured to %dx%d" % (width, height)) if hasattr(self, 'scene'): # By default, a QGraphicsView comes with a 1-pixel margin # You will get scrollbars unless you account for this # See http://stackoverflow.com/questions/3513788/qt-qgraphicsview-without-scrollbar width, height = width - 2, height - 2 self.scene.setSceneRect(1, 1, width - 2, height - 2) # tell renderer about our new size self.renderer.resize((width, height)) if isinstance(self.renderer.surface, QPixmap): # optimization when Qt is used as the renderer: # renderer surface is already a QPixmap self.pixmap = self.renderer.surface self.imgwin.set_pixmap(self.pixmap) else: # 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 is None) or (self.pixmap.width() < width) or (self.pixmap.height() < height)): pixmap = QPixmap(width * 2, height * 2) self.pixmap = pixmap self.imgwin.set_pixmap(pixmap) self.configure(width, height)
def resize(self, dims): """Resize our drawing area to encompass a space defined by the given dimensions. """ width, height = dims[:2] self.logger.debug("renderer reconfigured to %dx%d" % (width, height)) if self.surface_type == 'qpixmap': self.surface = QPixmap(width, height) else: self.surface = QImage(width, height, self.qimg_fmt)
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 = 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 = QPixmap(width, height) #pixmap.fill(QColor("black")) self.pixmap = pixmap # calculate intervals for range numbers nums = max(int(width // self._avg_pixels_per_range_num), 1) spacing = 256 // nums self._interval = {} for i in range(nums): self._interval[i * spacing] = True self.logger.debug("nums=%d spacing=%d intervals=%s" % (nums, spacing, self._interval)) self.redraw()
def resize(self, dims): """Resize our drawing area to encompass a space defined by the given dimensions. """ width, height = dims[:2] self.logger.debug("renderer reconfigured to %dx%d" % (width, height)) if self.surface_type == 'qpixmap': self.surface = QPixmap(width, height) else: self.surface = QImage(width, height, self.qimg_fmt) # fill surface with background color; # this reduces unwanted garbage in the resizing window painter = QPainter(self.surface) size = self.surface.size() sf_wd, sf_ht = size.width(), size.height() bg = self.viewer.img_bg bgclr = self._get_color(*bg) painter.fillRect(QtCore.QRect(0, 0, sf_wd, sf_ht), bgclr)
def configure_window(self, width, height): self.logger.debug("window size reconfigured to %dx%d" % (width, height)) if hasattr(self, 'scene'): # By default, a QGraphicsView comes with a 1-pixel margin # You will get scrollbars unless you account for this # See http://stackoverflow.com/questions/3513788/qt-qgraphicsview-without-scrollbar width, height = width - 2, height - 2 self.scene.setSceneRect(1, 1, width - 2, height - 2) # 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 is None) or (self.pixmap.width() < width) or \ (self.pixmap.height() < height): pixmap = QPixmap(width * 2, height * 2) #pixmap.fill(QColor("black")) self.pixmap = pixmap self.imgwin.set_pixmap(pixmap) self.configure(width, height)
def make_cursor(iconpath, x, y): image = QImage() image.load(iconpath) pm = QPixmap(image) return QCursor(pm, x, y)