def drawContents(self, painter): """draws splash screen""" bot_y = self.top_y + painter.fontMetrics().height() painter.font().setPixelSize(self.pxsize) painter.setPen(QtImport.QPen(QtImport.Qt.black)) painter.drawText( QtImport.QRect(QtImport.QPoint(self.top_x, self.top_y), QtImport.QPoint(self.right_x, bot_y)), QtImport.Qt.AlignLeft | QtImport.Qt.AlignTop, "Starting MXCuBE. Please wait...", ) painter.font().setPixelSize(self.pxsize * 2.5) painter.font().setPixelSize(self.pxsize) top_y = bot_y bot_y += 2 + painter.fontMetrics().height() painter.drawText( QtImport.QRect(QtImport.QPoint(self.top_x, top_y), QtImport.QPoint(self.right_x, bot_y)), QtImport.Qt.AlignLeft | QtImport.Qt.AlignBottom, self._message, ) self.progress_bar.setGeometry(10, self.top_y + 50, self.right_x, 20)
def paintEvent(self, e): painter = QtImport.QPainter(self) brush = QtImport.QBrush() brush.setColor(self._background_color) brush.setStyle(QtImport.Qt.SolidPattern) rect = QtImport.QRect(0, 0, painter.device().width(), painter.device().height()) painter.fillRect(rect, brush) # Get current state. parent = self.parent() vmin, vmax = parent.minimum(), parent.maximum() value = parent.value() # Define our canvas. d_height = painter.device().height() - (self._padding * 2) d_width = painter.device().width() - (self._padding * 2) # Draw the bars. step_size = d_height / self.n_steps bar_height = step_size * self._bar_solid_percent bar_spacer = step_size * (1 - self._bar_solid_percent) / 2 # Calculate the y-stop position, from the value in range. pc = (value - vmin) / (vmax - vmin) n_steps_to_draw = int(pc * self.n_steps) for n in range(n_steps_to_draw): brush.setColor(QtImport.QColor(self.steps[n])) rect = QtImport.QRect( self._padding, self._padding + d_height - ((1 + n) * step_size) + bar_spacer, d_width, bar_height) painter.fillRect(rect, brush) painter.end()
def paint(self, painter, option, widget): pen = QtImport.QPen(QtImport.Qt.SolidLine) pen.setWidth(1) pen.setColor(QtImport.Qt.black) painter.setPen(pen) if self.isSelected(): brush_color = QtImport.QColor(204, 255, 204) else: brush_color = QtImport.QColor(203, 212, 246) self.custom_brush.setColor(brush_color) painter.setBrush(self.custom_brush) painter.drawEllipse(-20, -20, 40, 40) paint_rect = QtImport.QRect(-20, -20, 40, 40) painter.drawText(paint_rect, QtImport.Qt.AlignCenter, str(self.index + 1))