def __init__(self): style = QCommonStyle() icons = [x for x in dir(QStyle) if x.startswith('SP_')] self.names = [] for name in icons: icon = style.standardIcon(getattr(QStyle, name)) setattr(self, name[3:], icon) self.names.append(name[3:])
def setup_settings(self): a = QCommonStyle() self.pushButton.setIcon(a.standardIcon(QStyle.SP_ArrowDown)) self.setWindowIcon(QIcon('book.png')) self.tabWidget.setCurrentIndex(0) self.tabWidget_2.setCurrentIndex(0) self.tabWidget_2.currentIndex() self.tableWidget.verticalHeader().setSectionResizeMode(QHeaderView.Fixed) self.progressBar.setVisible(False) self.progressBar_2.setVisible(False) self.export_button.setVisible(False) self.edit_button.setVisible(False) self.tableWidget.setColumnCount(6) self.table_lecturer.setColumnCount(2) self.table_groups.setColumnCount(2) self.table_subject.setColumnCount(2) self.table_classroom.setColumnCount(2) self.table_user.setColumnCount(3) self.tableWidget.setHorizontalHeaderLabels( ["Преподаватель", "Предмет", 'Пара', 'Примечание', "Аудитория", 'Редактировать']) self.table_lecturer.setHorizontalHeaderLabels(["Фамилия И.О.", '']) self.table_classroom.setHorizontalHeaderLabels(["Номер аудитории", '']) self.table_subject.setHorizontalHeaderLabels(["Предмет", '']) self.table_groups.setHorizontalHeaderLabels(["Группа", '']) self.table_user.setHorizontalHeaderLabels(["Логин", "Статус", ""]) self.tableWidget.horizontalHeader().setSectionResizeMode(QHeaderView.Stretch) self.table_lecturer.horizontalHeader().setSectionResizeMode(QHeaderView.Stretch) self.table_groups.horizontalHeader().setSectionResizeMode(QHeaderView.Stretch) self.table_subject.horizontalHeader().setSectionResizeMode(QHeaderView.Stretch) self.table_classroom.horizontalHeader().setSectionResizeMode(QHeaderView.Stretch) self.table_user.horizontalHeader().setSectionResizeMode(QHeaderView.Stretch) self.button_subject.clicked.connect(self.controller.push_button_add_subject) self.button_classroom.clicked.connect(self.controller.push_button_add_classroom) self.button_group.clicked.connect(self.controller.push_button_add_group) self.button_lecturer.clicked.connect(self.controller.push_button_add_lecturer) self.pushButton.clicked.connect(self.controller.push_button_save) self.update_button.clicked.connect(self.controller.push_button_update_table) self.pushButton_2.clicked.connect(self.controller.push_button_show_timetable) self.export_button.clicked.connect(self.controller.push_button_export) self.edit_button.clicked.connect(self.controller.push_button_edit) self.controller.push_button_update_table() self.dateEdit_2.setDate(datetime.datetime.now()) self.dateEdit.setDate(datetime.datetime.now()) self.edit_classroom.setValidator(QIntValidator()) self.exit = QAction(self) self.exit.setText("Сменить пользователя") self.exit.setObjectName('exit') self.menuBar.addAction(self.exit)
def setup(self): self.setupUi(self) loadAct = QAction('&Open', self) loadAct.setShortcut('Ctrl+O') loadAct.setStatusTip('Load data') loadAct.triggered.connect(lambda: self.onLoadClicked(0)) surfAct = QAction('&Open Surface', self) surfAct.setShortcut('Ctrl+S') surfAct.setStatusTip('Surf data') surfAct.triggered.connect(lambda: self.onLoadClicked(1)) exitAct = QAction('&Exit', self) exitAct.setShortcut('ALT+F4') exitAct.setStatusTip('Exit application') exitAct.triggered.connect(self.close) menubar = self.menuBar() fileMenu = menubar.addMenu('&File') fileMenu.addAction(loadAct) fileMenu.addAction(surfAct) fileMenu.addAction(exitAct) style = QCommonStyle() self.btnUpAzimuth.setIcon(style.standardIcon(QStyle.SP_ArrowUp)) self.btnDownAzimuth.setIcon(style.standardIcon(QStyle.SP_ArrowDown)) self.btnRightAzimuth.setIcon(style.standardIcon( QStyle.SP_ArrowForward)) self.btnLeftAzimuth.setIcon(style.standardIcon(QStyle.SP_ArrowBack)) self.btnUpElevation.setIcon(style.standardIcon(QStyle.SP_ArrowUp)) self.btnDownElevation.setIcon(style.standardIcon(QStyle.SP_ArrowDown)) self.btnRightElevation.setIcon( style.standardIcon(QStyle.SP_ArrowForward)) self.btnLeftElevation.setIcon(style.standardIcon(QStyle.SP_ArrowBack)) self.centralWidget().layout().setContentsMargins(0, 0, 0, 0) self.statusBar().hide() all_widgets = QApplication.instance().allWidgets() for widget in all_widgets: if type(widget) == QSplitter: widget.setStyleSheet("" " QSplitter::handle:horizontal { " " border: 1px outset darkgrey; " " } " " QSplitter::handle:vertical{ " " border: 1px outset darkgrey; " " } ") widget.setHandleWidth(2) # Default is 3
from PyQt5.QtWidgets import QStyleOptionButton, QStyleOptionViewItem from PyQt5.QtWidgets import QToolTip from cadnano.proxies.cnenum import PartType from cadnano.gui.palette import getBrushObj from cadnano.views.pathview import pathstyles as styles from cadnano.controllers.viewrootcontroller import ViewRootController from cadnano import util from .cnoutlineritem import NAME_COL, LOCKED_COL, VISIBLE_COL, COLOR_COL from .nucleicacidpartitem import OutlineNucleicAcidPartItem from .virtualhelixitem import OutlineVirtualHelixItem from .oligoitem import OutlineOligoItem _FONT = QFont(styles.THE_FONT, 12) _QCOMMONSTYLE = QCommonStyle() _LOCK_ICON = QPixmap(":/outlinericons/lock") _EYE_ICON = QPixmap(":/outlinericons/eye") class OutlinerTreeWidget(QTreeWidget): """ The there needs to always be a currentItem which defaults to row 0, column 0 at the root """ def __init__(self, parent=None): super(OutlinerTreeWidget, self).__init__(parent) self.setAttribute(Qt.WA_MacShowFocusRect, 0) # no mac focus halo self.to_be_activated = None def configure(self, window, document):
def drawControl(self, element, opt, painter, widget): """elif element == QStyle.CE_PushButtonBevel: # States is_down = (opt.state & STATE_SUNKEN) | (opt.state & STATE_ON) hovered = opt.state & STATE_ENABLED and opt.state & STATE_MOUSEOVER has_focus = opt.state & STATE_HASFOCUS rect = opt.rect btn_color = opt.palette.button().color() painter.setPen(btn_color) painter.setRenderHint(QPainter.Antialiasing) path = QPainterPath() path.addRoundedRect(QRectF(rect), 3, 3) if is_down: painter.setBrush(btn_color.darker(115)) elif has_focus: painter.setBrush(btn_color.lighter(130)) elif hovered: grad = QLinearGradient(rect.topLeft(), rect.bottomLeft()) grad.setColorAt(0.6, btn_color) grad.setColorAt(1, btn_color.lighter(120)) painter.setBrush(grad) else: painter.setBrush(btn_color) painter.drawPath(path)""" if element == QStyle.CE_ComboBoxLabel: cb = opt painter.save() edit_rect = self.subControlRect(QStyle.CC_ComboBox, cb, QStyle.SC_ComboBoxEditField, widget) # Draw icon if not cb.currentIcon.isNull(): if cb.state & STATE_ENABLED: mode = QIcon.Normal else: mode = QIcon.Disabled pixmap = cb.currentIcon.pixmap(cb.iconSize, mode) icon_rect = QRect(cb.rect) icon_rect.setWidth(cb.iconSize.width() + 4) # icon_rect = self.alignedRect(opt.direction, # Qt.AlignLeft | Qt.AlignVCenter, # icon_rect.size(), edit_rect) self.drawItemPixmap(painter, icon_rect, Qt.AlignCenter, pixmap) # Space between text if cb.direction == Qt.RightToLeft: edit_rect.translate(-4, -cb.iconSize.width(), 0) else: edit_rect.translate(cb.iconSize.width() + 4, 0) edit_rect.adjusted(0, 0, -13, 0) # Draw text elide_width = edit_rect.width() - opt.fontMetrics.width('**') text = opt.fontMetrics.elidedText(cb.currentText, Qt.ElideRight, elide_width) # FIXME: states painter.setPen(_COLORS['ComboBoxTextColor']) painter.drawText(edit_rect.adjusted(1, 0, -1, 0), Qt.AlignLeft | Qt.AlignVCenter, text) painter.restore() # TODO: tab with flat style # elif element == QStyle.CE_TabBarTabShape: # pass elif element == QStyle.CE_ToolBar: rect = opt.rect # print(widget.property("border"), widget) painter.fillRect(rect, _COLORS['ToolButtonColor']) if widget.property("border"): # painter.setPen(opt.palette.light().color().lighter(150)) painter.setPen(_COLORS["Border"]) painter.drawLine(rect.topLeft(), rect.topRight()) # painter.setPen(_COLORS['Border']) # painter.drawLine(opt.rect.topRight(), opt.rect.bottomRight()) elif element == QStyle.CE_MenuItem: painter.save() enabled = opt.state & STATE_ENABLED item = opt item.rect = opt.rect pal = opt.palette if enabled: color = _COLORS['MenuItemEnabled'] else: color = _COLORS['MenuItemDisabled'] item.palette = pal pal.setBrush(QPalette.Text, color) QProxyStyle.drawControl(self, element, opt, painter, widget) painter.restore() elif element == QStyle.CE_MenuBarEmptyArea: painter.fillRect(opt.rect, _COLORS['MenuBar']) # Draw border painter.save() # FIXME: color from theme painter.setPen(_COLORS['MenuBarBorderColor']) painter.drawLine(opt.rect.bottomLeft() + QPointF(.5, .5), opt.rect.bottomRight() + QPointF(.5, .5)) painter.restore() # elif element == QStyle.CE_PushButtonBevel: # painter.setPen(Qt.red) # painter.fillRect(opt.rect, QColor("red")) elif element == QStyle.CE_MenuBarItem: painter.save() act = opt.state & (STATE_SUNKEN | QStyle.State_Selected) dis = not (opt.state & STATE_ENABLED) painter.fillRect(opt.rect, _COLORS['MenuBar']) pal = opt.palette item = opt item.rect = opt.rect if dis: color = _COLORS['MenuBarItemDisabled'] else: color = _COLORS['MenuBarItemEnabled'] pal.setBrush(QPalette.ButtonText, color) item.palette = pal QCommonStyle.drawControl(self, element, item, painter, widget) if act: pal = opt.palette color = _COLORS['MenuBarHover'] painter.fillRect(opt.rect, color) align = (Qt.AlignCenter | Qt.TextShowMnemonic | Qt.TextDontClip | Qt.TextSingleLine) if not self.styleHint(QStyle.SH_UnderlineShortcut, opt, widget): align |= Qt.TextHideMnemonic # FIXME: if dis: co = _COLORS['IconDisabledColor'] else: co = _COLORS['MenuBarTextHover'] painter.setPen(Qt.NoPen) pal.setBrush(QPalette.Text, co) self.drawItemText(painter, item.rect, align, pal, not dis, opt.text, QPalette.Text) painter.restore() else: QProxyStyle.drawControl(self, element, opt, painter, widget)
def drawComplexControl(self, element, opt, painter, widget): if not self.__panel_widget(widget): QProxyStyle.drawComplexControl(self, element, opt, painter, widget) return if element == QStyle.CC_ComboBox: empty = False if not opt.currentText and opt.currentIcon.isNull(): empty = True tool_btn = opt if empty: tool_btn.state &= ~(STATE_ENABLED | STATE_SUNKEN) self.drawPrimitive(QStyle.PE_PanelButtonTool, tool_btn, painter, widget) # Draw border if widget.property("border"): # painter.setPen(opt.palette.light().color().lighter(150)) painter.setPen(_COLORS["MenuBarBorderColor"]) painter.drawLine(opt.rect.topRight() + QPoint(0, 6), opt.rect.bottomRight() - QPoint(0, 6)) if widget.property("border_bottom"): painter.setPen(_COLORS['Border']) painter.drawLine(opt.rect.bottomLeft(), opt.rect.bottomRight()) arrow_rect = QRect((opt.rect.left() + opt.rect.right()) / 2 + 6, opt.rect.center().y(), 9, 9) arrow_rect.moveRight(opt.rect.width() - 10) # FIXME: arrow_opt = QStyleOptionComboBox() arrow_opt.state = opt.state arrow_opt.rect = arrow_rect if empty: arrow_opt.state &= ~(STATE_ENABLED | STATE_SUNKEN) if self.styleHint(QStyle.SH_ComboBox_Popup, opt, widget): arrow_opt.rect.translate(0, -3) arrow_opt.palette.setColor(QPalette.ButtonText, _COLORS['IconBaseColor']) QCommonStyle.drawPrimitive(self, QStyle.PE_IndicatorArrowDown, arrow_opt, painter, widget) # elif element == QStyle.CC_ScrollBar: # pass elif element == QStyle.CC_ToolButton: # reverse = opt.direction == Qt.RightToLeft button = self.subControlRect(element, opt, QStyle.SC_ToolButton, widget) flags = opt.state if flags & QStyle.State_AutoRaise: if not flags & STATE_MOUSEOVER: flags &= ~QStyle.State_Raised tool = opt tool.palette = self.panel_palette(opt.palette) if opt.subControls & QStyle.SC_ToolButton: tool.rect = button tool.state = flags self.drawPrimitive(QStyle.PE_PanelButtonTool, tool, painter, widget) # Draw border if widget.property("border"): # painter.setPen(_COLORS["MenuBarBorderColor"]) # painter.drawLine(opt.rect.bottomLeft(), opt.rect.bottomRight()) pass label = opt label.palette.setColor(QPalette.ButtonText, label.palette.buttonText().color()) fw = self.pixelMetric(QStyle.PM_DefaultFrameWidth, opt, widget) label.rect = opt.rect.adjusted(fw, fw, -fw, -fw) self.drawControl(QStyle.CE_ToolButtonLabel, label, painter, widget) else: QProxyStyle.drawComplexControl(self, element, opt, painter, widget)
def setup(self): self.setupUi(self) self.setupMenu() style = QCommonStyle() self.btnUpAzimuth.setIcon(style.standardIcon(QStyle.SP_ArrowUp)) self.btnDownAzimuth.setIcon(style.standardIcon(QStyle.SP_ArrowDown)) self.btnRightAzimuth.setIcon(style.standardIcon( QStyle.SP_ArrowForward)) self.btnLeftAzimuth.setIcon(style.standardIcon(QStyle.SP_ArrowBack)) self.btnUpElevation.setIcon(style.standardIcon(QStyle.SP_ArrowUp)) self.btnDownElevation.setIcon(style.standardIcon(QStyle.SP_ArrowDown)) self.btnRightElevation.setIcon( style.standardIcon(QStyle.SP_ArrowForward)) self.btnLeftElevation.setIcon(style.standardIcon(QStyle.SP_ArrowBack)) self.centralWidget().layout().setContentsMargins(0, 0, 0, 0) self.statusBar().hide() all_widgets = QApplication.instance().allWidgets() for widget in all_widgets: if type(widget) == QSplitter: widget.setStyleSheet("" " QSplitter::handle:horizontal { " " border: 1px outset darkgrey " " } " " QSplitter::handle:vertical{ " " border: 1px outset darkgrey " " } ") widget.setHandleWidth(2) # Default is 3 # Setup 3D viewer self.viewer3D = Viewer3D(self) self.viewer3D.AddPlaneCornerButtons() self.layout3D.setContentsMargins(0, 0, 0, 0) self.layout3D.addWidget(self.viewer3D) # Setup CT viewer self.stackCT = Viewer2DStacked(self) self.layoutCT.setContentsMargins(0, 0, 0, 0) self.layoutCT.insertWidget(0, self.stackCT) # Setup US views self.viewUS = [] self.viewUS.append(Viewer2D(self, 1)) self.viewUS.append(Viewer2D(self, 2)) # Make all views share the same cursor object for i in range(2): self.viewUS[i].viewer.SetResliceCursor( self.viewUS[0].viewer.GetResliceCursor()) # Cursor representation (anti-alias) for i in range(len(self.viewUS)): for j in range(3): prop = self.viewUS[i].viewer.GetResliceCursorWidget( ).GetResliceCursorRepresentation().GetResliceCursorActor( ).GetCenterlineProperty(j) renderLinesAsTubes(prop) # Remove when stacked works for 2 images for i in range(len(self.viewUS)): # Set background for 2D views color = [0.0, 0.0, 0.0] color[self.viewUS[i].iDim] = 1 for j in range(3): color[j] = color[j] / 4.0 self.viewUS[i].viewer.GetRenderer().SetBackground(color) self.viewUS[i].interactor.Disable() self.establishCallbacks() # Show widgets but hide non-existing data for i in range(self.stackCT.count()): self.stackCT.widget(i).show() self.stackCT.widget(i).viewer.GetImageActor().SetVisibility(False) # Show widgets but hide non-existing data for i in range(len(self.viewUS)): self.viewUS[i].show() self.viewUS[i].viewer.GetImageActor().SetVisibility(False) self.layoutUS0.setContentsMargins(0, 0, 0, 0) self.layoutUS0.insertWidget(0, self.viewUS[0]) self.layoutUS1.setContentsMargins(0, 0, 0, 0) self.layoutUS1.insertWidget(0, self.viewUS[1])