def draw_picture(self, qp): size = QSizeF(self.pixel_size, self.pixel_size) pixel_width_range = list( range(self.scroll_width_shift, self.scroll_width_shift + self.width_pixel_count)) pixel_height_range = list( range(self.scroll_height_shift, self.scroll_height_shift + self.height_pixel_count)) for y in range(self.height_pixel_count): line_index = pixel_height_range[y] line = self.rgb_map[line_index] for x in range(self.width_pixel_count): pixel_index = pixel_width_range[x] pixel_color = line[pixel_index] if self.bit_depth == 16: color = QColor.fromRgba64(*pixel_color) else: color = QColor(*pixel_color) brush = QBrush(color) left_top = QPointF( x * self.pixel_size + self.width_central_shift, y * self.pixel_size + self.height_central_shift) rect = QRectF(left_top, size) qp.fillRect(rect, brush)
def __init__(self, width, height, selected=False): super().__init__() self.width = width self.height = height self.selected = selected self.selectPalette.setColor(QPalette.Background, QColor.fromRgb(216, 85, 106)) self.unselectPalette.setColor(QPalette.Background, QColor.fromRgba64(255, 255, 255, 0)) self.Setup()
def __init__(self, size, title='None', idx=0, selected=False): super().__init__() self.size = size self.title = title self.idx = idx self.selected = selected self.selectPalette.setColor(QPalette.Background, QColor.fromRgb(51,51,51)) self.unselectPalette.setColor(QPalette.Background, QColor.fromRgba64(255,255,255,0)) indicatorWidth = 5 self.indicator = Indicator(indicatorWidth, self.size, selected=self.selected) self.itemBox = ItemBox(self.size - indicatorWidth, self.size, self.title) layout = QHBoxLayout() layout.setSpacing(0) layout.setContentsMargins(0,0,0,0); layout.addWidget(self.indicator) layout.addWidget(self.itemBox) self.setLayout(layout) self.Setup()