def __init__(self, title='Convert Symbol', size=(400, 300), parent=None): super(convertSymDialog, self).__init__(parent) self.layout = QtWidgets.QVBoxLayout() self.setLayout(self.layout) # edit widget self.layout.addWidget(QtWidgets.QLabel('Name')) self.text_name = QtWidgets.QLineEdit(parent) font = QtGui.QFont() font.setFamily('Lucida') font.setFixedPitch(True) font.setPointSize(12) self.text_name.setFont(font) self.layout.addWidget(self.text_name) self.layout.addWidget(QtWidgets.QLabel('Icon')) self.text_icon = QtWidgets.QWidget() self.icon_layout = QtWidgets.QHBoxLayout() self.icon_createBtn = QtWidgets.QPushButton('Create Icon') self.icon_selectIcon = QtWidgets.QPushButton('Select Icon') self.icon_selectIcon.clicked.connect(self.selectIcon) # self.icon_layout.addWidget(self.icon_createBtn) self.icon_layout.addWidget(self.icon_selectIcon) self.text_icon.setLayout(self.icon_layout) self.layout.addWidget(self.text_icon) # self.layout.addWidget(QtWidgets.QLabel('Parameters')) # self.text_parameters = QtWidgets.QWidget() # self.parameter_layout = QtWidgets.QHBoxLayout() # self.parameter_inp = QtWidgets.QCheckBox('input') # self.parameter_outp = QtWidgets.QCheckBox('output') # self.parameter_layout.addWidget(self.parameter_inp) # self.parameter_layout.addWidget(self.parameter_outp) # self.text_parameters.setLayout(self.parameter_layout) # self.layout.addWidget(self.text_parameters) # # myFont=QtGui.QFont() # myFont.setBold(True) # self.label.setFont(myFont) self.layout.addWidget(QtWidgets.QLabel('Properties')) self.text_properties = QtWidgets.QWidget() self.grid = QtWidgets.QGridLayout() self.values = dict() self.n = 0 self.key_field = QtWidgets.QLineEdit('key') self.addProperty = QtWidgets.QPushButton('Add property') self.addProperty.clicked.connect(self.addPropertyAction) self.grid.addWidget(self.key_field, 99, 0) self.grid.addWidget(self.addProperty, 99, 1) self.text_properties.setLayout(self.grid) self.layout.addWidget(self.text_properties) # self.layout.addWidget(QtWidgets.QLabel('Properties')) # self.text_properties = QtWidgets.QTextEdit(parent) # font = QtGui.QFont() # font.setFamily('Lucida') # font.setFixedPitch(True) # font.setPointSize(12) # self.text_properties.setFont(font) # self.layout.addWidget(self.text_properties) # Cancel and OK buttons buttons = QtWidgets.QDialogButtonBox.Ok | QtWidgets.QDialogButtonBox.Cancel self.bbox = QtWidgets.QDialogButtonBox(buttons) self.bbox.accepted.connect(self.accept) self.bbox.rejected.connect(self.reject) self.layout.addWidget(self.bbox) # set window title and window size self.setWindowTitle(title) self.resize(size[0], size[1]) self.filename = (0, 0)
def __init__(self, setup=FULL): """ Args: setup: What part of setup is the user entering into? """ super(ArmadaUninstaller, self).__init__() self.logger = logging.getLogger('menu.' + self.__class__.__name__) self.logger.info('Setup starting...') self.setup = setup self.setObjectName('armada_Installer') self.armada_root_path = definitions.ROOT_PATH # self.setWindowFlags(QtCore.Qt.FramelessWindowHint) self.setWindowTitle('Armada Pipeline Uninstaller') self.setWindowIcon(resource.icon('armada_logo', 'png')) self.setAttribute(QtCore.Qt.WA_DeleteOnClose) self.installEventFilter(self) self.setStyleSheet(resource.style_sheet('setup')) self.setFixedSize(1000, 500) self.sizeHint() # GUI ------------------------------ pixmap_banner = resource.pixmap(name='banner_setup', scope='help') self.lbl_banner = QtWidgets.QLabel() self.lbl_banner.setPixmap(pixmap_banner) self.cb_style_sheet = """ QCheckBox::indicator:checked:disabled {{ image: url({0}/resources/icon/checkbox_unchecked.svg); background: #29dff7; }} QCheckBox::indicator:unchecked:disabled{{ image: url({0}/resources/icon/checkbox_unchecked.svg); }} """.format(self.armada_root_path) self.cb_s0_install = QtWidgets.QCheckBox('Uninstall Armada Pipeline') self.cb_s0_install.setStyleSheet(self.cb_style_sheet) self.cb_s0_install.setEnabled(False) self.cb_s1_download = QtWidgets.QCheckBox('Uninstalling') self.cb_s1_download.setStyleSheet(self.cb_style_sheet) self.cb_s1_download.setEnabled(False) self.cb_s2_complete = QtWidgets.QCheckBox('Uninstallation Complete') self.cb_s2_complete.setStyleSheet(self.cb_style_sheet) self.cb_s2_complete.setEnabled(False) self.cb_delete_local_settings = QtWidgets.QCheckBox("Remove Armada's local settings?") self.lbl_title = QtWidgets.QLabel() # self.lbl_title.setSizePolicy(QtWidgets.QSizePolicy.Preferred, QtWidgets.QSizePolicy.MinimumExpanding) # self.lbl_title.setMinimumHeight(400) self.lbl_title.setStyleSheet(""" QLabel { font-size: 30px; font-family: Roboto; color: #FFFFFF; }""") self.lbl_full_path = QtWidgets.QLabel() self.lbl_full_path.setText("Full path:") self.lbl_full_path.setStyleSheet(resource.style_sheet('setup')) self.le_full_path = QtWidgets.QLabel() serifFont = QtGui.QFont("Roboto", 10, QtGui.QFont.StyleItalic) self.le_full_path.setFont(serifFont) # self.le_full_path.setText('{0}/Armada Pipeline/armada_pipeline_{1}_win10'.format(self.le_install_dir.text(), self.armada_version)) self.le_full_path.setWordWrap(True) self.btn_install_browse = QtWidgets.QPushButton("Browse") self.btn_install_browse.setMinimumWidth(100) self.task_description = QtWidgets.QLabel() self.progress_bar = QtWidgets.QProgressBar() self.progress_bar.setMinimum(0) self.progress_bar.setMaximum(100) self.progress_bar.setAlignment(QtCore.Qt.AlignCenter) self.btn_left = QtWidgets.QPushButton("Cancel") btn_left_retain = self.btn_left.sizePolicy() btn_left_retain.setRetainSizeWhenHidden(True) self.btn_left.setSizePolicy(btn_left_retain) self.btn_left.setStyleSheet(""" QPushButton{ background-color:#636363; height: 30px; } QPushButton:hover{ background: #369593; } QPushButton:hover:pressed{ background: #2e7a78; } QPushButton:pressed{ background: #2a615f; } QPushButton:disabled{ background: #3b3b3b; } """) self.btn_right = QtWidgets.QPushButton("Install") self.btn_right.setStyleSheet(""" QPushButton{ background-color:#636363; height: 30px; border-style: solid; border-width: 3px; border-color: #369593; } QPushButton:hover{ background: #369593; } QPushButton:hover:pressed{ background: #2e7a78; border-style: solid; border-width: 3px; border-color: #2e7a78; } QPushButton:pressed{ background: #2a615f; } QPushButton:disabled{ background: #3b3b3b; border-style: solid; border-width: 0px; border-color: #4abdbb; border-radius: 0px; } """) self.btn_right.setDisabled(True) self.lbl_description = QtWidgets.QTextBrowser() self.lbl_description.setReadOnly(True) self.lbl_description.setOpenExternalLinks(True) self.lbl_description.setStyleSheet(""" QTextEdit { background-color: #262626; color: #FFFFFF; font: 14px "Roboto-thin"; border: 0px; }""") # State machine ------------------ self.state_machine = QtCore.QStateMachine() self.s0_install = QtCore.QState() self.s1_download = QtCore.QState() self.s2_complete = QtCore.QState() # Entry point for setup # Transitions self.trans_s0_s1 = self.s0_install.addTransition(self.btn_right.clicked, self.s1_download) self.trans_s1_s2 = self.s1_download.addTransition(self.btn_right.clicked, self.s2_complete) # Add states self.state_machine.addState(self.s0_install) self.state_machine.addState(self.s1_download) self.state_machine.addState(self.s2_complete) self.state_machine.setInitialState(self.s0_install) # Connections self.s0_install.entered.connect(self.on_s0_install_entered) self.s1_download.entered.connect(self.on_uninstall_pressed) self.s1_download.entered.connect(self.on_s1_download_entered) self.s2_complete.entered.connect(self.on_s2_complete_entered) # Properties self.s0_install.assignProperty(self.btn_left, "text", "Cancel") self.s0_install.assignProperty(self.btn_right, "text", "Install") self.s1_download.assignProperty(self.btn_right, "text", "Next") self.s2_complete.assignProperty(self.btn_right, "text", "Set Sail!") self.state_machine.start() # Layout --------------------------- self.steps_layout = QtWidgets.QVBoxLayout() self.steps_layout.addWidget(self.lbl_banner, 0, QtCore.Qt.AlignCenter | QtCore.Qt.AlignTop) self.steps_layout.addWidget(self.cb_s0_install, 0, QtCore.Qt.AlignCenter) self.steps_layout.addWidget(self.cb_s1_download, 0, QtCore.Qt.AlignCenter) self.steps_layout.addWidget(self.cb_s2_complete, 0, QtCore.Qt.AlignCenter) self.steps_layout.setContentsMargins(30, 30, 30, 100) self.title_layout = QtWidgets.QHBoxLayout() self.title_layout.addWidget(self.lbl_title) # self.title_layout.setSizeConstraint(QtWidgets.QLayout.SetMinimumSize) self.title_layout.setAlignment(QtCore.Qt.AlignCenter) self.title_layout.setContentsMargins(20, 20, 20, 20) self.full_path_layout = QtWidgets.QHBoxLayout() self.full_path_layout.addWidget(self.cb_delete_local_settings, 0, QtCore.Qt.AlignLeft) self.full_path_layout.addWidget(self.le_full_path, 1) self.full_path_layout.setContentsMargins(0, 20, 0, 20) # Structure layout self.description_layout = QtWidgets.QHBoxLayout() self.description_layout.addWidget(self.lbl_description, 1, QtCore.Qt.AlignTop) self.description_layout.setContentsMargins(0, 0, 0, 0) self.button_layout = QtWidgets.QHBoxLayout() self.button_layout.addWidget(self.btn_left) self.button_layout.addWidget(self.btn_right) self.button_layout.setAlignment(QtCore.Qt.AlignBottom) self.button_layout.setContentsMargins(20, 20, 20, 20) self.info_layout = QtWidgets.QVBoxLayout() self.info_layout.addLayout(self.description_layout) self.info_layout.addLayout(self.full_path_layout) self.info_layout.setContentsMargins(30, 30, 30, 30) self.user_layout = QtWidgets.QVBoxLayout() self.user_layout.addLayout(self.title_layout) self.user_layout.addLayout(self.info_layout) self.user_layout.addWidget(self.task_description) self.user_layout.addWidget(self.progress_bar) self.user_layout.addLayout(self.button_layout, QtCore.Qt.AlignBottom) self.main_layout = QtWidgets.QHBoxLayout() self.main_layout.addLayout(self.steps_layout) self.main_layout.addLayout(self.user_layout) self.setLayout(self.main_layout) # Connections self.btn_install_browse.clicked.connect(self.on_browse_pressed) self.esc_pressed.connect(self.on_cancel_pressed) # Wait for user input self.exec_()
def paint(self, painter, option, index): _entity_data = index.data() _entity_handle = zfused_api.library.LibraryEntity( _entity_data.get("Id")) # _name = _entity_handle.name_code().replace("/","_") # _id = _entity_handle.id() painter.save() painter.setRenderHint(QtGui.QPainter.Antialiasing, True) _rect = option.rect _pen = QtGui.QPen(QtGui.QColor("#007acc"), 0.1) painter.setPen(_pen) painter.setBrush(QtGui.QColor(self._background_color)) painter.drawRoundedRect(_rect, 0, 0) # painter thumbnail _thumbnail_rect = QtCore.QRectF(_rect.x(), _rect.y(), _rect.width(), constants.Constants.THUMBNAIL_HEIGHT) _pixmap = _pixmap = cache.ThumbnailCache.get_pixmap( _entity_handle, self.parent().parent().update) if _pixmap: _pixmap_size = _pixmap.size() if _pixmap_size.width() and _pixmap_size.height(): _label_size = QtCore.QSize( _rect.width(), constants.Constants.THUMBNAIL_HEIGHT) scale = max( float(_label_size.width() / float(_pixmap_size.width())), float(_label_size.height()) / float(_pixmap_size.height())) _pixmap = _pixmap.scaled(_pixmap_size.width() * scale, _pixmap_size.height() * scale) # QtCore.Qt.KeepAspectRatio, # QtCore.Qt.SmoothTransformation ) _thumbnail_pixmap = _pixmap.copy( (_pixmap_size.width() * scale - _label_size.width()) / 2.0, (_pixmap_size.height() * scale - _label_size.height()) / 2.0, _label_size.width(), _label_size.height()) painter.drawPixmap(_rect.x(), _rect.y(), _thumbnail_pixmap) else: painter.setBrush( QtGui.QColor( color.LetterColor.color(_entity_handle.code().lower()[0]))) painter.setPen(QtGui.QColor(0, 0, 0, 0)) painter.drawRoundedRect(_thumbnail_rect, 0, 0) path = QtGui.QPainterPath() painter.setPen(QtGui.QPen(QtGui.QColor(0, 0, 0, 0), 1)) path.addRect(_thumbnail_rect) path.addRoundedRect(_thumbnail_rect, 0, 0) painter.setBrush(QtGui.QColor(self._background_color)) path.setFillRule(QtCore.Qt.OddEvenFill) painter.drawPath(path) # painter name _name_rect = QtCore.QRectF( _rect.x(), _rect.y() + constants.Constants.THUMBNAIL_HEIGHT, _rect.width(), constants.Constants.INFOMATION_HEIGHT * 2) painter.setBrush( QtGui.QColor(constants.Constants.NAME_BACKGROUND_COLOR)) painter.setPen(QtGui.QPen(QtGui.QColor(0, 0, 0, 0), 1)) painter.drawRoundedRect(_name_rect, 0, 0) _font = QtGui.QFont("Microsoft YaHei UI", 12) _font.setPixelSize(15) _font.setBold(True) painter.setFont(_font) painter.setPen( QtGui.QPen(QtGui.QColor(constants.Constants.NAME_COLOR), 1)) _name = _entity_handle.name().replace("/", " - ") _name_rect = QtCore.QRectF( _rect.x() + self._spacing, _rect.y() + constants.Constants.THUMBNAIL_HEIGHT, _rect.width(), constants.Constants.INFOMATION_HEIGHT) painter.drawText(_name_rect, QtCore.Qt.AlignLeft | QtCore.Qt.AlignBottom, _name) _code_rect = QtCore.QRectF( _rect.x() + self._spacing, _rect.y() + constants.Constants.THUMBNAIL_HEIGHT + constants.Constants.INFOMATION_HEIGHT, _rect.width(), constants.Constants.INFOMATION_HEIGHT) _font.setBold(False) _font.setPixelSize(12) painter.setFont(_font) painter.setPen( QtGui.QPen(QtGui.QColor(constants.Constants.CODE_COLOR), 1)) _code = _entity_handle.code() painter.drawText(_code_rect, QtCore.Qt.AlignLeft | QtCore.Qt.AlignTop, _code) # 绘制实体类型 self._font.setPixelSize(12) self._font.setBold(True) _fm = QtGui.QFontMetrics(self._font) painter.setFont(self._font) _category_id = _entity_handle.data().get("CategoryId") if _category_id: _category_handle = zfused_api.category.Category(_category_id) _category_code = _category_handle.name() painter.setBrush(QtGui.QColor(_category_handle.color())) else: _category_code = u"其他" painter.setBrush(QtGui.QColor(0, 122, 204, 200)) _category_rect = QtCore.QRectF( _rect.x() + self._spacing, _rect.y() + self._spacing, _fm.width(_category_code) + self._spacing * 2, 20) painter.setPen(QtGui.QPen(QtGui.QColor(0, 0, 0, 0), 1)) painter.drawRoundedRect(_category_rect, 2, 2) painter.setPen(QtGui.QPen(QtGui.QColor("#FFFFFF"), 1)) painter.drawText(_category_rect, QtCore.Qt.AlignCenter, _category_code) # 绘制版本数量 _count = _entity_handle.data().get("Count") _count_rect = QtCore.QRectF(_rect.x(), _rect.y() + _rect.height() - 30, _rect.width(), 30) painter.setPen(QtGui.QColor(0, 0, 0, 0)) painter.setBrush(QtGui.QColor("#353535")) painter.drawRoundedRect(_count_rect, 0, 0) painter.drawPixmap(_count_rect.x() + self._spacing, _count_rect.y() + 5, self._file_pixmap) painter.setPen(QtGui.QPen(QtGui.QColor("#DDDDDD"), 1)) painter.drawText(_count_rect.x() + self._spacing * 2 + 20, _count_rect.y(), 50, 30, QtCore.Qt.AlignLeft | QtCore.Qt.AlignVCenter, u"{} 文件".format(_count)) # _tag_ids = _entity_handle.tag_ids() # if _tag_ids: # _tag_x = _rect.x() + constants.Constants.TAG_SPACING # for _tag_id in _tag_ids: # _tag_handle = zfused_api.tag.Tag(_tag_id) # _tag_name_code = _tag_handle.name_code() # _tag_color = _tag_handle.color() # _width = _fm.width(_tag_name_code) + constants.Constants.TAG_SPACING # _tag_rect = QtCore.QRectF( _tag_x, # _code_rect.y() + _code_rect.height() + constants.Constants.TAG_SPACING, # _width, # constants.Constants.TAG_HEIGHT - constants.Constants.TAG_SPACING*2 ) # if _tag_x + _width - _rect.x() > _rect.width(): # break # painter.setBrush(QtGui.QColor(_tag_color)) # painter.setPen(QtGui.QPen(QtGui.QColor(0,0,0,0), 1)) # painter.drawRoundedRect(_tag_rect, 2, 2) # painter.setPen(QtGui.QColor("#ebedef")) # painter.drawText(_tag_rect, QtCore.Qt.AlignCenter, _tag_name_code) # _tag_x += (_fm.width(_tag_name_code) + constants.Constants.TAG_SPACING*2) if option.state & QtWidgets.QStyle.State_MouseOver: painter.setPen(QtGui.QColor(0, 122, 204, 0)) painter.setBrush(QtGui.QColor(0, 122, 204, 30)) painter.drawRect(_rect) elif option.state & QtWidgets.QStyle.State_Selected: painter.setPen(QtGui.QColor(0, 122, 204, 0)) painter.setBrush(QtGui.QColor(0, 122, 204, 50)) painter.drawRect(_rect) else: painter.setPen(QtGui.QColor(255, 255, 255, 0)) painter.setBrush(QtGui.QColor(200, 200, 200, 0)) painter.drawRect(_rect) painter.restore()
def setBerthRect(self): """Sets the berth graphics item boundingRect.""" font = QtGui.QFont("Courier New") font.setPixelSize(11) rect = QtGui.QFontMetricsF(font).boundingRect("XXXXX") self._berthRect = rect
@run: import coopQt as cqt (suggested) @created: 12 Aug, 2015 @change: 29 Apr, 2017 ''' import maya.mel as mel import maya.cmds as cmds import maya.OpenMayaUI as omUI from Qt import QtCore, QtGui, QtWidgets try: from shiboken import wrapInstance except: from shiboken2 import wrapInstance #STYLES fontHeader = QtGui.QFont('MS Shell dlg 2', 15) fontFooter = QtGui.QFont('MS Shell dlg 2', 8) # STYLING #button.setStyleSheet("background-color: rgb(0,210,255); color: rgb(0,0,0);") #imagePath = cmds.internalVar(upd = True) + 'icons/background.png') #button.setStyleSheet("background-image: url(" + imagePath + "); border:solid black 1px;") #self.setStyleSheet("QLabel { color: rgb(50, 50, 50); font-size: 11px; background-color: rgba(188, 188, 188, 50); border: 1px solid rgba(188, 188, 188, 250); } QSpinBox { color: rgb(50, 50, 50); font-size: 11px; background-color: rgba(255, 188, 20, 50); }") #WINDOW def getMayaWindow(): ptr = omUI.MQtUtil.mainWindow() #pointer to main window return wrapInstance(long(ptr), QtWidgets.QWidget) #wrapper
def __init__(self): super(Core_TimelineMarker, self).__init__() self.data_file = self.getJSONPath() self.tx_shot = QtWidgets.QLabel("NO ENV SET") self.bt_add = QtWidgets.QPushButton(u"\u002B") self.bt_add.clicked.connect(self.addMarker) self.bt_add.setStyle(QtGui.QFont().setBold(True)) self.bt_remove = QtWidgets.QPushButton(u"\u2212") self.bt_remove.clicked.connect(self.removeMarker) self.bt_remove.setStyle(QtGui.QFont().setBold(True)) self.bt_save = QtWidgets.QPushButton('save') self.bt_save.setToolTip("Save Current Markers") self.bt_save.clicked.connect(self.saveMarkers) self.bt_reload = QtWidgets.QPushButton('reload') self.bt_reload.setToolTip("Reload Markers from Loaded File") self.bt_reload.clicked.connect(self.reloadMarkers) self.bt_reloadFile = QtWidgets.QPushButton('reload from file') self.bt_reloadFile.clicked.connect(self.loadFromFile) self.bt_reloadFile.setToolTip("Load Markers from selected File") self.bt_add.setFixedWidth(50) self.bt_remove.setFixedWidth(50) self.bt_add.setFlat(True) self.bt_remove.setFlat(True) self.bt_save.setFlat(True) self.bt_reload.setFlat(True) self.bt_reloadFile.setFlat(True) self.layout_editMarkers = QtWidgets.QGridLayout() self.layout_editMarkers.setContentsMargins(0,0,0,0) self.layout_editMarkers.setSpacing(0) self.layout_editMarkers.addWidget(self.tx_shot,0,0) self.layout_editMarkers.addWidget(self.bt_add,0,2) self.layout_editMarkers.addWidget(self.bt_remove,0,3) self.layout_markers = QtWidgets.QHBoxLayout() self.layout_markers.setSpacing(0) self.group_markers = QtWidgets.QGroupBox() self.group_markers.setContentsMargins(0,0,0,0) self.group_markers.setLayout(self.layout_markers) self.layout_reload = QtWidgets.QGridLayout() self.layout_reload.setContentsMargins(0,0,0,0) self.layout_reload.setSpacing(0) self.layout_reload.addWidget(self.bt_save, 0,0) self.layout_reload.addWidget(self.bt_reload, 0,1) self.layout_reload.addWidget(self.bt_reloadFile, 0,2) self.layout_master = QtWidgets.QHBoxLayout() self.layout_master.setContentsMargins(10,0,10,0) self.layout_master.setSpacing(0) self.layout_master.addLayout(self.layout_editMarkers) self.layout_master.addSpacerItem(QtWidgets.QSpacerItem(10,10)) self.layout_master.addWidget(self.group_markers) self.layout_master.addStretch() self.layout_master.addLayout(self.layout_reload) self.setLayout(self.layout_master) self.resize(1000,50) self.setContentsMargins(0,0,0,0) self.setWindowTitle("Timeline Markers - beta") self.reloadMarkers()