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 paint(self, painter, option, widget): pen = QtImport.QPen(QtImport.Qt.SolidLine) pen.setWidth(1) pen.setColor(QtImport.Qt.black) painter.setPen(pen) if self.__num_drops: for drop_index in range(self.__num_drops): pos_x = self.scene().width() / 2 pos_y = float(drop_index + 1) / (self.__num_drops + 1) * \ self.scene().height() painter.drawLine(pos_x - 4, pos_y - 4, pos_x + 4, pos_y + 4) painter.drawLine(pos_x + 4, pos_y - 4, pos_x - 4, pos_y + 4) pen.setColor(QtImport.Qt.blue) pen.setWidth(2) # painter.drawLine(pos_x - 2, pos_y - 2, # pos_x + 2, pos_y + 2) # painter.drawLine(pos_x - 2, pos_y + 2, # pos_x + 2, pos_y - 2) # pen.setColor(QtCore.Qt.blue) painter.setPen(pen) if self.__navigation_posx and self.__navigation_posy: painter.drawLine(self.__navigation_posx - 8, self.__navigation_posy, self.__navigation_posx + 8, self.__navigation_posy) painter.drawLine(self.__navigation_posx, self.__navigation_posy - 8, self.__navigation_posx, self.__navigation_posy + 8)
def __init__(self): """ Defines grid view """ QtImport.QGraphicsItem.__init__(self) self.index = None self.rect = QtImport.QRectF(0, 0, 0, 0) self.setPos(10, 10) self.custom_pen = QtImport.QPen(QtImport.Qt.SolidLine) self.custom_pen.setWidth(1) self.custom_pen.setColor(QtImport.Qt.lightGray) self.custom_brush = QtImport.QBrush(QtImport.Qt.SolidPattern) brush_color = QtImport.Qt.white self.custom_brush.setColor(brush_color) self.results = None self.debug_hit_limit = 1e9 self.num_comp_x = None self.num_comp_y = None self.num_holes_x = None self.num_holes_y = None self.offset_hole = 2 self.offset_comp = 10 self.size_hole = None self.size_comp_x = None self.size_comp_y = None self.size_chip_x = None self.size_chip_y = None self.images_per_crystal = 1
def paint(self, painter, option, widget): pen = QtImport.QPen(QtImport.Qt.SolidLine) pen.setWidth(1) pen.setColor(QtImport.Qt.black) painter.setPen(pen) painter.drawLine(self.start_pos[0], self.start_pos[1], self.end_pos[0], self.end_pos[1]) painter.drawText( self.start_pos[0] + (self.end_pos[0] - self.start_pos[0]) / 2.0, self.start_pos[1] + (self.end_pos[1] - self.start_pos[1]) / 2.0 + self.index, str(self.index + 1), )
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))
def paintEvent(self, event): if not self.is_running(): painter = QtImport.QPainter(self) painter.setPen(QtImport.QPen(QtImport.Qt.black, 1)) painter.drawLine(0, 0, self.width(), self.height()) painter.drawLine(0, self.height(), self.width(), 0)
class QueueItem(QtImport.QTreeWidgetItem): """ Use this class to create a new type of item for the collect tree/queue. """ normal_brush = QtImport.QBrush(QtImport.Qt.black) highlighted_brush = QtImport.QBrush(QtImport.QColor(128, 128, 128)) normal_pen = QtImport.QPen(QtImport.Qt.black) highlighted_pen = QtImport.QPen(QtImport.QColor(128, 128, 128)) bg_brush = QtImport.QBrush(QtImport.QColor(0, 128, 0)) bg_normal_brush = QtImport.QBrush(QtImport.Qt.white) def __init__(self, *args, **kwargs): QtImport.QTreeWidgetItem.__init__(self, args[0]) self.deletable = kwargs.pop("deletable", False) self.pen = QueueItem.normal_pen self.brush = QueueItem.normal_brush self.bg_brush = QueueItem.bg_normal_brush self.previous_bg_brush = QueueItem.bg_normal_brush self._queue_entry = None self._data_model = None self._checkable = True self._previous_check_state = False self._font_is_bold = False self._star = False self._base_tool_tip = "" self.setText(1, "") def listView(self): # remove this return self.treeWidget() def setOn(self, state): """ Backward compatability, because QueueManager and other hwobj are using this method to change state """ if self._checkable: if state: check_state = QtImport.Qt.Checked else: check_state = QtImport.Qt.Unchecked self.setCheckState(0, check_state) else: self.setCheckState(0, QtImport.Qt.Unchecked) def setCheckState(self, column, check_state): """ sets check state for item and all children and parent if they exist """ self._previous_check_state = self.checkState(0) if isinstance(self, DataCollectionGroupQueueItem): self._checkable = False if self.childCount() == 0: self._checkable = True else: for index in range(self.childCount()): if self.child(index)._checkable: self._checkable = True break self.parent().setCheckState(column, check_state) if not self._checkable: check_state = QtImport.Qt.Unchecked QtImport.QTreeWidgetItem.setCheckState(self, column, check_state) if self._queue_entry: self._queue_entry.set_enabled(check_state > 0) if self._data_model: self._data_model.set_enabled(check_state > 0) def set_hidden(self, hidden): self.setHidden(hidden) for index in range(self.childCount()): self.child(index).setHidden(hidden) if self._queue_entry: self._queue_entry.set_enabled(not hidden) if self._data_model: self._data_model.set_enabled(not hidden) def update_check_state(self, new_state): """ in qt3 method was called stateChanged. """ if new_state != self._previous_check_state: self.setCheckState(0, self.checkState(0)) if isinstance(self, DataCollectionGroupQueueItem): for index in range(self.childCount()): self.child(index).setCheckState(0, self.checkState(0)) def move_item(self, after): self.parent().takeChild(self.parent().indexOfChild(self)) after.parent().insertChild(after.parent().indexOfChild(after) + 1, self) container_qe = self.get_queue_entry().get_container() after_qe = after.get_queue_entry() container_qe.swap(after_qe, self.get_queue_entry()) def setHighlighted(self, enable): """ Controls highlighting of the list item. :param enable: Highlighted True, or not highlighted False. :type enable: bool """ if enable: self.pen = QueueItem.highlighted_pen self.brush = QueueItem.highlighted_brush else: self.pen = QueueItem.normal_pen self.brush = QueueItem.normal_brush if self.treeWidget(): self.treeWidget().updateGeometry() def set_background_color(self, color_index): self.previous_bg_brush = self.background(0) color = Colors.QUEUE_ENTRY_COLORS[color_index] self.bg_brush = QtImport.QBrush(color) self.setBackground(0, self.bg_brush) self.setBackground(1, self.bg_brush) def restoreBackgroundColor(self): self.bg_brush = self.previous_bg_brush self.setBackground(0, self.bg_brush) self.setBackground(1, self.bg_brush) def setFontBold(self, state): self._font_is_bold = state def reset_style(self): self.set_background_color(0) self.setFontBold(False) self.setHighlighted(False) def lastItem(self): """ :returns: The last item of this child. :rtype: QueueItem """ if self.childCount() > 0: return self.child(self.childCount()) def set_checkable(self, state): self._checkable = state def set_queue_entry(self, queue_entry): self._queue_entry = queue_entry def get_previous_check_state(self): return self._previous_check_state def get_queue_entry(self): return self._queue_entry def get_model(self): return self._data_model def update_display_name(self): self.setText(0, self._data_model.get_display_name()) def update_tool_tip(self): pass def set_star(self, state): self._star = state def has_star(self): return self._star == True def get_all_grand_children(self): grand_children_list = [] for child_index in range(self.childCount()): for grand_child_index in range( self.child(child_index).childCount()): grand_children_list.append( self.child(child_index).child(grand_child_index)) return grand_children_list def set_strike_out(self, state): font = self.font(0) font.setStrikeOut(state) self.setFont(0, font)