示例#1
0
 def createLabels(self):
     self.directoryLabel = QtWidgets.QLabel(self.tr("Search in:"))
     self.fileNameLabel = QtWidgets.QLabel(
         self.tr("File name (including wildcards):"))
示例#2
0
    def set_package_name(self, package_name):
        package_paths = self.context_model.packages_path
        self.packages = {}
        self.clear()
        rows = []

        busy_cursor = QtGui.QCursor(QtCore.Qt.WaitCursor)
        QtWidgets.QApplication.setOverrideCursor(busy_cursor)
        try:
            packages = list(
                iter_packages(name=str(package_name), paths=package_paths))
        except RezError:
            packages = []

        if not packages:
            self.setEnabled(False)
            self.package_name = None
            QtWidgets.QApplication.restoreOverrideCursor()
            return

        for i, package in enumerate(
                sorted(packages, key=lambda x: x.version, reverse=True)):
            version_str = str(package.version) + ' '
            path_str = package.uri + "  "
            release_str = get_timestamp_str(package.timestamp) \
                if package.timestamp else '-'
            enabled = self.callback(package) if self.callback else True
            rows.append((enabled, version_str, path_str, release_str))
            self.packages[i] = package

        QtWidgets.QApplication.restoreOverrideCursor()
        self.setRowCount(len(rows))
        first_selectable_row = -1

        for i, row in enumerate(rows):
            enabled, version_str = row[:2]
            row = row[2:]
            item = QtWidgets.QTableWidgetItem(version_str)
            item.setTextAlignment(QtCore.Qt.AlignRight
                                  | QtCore.Qt.AlignVCenter)
            self.setVerticalHeaderItem(i, item)

            for j in range(len(row)):
                item = QtWidgets.QTableWidgetItem(row[j])
                if enabled:
                    if first_selectable_row == -1:
                        first_selectable_row = i
                else:
                    item.setFlags(QtCore.Qt.NoItemFlags)
                self.setItem(i, j, item)

        self.setHorizontalHeaderLabels(["path", "released"])
        self.resizeRowsToContents()
        self.resizeColumnsToContents()
        vh = self.verticalHeader()
        vh.setVisible(True)
        hh = self.horizontalHeader()
        hh.setStretchLastSection(True)
        hh.setVisible(True)

        self.package_name = package_name
        self.setEnabled(True)

        if first_selectable_row != -1:
            self.selectRow(first_selectable_row)
def project_settings_init():

    session = ftrack_api.Session()
    task = session.get("Task", os.environ["FTRACK_TASKID"])

    changes = []

    # FPS
    local_fps = remote_fps = nuke.root()["fps"].getValue()
    if "fps" in task["parent"]["custom_attributes"]:
        remote_fps = task["parent"]["custom_attributes"]["fps"]

    if local_fps != remote_fps:
        changes.append({
            "setting": nuke.root()["fps"],
            "new": remote_fps,
            "old": local_fps
        })

    # Resolution
    local_width = remote_width = nuke.root()["format"].value().width()
    if "width" in task["parent"]["custom_attributes"]:
        remote_width = int(task["parent"]["custom_attributes"]["width"])
    local_height = remote_height = nuke.root()["format"].value().height()
    if "height" in task["parent"]["custom_attributes"]:
        remote_height = int(task["parent"]["custom_attributes"]["height"])

    if (remote_width and remote_height and remote_width != local_width
            or remote_height != local_height):

        fmt = None
        for f in nuke.formats():
            if f.width() == remote_width and f.height() == remote_height:
                fmt = f.name()

        if not fmt:
            nuke.addFormat("{0} {1} FtrackDefault".format(
                int(remote_width), int(remote_height)))
            fmt = "FtrackDefault"

        changes.append({
            "setting": nuke.root()["format"],
            "new": fmt,
            "old": nuke.root()["format"].value().name()
        })

    # Frame Range
    handles = 0
    if "handles" in task["parent"]["custom_attributes"]:
        handles = task["parent"]["custom_attributes"]["handles"]
    local_fstart = remote_fstart = nuke.root()["first_frame"].getValue()
    if "fstart" in task["parent"]["custom_attributes"]:
        remote_fstart = task["parent"]["custom_attributes"]["fstart"]
        remote_fstart -= handles
    local_fend = remote_fend = nuke.root()["last_frame"].getValue()
    if "fend" in task["parent"]["custom_attributes"]:
        remote_fend = task["parent"]["custom_attributes"]["fend"]
        remote_fend += handles

    if local_fstart != remote_fstart:
        changes.append({
            "setting": nuke.root()["first_frame"],
            "new": remote_fstart,
            "old": local_fstart
        })

    if local_fend != remote_fend:
        changes.append({
            "setting": nuke.root()["last_frame"],
            "new": remote_fend,
            "old": local_fend
        })

    # No changes.
    if not changes:
        return

    # Display changes to user
    messagebox = QtWidgets.QMessageBox()
    messagebox.setIcon(messagebox.Warning)

    messagebox.setWindowTitle("Project Setting Changes")
    messagebox.setText(
        "Changes to the project settings has been detected in Ftrack.")

    detailed_text = ""
    for change in changes:
        detailed_text += '"{0}": {1} > {2}\n'.format(change["setting"].name(),
                                                     change["old"],
                                                     change["new"])
    messagebox.setDetailedText(detailed_text)

    messagebox.setStandardButtons(messagebox.Ok)
    messagebox.addButton(messagebox.Cancel)
    result = messagebox.exec_()

    # Cancel changes
    if result == QtWidgets.QMessageBox.Cancel:
        return

    # Set changes.
    for change in changes:
        change["setting"].setValue(change["new"])
示例#4
0
    def __init__(self,
                 parent=None,
                 startColor=[0, 0, 0],
                 type="float",
                 alpha=False,
                 h=50,
                 *args):
        super(pyf_ColorSlider, self).__init__(parent=parent, *args)
        self.parent = parent
        self.setLayout(QtWidgets.QHBoxLayout())
        self.type = type
        self.alpha = alpha
        self.RBox = valueBox(type=self.type)
        self.GBox = valueBox(type=self.type)
        self.BBox = valueBox(type=self.type)
        self.ABox = valueBox(type=self.type)

        for i in [self.RBox, self.GBox, self.BBox, self.ABox]:
            i.setMinimum(0)
            if type == "int":
                i.setMaximum(255)
            else:
                i.setMaximum(1.0)

        self.R = pyf_GradientSlider(self, color2=[255, 0, 0])
        self.G = pyf_GradientSlider(self, color2=[0, 255, 0])
        self.B = pyf_GradientSlider(self, color2=[0, 0, 255])
        self.A = pyf_GradientSlider(self, color2=[255, 255, 255])

        div = 1.0
        if self.type == "int":
            div = 255.0

        self.RBox.editingFinished.connect(
            lambda: self.R.setValue(float(self.RBox.value()) / div))
        self.R.doubleValueChanged.connect(
            lambda: self.RBox.setValue(self.R.value() * div))
        self.GBox.editingFinished.connect(
            lambda: self.G.setValue(float(self.GBox.value()) / div))
        self.G.doubleValueChanged.connect(
            lambda: self.GBox.setValue(self.G.value() * div))
        self.BBox.editingFinished.connect(
            lambda: self.B.setValue(float(self.BBox.value()) / div))
        self.B.doubleValueChanged.connect(
            lambda: self.BBox.setValue(self.B.value() * div))
        self.ABox.editingFinished.connect(
            lambda: self.A.setValue(float(self.ABox.value()) / div))
        self.A.doubleValueChanged.connect(
            lambda: self.ABox.setValue(self.A.value() * div))

        rLay = QtWidgets.QHBoxLayout()
        rLay.addWidget(self.RBox)
        rLay.addWidget(self.R)
        gLay = QtWidgets.QHBoxLayout()
        gLay.addWidget(self.GBox)
        gLay.addWidget(self.G)
        bLay = QtWidgets.QHBoxLayout()
        bLay.addWidget(self.BBox)
        bLay.addWidget(self.B)
        aLay = QtWidgets.QHBoxLayout()
        aLay.addWidget(self.ABox)
        aLay.addWidget(self.A)

        self.A.setValue(1.0)
        self.Color = QtWidgets.QPushButton()
        self.Color.clicked.connect(self.showColorDialog)

        self.Color.setMaximumWidth(h)
        self.Color.setMinimumWidth(h)
        self.Color.setMaximumHeight(h - 12)
        self.Color.setMinimumHeight(h - 12)
        self.slidersLay = QtWidgets.QVBoxLayout()
        inpList = [rLay, gLay, bLay]

        if self.alpha:
            inpList.append(aLay)
        else:
            self.A.hide()

        for i in [
                self.R, self.G, self.B, self.A, self.RBox, self.GBox,
                self.BBox, self.ABox
        ]:

            i.setMaximumHeight(h / (len(inpList) + 1))
            i.setMinimumHeight(h / (len(inpList) + 1))
        for i in [self.R, self.G, self.B, self.A]:
            i.doubleValueChanged.connect(self.colorChanged)

        for i in inpList:
            self.slidersLay.addLayout(i)

        self.setMaximumHeight(h)
        self.layout().addWidget(self.Color)
        self.layout().addLayout(self.slidersLay)
        self.layout().setSpacing(5)
        self.slidersLay.setSpacing(0)
        self.styleSheetString = "QPushButton{ background-color: rgba(%f,%f,%f,%f);border-color: black;border-radius: 2px;border-style: outset;border-width: 1px;}\nQPushButton:pressed{ border-style: inset;border-color: beige}"
        self.defaultColor = startColor
        if isinstance(startColor, list) and len(startColor) >= 3:
            self.setColor(startColor)
        self.Color.setStyleSheet(self.styleSheetString %
                                 (self.R.value() * 255, self.G.value() * 255,
                                  self.B.value() * 255, self.A.value() * 255))
        self._menu = QtWidgets.QMenu()
        self.actionReset = self._menu.addAction("ResetValue")
        self.actionReset.triggered.connect(self.onResetValue)
示例#5
0
 def initializeUi(self):
     super(MayaCheckBoxTreeWidget, self).initializeUi()
     self.setIndentation(0)
     self.setSelectionMode(QtWidgets.QAbstractItemView.ExtendedSelection)
     self.setHeaderItem(QtWidgets.QTreeWidgetItem(["Layer", "Camera"]))
示例#6
0
    def __init__(self, parent=None):
        super(PresetShareUI, self).__init__(parent=parent)
        # window prep ---------------------------------------------------------
        self.parent = parent
        self.setWindowTitle(WINDOW_TITLE)
        self.setObjectName(self.__class__.__name__)
        self.setAttribute(QtCore.Qt.WA_DeleteOnClose, True)
        minflag = QtCore.Qt.WindowMinimizeButtonHint
        self.setWindowFlags(self.windowFlags() | minflag)
        self.setMinimumWidth(350)
        self.preset_share_dir = preset_share_utils.get_base_dir()
        self.mainLayout = QtWidgets.QVBoxLayout()
        self.setLayout(self.mainLayout)

        # logic variables -----------------------------------------------------
        self._remember_dir_var = "{}lastpath".format(self.__class__.__name__)
        self.skip_other_users = True
        self.collected_dir_info = {}
        self.view_expanded_state_info = {}
        self._state_gathered = False

        # file system crawl and display ---------------------------------------
        self.search_widget = QtWidgets.QLineEdit()
        self.search_widget.setPlaceholderText("Search")

        self.file_manager = QtWidgets.QFileSystemModel()
        ext_filters = ["*.{}".format(preset_share_utils.PRESET_EXT)]
        self.file_manager.setNameFilters(ext_filters)
        self.file_manager.rowsInserted.connect(self.manual_tracking)
        self.file_manager.columnsInserted.connect(self.manual_tracking)
        self.file_manager.directoryLoaded.connect(self.loadedPath)
        self.root_model_index = self.file_manager.setRootPath(
            self.preset_share_dir)

        self.file_view = QtWidgets.QTreeView()
        self.file_view.setModel(self.file_manager)
        self.file_view.setRootIndex(self.root_model_index)
        self.file_view.hideColumn(1)
        self.file_view.hideColumn(2)
        self.file_view.clicked.connect(self.preset_selected)
        self.file_view.header().setSectionResizeMode(
            QtWidgets.QHeaderView.Stretch)
        # self.file_view.header().setStretchLastSection(True)
        self.file_view.setContextMenuPolicy(QtCore.Qt.CustomContextMenu)
        self.file_view.customContextMenuRequested.connect(
            self.create_context_menu)

        # Arbitrarily setting this now, as it gets set again with signals -----
        self.set_search_completer()

        self.text_view = QtWidgets.QTextEdit()
        self.text_view.setReadOnly(True)
        self.text_view.setMaximumHeight(100)

        self.apply_preset_btn = QtWidgets.QPushButton("Apply Preset")
        self.apply_preset_btn.setToolTip("Select Node of same type.")
        self.apply_preset_btn.setEnabled(False)
        self.apply_preset_btn.clicked.connect(self.apply_preset)

        self.create_preset_btn = QtWidgets.QPushButton("Create Preset")
        self.create_preset_btn.setToolTip("Select Node in Maya")
        self.create_preset_btn.clicked.connect(self.create_preset)

        self.mainLayout.addWidget(self.search_widget)
        self.mainLayout.addWidget(self.file_view)
        self.mainLayout.addWidget(self.text_view)
        self.mainLayout.addWidget(self.apply_preset_btn)
        self.mainLayout.addWidget(self.create_preset_btn)
示例#7
0
    def __init__(self, table_view=True, big_view=False, parent=None):
        super(MItemViewFullSet, self).__init__(parent)
        self.sort_filter_model = MSortFilterModel()
        self.source_model = MTableModel()
        self.sort_filter_model.setSourceModel(self.source_model)

        self.stack_widget = QtWidgets.QStackedWidget()

        self.view_button_grp = MToolButtonGroup(exclusive=True)
        data_group = []
        if table_view:
            self.table_view = MTableView(show_row_count=True)
            self.table_view.doubleClicked.connect(self.sig_double_clicked)
            self.table_view.pressed.connect(self.slot_left_clicked)
            self.table_view.setModel(self.sort_filter_model)
            self.stack_widget.addWidget(self.table_view)
            data_group.append({
                "svg": "table_view.svg",
                "checkable": True,
                "tooltip": "Table View"
            })
        if big_view:
            self.big_view = MBigView()
            self.big_view.doubleClicked.connect(self.sig_double_clicked)
            self.big_view.pressed.connect(self.slot_left_clicked)
            self.big_view.setModel(self.sort_filter_model)
            self.stack_widget.addWidget(self.big_view)
            data_group.append({
                "svg": "big_view.svg",
                "checkable": True,
                "tooltip": "Big View"
            })

        # 设置多个view 共享 MItemSelectionModel
        leader_view = self.stack_widget.widget(0)
        self.selection_model = leader_view.selectionModel()
        for index in range(self.stack_widget.count()):
            if index == 0:
                continue
            other_view = self.stack_widget.widget(index)
            other_view.setSelectionModel(self.selection_model)

        self.selection_model.currentChanged.connect(self.sig_current_changed)
        self.selection_model.currentRowChanged.connect(
            self.sig_current_row_changed)
        self.selection_model.currentColumnChanged.connect(
            self.sig_current_column_changed)
        self.selection_model.selectionChanged.connect(
            self.sig_selection_changed)

        self.tool_bar = QtWidgets.QWidget()
        self.top_lay = QtWidgets.QHBoxLayout()
        self.top_lay.setContentsMargins(0, 0, 0, 0)
        if data_group and len(data_group) > 1:
            self.view_button_grp.sig_checked_changed.connect(
                self.stack_widget.setCurrentIndex)
            self.view_button_grp.set_button_list(data_group)
            self.view_button_grp.set_dayu_checked(0)
            self.top_lay.addWidget(self.view_button_grp)
        self.search_line_edit = MLineEdit().search().small()
        self.search_attr_button = MToolButton().icon_only().svg(
            "down_fill.svg").small()
        self.search_line_edit.set_prefix_widget(self.search_attr_button)
        self.search_line_edit.textChanged.connect(
            self.sort_filter_model.set_search_pattern)
        self.search_line_edit.setVisible(False)

        self.top_lay.addStretch()
        self.top_lay.addWidget(self.search_line_edit)
        self.tool_bar.setLayout(self.top_lay)

        self.page_set = MPage()
        self.main_lay = QtWidgets.QVBoxLayout()
        self.main_lay.setSpacing(5)
        self.main_lay.setContentsMargins(0, 0, 0, 0)
        self.main_lay.addWidget(self.tool_bar)
        self.main_lay.addWidget(self.stack_widget)
        self.main_lay.addWidget(self.page_set)
        self.setLayout(self.main_lay)
示例#8
0
 def message_dialog(text='', title='Message'):
     dlg = QtWidgets.QMessageBox()
     dlg.setWindowTitle(title)
     dlg.setInformativeText(text)
     dlg.setStandardButtons(QtWidgets.QMessageBox.Ok)
     return dlg.exec()
示例#9
0
	def __init__( self, topLevelWidget, toolTip="", parenting = None ) :

		Gaffer.Trackable.__init__( self )

		assert( isinstance( topLevelWidget, ( QtWidgets.QWidget, Widget ) ) )

		if isinstance( topLevelWidget, QtWidgets.QWidget ) :
			assert( Widget.__qtWidgetOwners.get( topLevelWidget ) is None )
			self.__qtWidget = topLevelWidget

			## Qt treats subclasses of QWidget differently from direct instances of QWidget itself
			# where in direct instances of QWidget the behavior of the attribute "WA_StyledBackground"
			# is set in place, however there is a bug in PySide that treats direct instances of QWidget
			# in the same way as their subclassed ones, because of that we need to set the
			# attribute WA_StyledBackground to all direct instances of QWidget to get the expected
			# behavior from Qt when using PySide.
			# more details:
			# http://stackoverflow.com/questions/32313469/stylesheet-in-pyside-not-working
			if type( topLevelWidget ) == QtWidgets.QWidget :
				self.__qtWidget.setAttribute( QtCore.Qt.WA_StyledBackground, True )
		else :
			self.__gafferWidget = topLevelWidget
			self.__qtWidget = QtWidgets.QWidget()
			self.__qtWidget.setLayout( QtWidgets.QGridLayout() )
			## We need to set the size constraint to prevent widgets expanding in an unwanted
			# way. However we may want other types to expand in the future. I think what we
			# really need to do is somehow make __qtWidget without a layout, and just have
			# it's size etc. dictated directly by self.__gafferWidget._qtWidget() somehow.
			self.__qtWidget.layout().setSizeConstraint( QtWidgets.QLayout.SetMinAndMaxSize )
			self.__qtWidget.layout().setContentsMargins( 0, 0, 0, 0 )
			self.__qtWidget.layout().addWidget( self.__gafferWidget._qtWidget(), 0, 0 )

		Widget.__qtWidgetOwners[self.__qtWidget] = weakref.ref( self )

		# disable different focus appearance on os x
		## \todo If we have a style class for Widget at some point, then perhaps
		# this should go in there.
		self.__qtWidget.setAttribute( QtCore.Qt.WA_MacShowFocusRect, False )

		self._keyPressSignal = None
		self._keyReleaseSignal = None
		self._buttonPressSignal = None
		self._buttonReleaseSignal = None
		self._buttonDoubleClickSignal = None
		self._mouseMoveSignal = None
		self._enterSignal = None
		self._leaveSignal = None
		self._dragBeginSignal = None
		self._dragEnterSignal = None
		self._dragMoveSignal = None
		self._dragLeaveSignal = None
		self._dropSignal = None
		self._dragEndSignal = None
		self._wheelSignal = None
		self._visibilityChangedSignal = None
		self._contextMenuSignal = None
		self._parentChangedSignal = None

		self.__visible = not isinstance( self, GafferUI.Window )

		# perform automatic parenting if necessary. we don't want to do this
		# for menus, because they don't have the same parenting semantics. if other
		# types end up with similar requirements then we should probably just have
		# a mechanism for them to say they don't want to participate rather than
		# hardcoding stuff here.
		if len( self.__parentStack ) and not isinstance( self, GafferUI.Menu ) :
			if self.__initNesting() == self.__parentStack[-1][1] + 1 :
				if self.__parentStack[-1][0] is not None :
					parenting = parenting or {}
					self.__parentStack[-1][0].addChild( self, **parenting )

		self.__eventFilterInstalled = False
		# if a class has overridden getToolTip, then the tooltips
		# may be dynamic based on context, and we need to display
		# them using the event filter.
		c = self.__class__
		while c and c is not Widget :
			if "getToolTip" in c.__dict__ :
				self.__ensureEventFilter()
				break
			c = c.__bases__[0]

		if isinstance( self, GafferUI.Window ) :
			# We need keypress events at the window level
			# in `_EventFilter.__dragKeyPress()`.
			self.__ensureEventFilter()

		self.setToolTip( toolTip )

		self.__applyQWidgetStyleClasses()
    def setupUi(self, Form):
        Form.setObjectName("Form")
        Form.resize(356, 25)
        self.horizontalLayout_5 = QtWidgets.QHBoxLayout(Form)
        self.horizontalLayout_5.setContentsMargins(0, 0, 0, 0)
        self.horizontalLayout_5.setObjectName("horizontalLayout_5")
        self.horizontalLayout = QtWidgets.QHBoxLayout()
        self.horizontalLayout.setObjectName("horizontalLayout")
        self.label = QtWidgets.QLabel(Form)
        sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Maximum, QtWidgets.QSizePolicy.Preferred)
        sizePolicy.setHorizontalStretch(0)
        sizePolicy.setVerticalStretch(0)
        sizePolicy.setHeightForWidth(self.label.sizePolicy().hasHeightForWidth())
        self.label.setSizePolicy(sizePolicy)
        self.label.setObjectName("label")
        self.horizontalLayout.addWidget(self.label)
        self.dsbX = QtWidgets.QDoubleSpinBox(Form)
        self.dsbX.setMinimumSize(QtCore.QSize(0, 0))
        self.dsbX.setMaximumSize(QtCore.QSize(80, 16777215))
        self.dsbX.setObjectName("dsbX")
        self.horizontalLayout.addWidget(self.dsbX)
        self.horizontalLayout_5.addLayout(self.horizontalLayout)
        self.horizontalLayout_2 = QtWidgets.QHBoxLayout()
        self.horizontalLayout_2.setObjectName("horizontalLayout_2")
        self.label_2 = QtWidgets.QLabel(Form)
        sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Maximum, QtWidgets.QSizePolicy.Preferred)
        sizePolicy.setHorizontalStretch(0)
        sizePolicy.setVerticalStretch(0)
        sizePolicy.setHeightForWidth(self.label_2.sizePolicy().hasHeightForWidth())
        self.label_2.setSizePolicy(sizePolicy)
        self.label_2.setObjectName("label_2")
        self.horizontalLayout_2.addWidget(self.label_2)
        self.dsbY = QtWidgets.QDoubleSpinBox(Form)
        self.dsbY.setMinimumSize(QtCore.QSize(0, 0))
        self.dsbY.setMaximumSize(QtCore.QSize(80, 16777215))
        self.dsbY.setObjectName("dsbY")
        self.horizontalLayout_2.addWidget(self.dsbY)
        self.horizontalLayout_5.addLayout(self.horizontalLayout_2)
        self.horizontalLayout_3 = QtWidgets.QHBoxLayout()
        self.horizontalLayout_3.setObjectName("horizontalLayout_3")
        self.label_3 = QtWidgets.QLabel(Form)
        sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Maximum, QtWidgets.QSizePolicy.Preferred)
        sizePolicy.setHorizontalStretch(0)
        sizePolicy.setVerticalStretch(0)
        sizePolicy.setHeightForWidth(self.label_3.sizePolicy().hasHeightForWidth())
        self.label_3.setSizePolicy(sizePolicy)
        self.label_3.setObjectName("label_3")
        self.horizontalLayout_3.addWidget(self.label_3)
        self.dsbZ = QtWidgets.QDoubleSpinBox(Form)
        self.dsbZ.setMaximumSize(QtCore.QSize(80, 16777215))
        self.dsbZ.setObjectName("dsbZ")
        self.horizontalLayout_3.addWidget(self.dsbZ)
        self.horizontalLayout_5.addLayout(self.horizontalLayout_3)
        self.horizontalLayout_4 = QtWidgets.QHBoxLayout()
        self.horizontalLayout_4.setObjectName("horizontalLayout_4")
        self.label_4 = QtWidgets.QLabel(Form)
        sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Maximum, QtWidgets.QSizePolicy.Preferred)
        sizePolicy.setHorizontalStretch(0)
        sizePolicy.setVerticalStretch(0)
        sizePolicy.setHeightForWidth(self.label_4.sizePolicy().hasHeightForWidth())
        self.label_4.setSizePolicy(sizePolicy)
        self.label_4.setObjectName("label_4")
        self.horizontalLayout_4.addWidget(self.label_4)
        self.dsbW = QtWidgets.QDoubleSpinBox(Form)
        self.dsbW.setMaximumSize(QtCore.QSize(80, 16777215))
        self.dsbW.setObjectName("dsbW")
        self.horizontalLayout_4.addWidget(self.dsbW)
        self.horizontalLayout_5.addLayout(self.horizontalLayout_4)
        spacerItem = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum)
        self.horizontalLayout_5.addItem(spacerItem)
        self.pbReset = QtWidgets.QPushButton(Form)
        sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Fixed, QtWidgets.QSizePolicy.Fixed)
        sizePolicy.setHorizontalStretch(0)
        sizePolicy.setVerticalStretch(0)
        sizePolicy.setHeightForWidth(self.pbReset.sizePolicy().hasHeightForWidth())
        self.pbReset.setSizePolicy(sizePolicy)
        self.pbReset.setMaximumSize(QtCore.QSize(25, 25))
        self.pbReset.setText("")
        icon = QtGui.QIcon()
        icon.addPixmap(QtGui.QPixmap(":/icons/resources/reset.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off)
        self.pbReset.setIcon(icon)
        self.pbReset.setObjectName("pbReset")
        self.horizontalLayout_5.addWidget(self.pbReset)

        self.retranslateUi(Form)
        QtCore.QMetaObject.connectSlotsByName(Form)
示例#11
0
	def __init__(self , parent = None):
		super(CleanCheckRIG , self).__init__(parent)
		self.Box_9_v = True
		
		self.keyOverName = []
		self.keyjointList = []
		self.setKeyDict = {'tx':0.0 , 'ty':0.0 , 'tz':0.0, 'rx':0.0 , 'ry':0.0 , 'rz':0.0 ,'sx':1.0 , 'sy':1.0 , 'sz':1.0 , 'v':True }

		self.QVBoxLayout = QtWidgets.QVBoxLayout()
		self.QVBoxLayout.setContentsMargins(5,5,5,5)
		
		self.groupBox = QtWidgets.QGroupBox()
		self.groupBox.setGeometry(QtCore.QRect(10, 10, 310, 491))
		self.QVBoxLayout.addWidget(self.groupBox)

		self.allShapeLayout = QtWidgets.QVBoxLayout()
		self.allShapeLayout.setContentsMargins(5,5,5,5)
		self.allShapeLayout.setSpacing(0)
		self.groupBox.setLayout(self.allShapeLayout)
		
		self.shapeLayout = QtWidgets.QVBoxLayout()
		self.shapeLayout.setContentsMargins(5,5,5,5)
		self.shapeLayout.setSpacing(5)
		self.allShapeLayout.addLayout(self.shapeLayout)
		
		self.checkBox_1 = QtWidgets.QCheckBox(unicode('检查重命名的节点' , 'gbk') )
		self.checkBox_1.setFixedHeight(20)
		self.shapeLayout.addWidget(self.checkBox_1)
		
		self.checkBox_2 = QtWidgets.QCheckBox(unicode('检查命名不正确的Shape节点' , 'gbk'))
		self.checkBox_2.setFixedHeight(20)
		self.shapeLayout.addWidget(self.checkBox_2)
		        
		self.checkBox_3 = QtWidgets.QCheckBox(unicode('检查绑定后不干净的shape节点' , 'gbk') )
		self.checkBox_3.setFixedHeight(20)
		self.shapeLayout.addWidget(self.checkBox_3)
	
		self.checkBox_4 = QtWidgets.QCheckBox(unicode('检查是否加smooth节点' , 'gbk') )
		self.checkBox_4.setFixedHeight(20)
		self.shapeLayout.addWidget(self.checkBox_4)
			       
		self.line = QtWidgets.QFrame()
		self.line.setFixedHeight(10)
		self.line.setFrameShape(QtWidgets.QFrame.HLine)
		self.line.setFrameShadow(QtWidgets.QFrame.Sunken)
		self.allShapeLayout.addWidget(self.line)
		
		self.shape2Layout = QtWidgets.QVBoxLayout()
		self.shape2Layout.setContentsMargins(5,5,5,5)
		self.shape2Layout.setSpacing(5)
		self.allShapeLayout.addLayout(self.shape2Layout)
		
		self.checkBox_6 = QtWidgets.QCheckBox(unicode('检查geo组以外的模型是否lambert材质不可渲染' , 'gbk') )
		self.checkBox_6.setFixedHeight(20)
		self.shape2Layout.addWidget(self.checkBox_6)
		
		self.checkBox_7 = QtWidgets.QCheckBox(unicode('设置geo组下模型可渲染' , 'gbk') )
		self.checkBox_7.setFixedHeight(20)
		self.shape2Layout.addWidget(self.checkBox_7)
		
		self.checkBox_8 = QtWidgets.QCheckBox(unicode('驱动,隐藏物体是否锁定或设置成了不可K帧' , 'gbk') )
		self.checkBox_8.setFixedHeight(20)
		self.shape2Layout.addWidget(self.checkBox_8)
		
		#self.checkBox_17 = QtWidgets.QCheckBox(unicode('手动清理暗面模型' , 'gbk') )
		#self.checkBox_17.setFixedHeight(20)
		#self.shape2Layout.addWidget(self.checkBox_17)
		
		
		self.line_2 = QtWidgets.QFrame()
		self.line_2.setFixedHeight(10)
		self.line_2.setFrameShape(QtWidgets.QFrame.HLine)
		self.line_2.setFrameShadow(QtWidgets.QFrame.Sunken)
		self.allShapeLayout.addWidget(self.line_2)
		
		self.shape3Layout = QtWidgets.QVBoxLayout()
		self.shape3Layout.setContentsMargins(5,5,5,5)
		self.shape3Layout.setSpacing(5)
		self.allShapeLayout.addLayout(self.shape3Layout)

		self.checkBox_9 = QtWidgets.QCheckBox(unicode('总控制器属性,颜色,关联显隐' , 'gbk'))
		self.checkBox_9.setFixedHeight(20)
		self.shape3Layout.addWidget(self.checkBox_9)
		
		self.checkBox_10 = QtWidgets.QCheckBox(unicode('RIG层级检查' , 'gbk') )
		self.checkBox_10.setFixedHeight(20)
		self.shape3Layout.addWidget(self.checkBox_10)
		
		self.checkBox_11 = QtWidgets.QCheckBox(unicode('毛发检查' , 'gbk'))
		self.checkBox_11.setFixedHeight(20)
		self.shape3Layout.addWidget(self.checkBox_11)
		
		self.checkBox_12 = QtWidgets.QCheckBox(unicode('检查头和手臂的Global属性' , 'gbk'))
		self.checkBox_12.setFixedHeight(20)
		self.shape3Layout.addWidget(self.checkBox_12)
		

		
		self.line_3 = QtWidgets.QFrame()
		self.line_3.setFixedHeight(10)
		self.line_3.setFrameShape(QtWidgets.QFrame.HLine)
		self.line_3.setFrameShadow(QtWidgets.QFrame.Sunken)
		self.allShapeLayout.addWidget(self.line_3)
		
		self.shape4Layout = QtWidgets.QVBoxLayout()
		self.shape4Layout.setContentsMargins(5,5,5,5)
		self.shape4Layout.setSpacing(5)
		self.allShapeLayout.addLayout(self.shape4Layout)
		
		self.checkBox_13 = QtWidgets.QCheckBox(unicode('清理多余的层' , 'gbk'))
		self.checkBox_13.setFixedHeight(20)
		self.shape4Layout.addWidget(self.checkBox_13)

		self.checkBox_14 = QtWidgets.QCheckBox(unicode('清理未知节点' , 'gbk'))
		self.checkBox_14.setFixedHeight(20)
		self.shape4Layout.addWidget(self.checkBox_14)
		
		self.checkBox_15 = QtWidgets.QCheckBox(unicode('清理多余蒙皮节点' , 'gbk') )
		self.checkBox_15.setFixedHeight(20)
		self.shape4Layout.addWidget(self.checkBox_15)
		
		self.checkBox_16 = QtWidgets.QCheckBox(unicode('清理多余蒙皮影响' , 'gbk') )
		self.checkBox_16.setFixedHeight(20)
		self.shape4Layout.addWidget(self.checkBox_16)
		

		self.line_4 = QtWidgets.QFrame()
		self.line_4.setFixedHeight(10)
		self.line_4.setFrameShape(QtWidgets.QFrame.HLine)
		self.line_4.setFrameShadow(QtWidgets.QFrame.Sunken)
		self.allShapeLayout.addWidget(self.line_4)
		
		self.startLayout = QtWidgets.QVBoxLayout()
		self.startLayout.setContentsMargins(5,5,5,5)
		self.startLayout.setSpacing(5)
		self.allShapeLayout.addLayout(self.startLayout)
		
		self.checkBox_20 = QtWidgets.QCheckBox(unicode('全选/全不选' , 'gbk') )
		self.checkBox_20.setFixedHeight(20)
		self.startLayout.addWidget(self.checkBox_20)
		
		self.pushButton = QtWidgets.QPushButton(unicode('开始检查' , 'gbk') )
		self.pushButton.setFixedHeight(30)
		self.pushButton.setFixedWidth(275)
		self.startLayout.addWidget(self.pushButton)
		
		
		self.resize(310, 450)
		
		self.setMinimumSize(QtCore.QSize(310, 450))
		self.setMaximumSize(QtCore.QSize(310, 450))
		
		self.makeConnections()
		self.setWindowTitle("Check Rig UI")
		self.setLayout(self.QVBoxLayout)
		self.initUiState()
		self.show()
示例#12
0
    def init_ui(self):
        """
        Logic to create QtWidget's UI.
        """

        # frame settings
        self.setWindowTitle('Transfer UVs after Skinning')
        # self.setWindowFlags(QtCore.Qt.WindowStaysOnTopHint)
        # self.setModal(False)
        self.setFixedHeight(150)
        self.setMinimumWidth(300)

        # defaults for margins and layouts are 10 but smaller values make the
        # layout look more professional
        # sets margins outside the layout: left, up, right, bottom
        self.layout().setContentsMargins(5, 5, 5, 5)

        # sets spacing between each element in the layout
        self.layout().setSpacing(5)

        # =====================================================================
        # PYQT Widget Defintions
        # =====================================================================

        # skinned_mesh_layout, child of central_widget ------------------------
        skinned_mesh_layout = QtWidgets.QHBoxLayout()

        skinned_mesh_lbl = QtWidgets.QLabel('Name of Skinned Mesh:')
        skinned_mesh_lbl.setAlignment(QtCore.Qt.AlignCenter)

        self.skinned_mesh_le = QtWidgets.QLineEdit(None)
        self.skinned_mesh_le.setReadOnly(True)

        skinned_mesh_btn = QtWidgets.QPushButton('<<')

        # uv_mesh_layout, child of central_widget -----------------------------
        uv_mesh_layout = QtWidgets.QHBoxLayout()

        uv_mesh_lbl = QtWidgets.QLabel('Name of UVed Mesh:')
        uv_mesh_lbl.setAlignment(QtCore.Qt.AlignCenter)

        self.uv_mesh_le = QtWidgets.QLineEdit(None)
        # self.uv_mesh_le.setPlaceholderText(None)
        self.uv_mesh_le.setReadOnly(True)

        load_uv_mesh_btn = QtWidgets.QPushButton('<<')

        self.transfer_btn = QtWidgets.QPushButton('Transfer UVs')
        self.transfer_btn.setEnabled(False)

        # =====================================================================
        # PYQT Widget/Layout Assignments
        # =====================================================================

        skinned_mesh_layout.addWidget(skinned_mesh_lbl)
        skinned_mesh_layout.addWidget(self.skinned_mesh_le)
        skinned_mesh_layout.addWidget(skinned_mesh_btn)

        uv_mesh_layout.addWidget(uv_mesh_lbl)
        uv_mesh_layout.addWidget(self.uv_mesh_le)
        uv_mesh_layout.addWidget(load_uv_mesh_btn)

        central_widget = QtWidgets.QWidget()
        central_widget.setLayout(QtWidgets.QVBoxLayout())
        central_widget.layout().addLayout(skinned_mesh_layout)
        central_widget.layout().addLayout(uv_mesh_layout)

        central_widget.layout().addWidget(self.transfer_btn)
        self.setCentralWidget(central_widget)

        # =====================================================================
        # PyQt Execution Connections
        # =====================================================================

        skinned_mesh_btn.clicked.connect(lambda: self.select_skinned_mesh())
        load_uv_mesh_btn.clicked.connect(lambda: self.select_uv_mesh())
        self.transfer_btn.clicked.connect(lambda: self.transfer_uvs(
            str(self.skinned_mesh_le.text()), str(self.uv_mesh_le.text())))
示例#13
0
文件: plugin.py 项目: 3dzayn/pype
    def populate_widgets(self, data, content_layout=None):
        """
        Populate widget from input dict.

        Each plugin has its own set of widget rows defined in dictionary
        each row values should have following keys: `type`, `target`,
        `label`, `order`, `value` and optionally also `toolTip`.

        Args:
            data (dict): widget rows or organized groups defined
                         by types `dict` or `section`
            content_layout (QtWidgets.QFormLayout)[optional]: used when nesting

        Returns:
            dict: redefined data dict updated with created widgets

        """

        content_layout = content_layout or self.content_layout[-1]
        # fix order of process by defined order value
        ordered_keys = list(data.keys())
        for k, v in data.items():
            try:
                # try removing a key from index which should
                # be filled with new
                ordered_keys.pop(v["order"])
            except IndexError:
                pass
            # add key into correct order
            ordered_keys.insert(v["order"], k)

        # process ordered
        for k in ordered_keys:
            v = data[k]
            tool_tip = v.get("toolTip", "")
            if v["type"] == "dict":
                # adding spacer between sections
                self.content_layout.append(QtWidgets.QWidget(self))
                content_layout.addWidget(self.content_layout[-1])
                self.content_layout[-1].setObjectName("sectionHeadline")

                headline = QtWidgets.QVBoxLayout(self.content_layout[-1])
                headline.addWidget(Spacer(20, self))
                headline.addWidget(QtWidgets.QLabel(v["label"]))

                # adding nested layout with label
                self.content_layout.append(QtWidgets.QWidget(self))
                self.content_layout[-1].setObjectName("sectionContent")

                nested_content_layout = QtWidgets.QFormLayout(
                    self.content_layout[-1])
                nested_content_layout.setObjectName("NestedContentLayout")
                content_layout.addWidget(self.content_layout[-1])

                # add nested key as label
                data[k]["value"] = self.populate_widgets(
                    v["value"], nested_content_layout)

            if v["type"] == "section":
                # adding spacer between sections
                self.content_layout.append(QtWidgets.QWidget(self))
                content_layout.addWidget(self.content_layout[-1])
                self.content_layout[-1].setObjectName("sectionHeadline")

                headline = QtWidgets.QVBoxLayout(self.content_layout[-1])
                headline.addWidget(Spacer(20, self))
                headline.addWidget(QtWidgets.QLabel(v["label"]))

                # adding nested layout with label
                self.content_layout.append(QtWidgets.QWidget(self))
                self.content_layout[-1].setObjectName("sectionContent")

                nested_content_layout = QtWidgets.QFormLayout(
                    self.content_layout[-1])
                nested_content_layout.setObjectName("NestedContentLayout")
                content_layout.addWidget(self.content_layout[-1])

                # add nested key as label
                data[k]["value"] = self.populate_widgets(
                    v["value"], nested_content_layout)

            elif v["type"] == "QLineEdit":
                data[k]["value"] = self.create_row(content_layout,
                                                   "QLineEdit",
                                                   v["label"],
                                                   setText=v["value"],
                                                   setToolTip=tool_tip)
            elif v["type"] == "QComboBox":
                data[k]["value"] = self.create_row(content_layout,
                                                   "QComboBox",
                                                   v["label"],
                                                   addItems=v["value"],
                                                   setToolTip=tool_tip)
            elif v["type"] == "QCheckBox":
                data[k]["value"] = self.create_row(content_layout,
                                                   "QCheckBox",
                                                   v["label"],
                                                   setChecked=v["value"],
                                                   setToolTip=tool_tip)
            elif v["type"] == "QSpinBox":
                data[k]["value"] = self.create_row(content_layout,
                                                   "QSpinBox",
                                                   v["label"],
                                                   setRange=(0, 99999),
                                                   setValue=v["value"],
                                                   setToolTip=tool_tip)
        return data
示例#14
0
文件: plugin.py 项目: 3dzayn/pype
    def __init__(self, name, info, ui_inputs, parent=None):
        super(CreatorWidget, self).__init__(parent)

        self.setObjectName(name)

        self.setWindowFlags(QtCore.Qt.Window
                            | QtCore.Qt.CustomizeWindowHint
                            | QtCore.Qt.WindowTitleHint
                            | QtCore.Qt.WindowCloseButtonHint
                            | QtCore.Qt.WindowStaysOnTopHint)
        self.setWindowTitle(name or "OpenPype Creator Input")
        self.resize(500, 700)

        # Where inputs and labels are set
        self.content_widget = [QtWidgets.QWidget(self)]
        top_layout = QtWidgets.QFormLayout(self.content_widget[0])
        top_layout.setObjectName("ContentLayout")
        top_layout.addWidget(Spacer(5, self))

        # first add widget tag line
        top_layout.addWidget(QtWidgets.QLabel(info))

        # main dynamic layout
        self.scroll_area = QtWidgets.QScrollArea(self, widgetResizable=True)
        self.scroll_area.setVerticalScrollBarPolicy(
            QtCore.Qt.ScrollBarAsNeeded)
        self.scroll_area.setVerticalScrollBarPolicy(
            QtCore.Qt.ScrollBarAlwaysOn)
        self.scroll_area.setHorizontalScrollBarPolicy(
            QtCore.Qt.ScrollBarAlwaysOff)
        self.scroll_area.setWidgetResizable(True)

        self.content_widget.append(self.scroll_area)

        scroll_widget = QtWidgets.QWidget(self)
        in_scroll_area = QtWidgets.QVBoxLayout(scroll_widget)
        self.content_layout = [in_scroll_area]

        # add preset data into input widget layout
        self.items = self.populate_widgets(ui_inputs)
        self.scroll_area.setWidget(scroll_widget)

        # Confirmation buttons
        btns_widget = QtWidgets.QWidget(self)
        btns_layout = QtWidgets.QHBoxLayout(btns_widget)

        cancel_btn = QtWidgets.QPushButton("Cancel")
        btns_layout.addWidget(cancel_btn)

        ok_btn = QtWidgets.QPushButton("Ok")
        btns_layout.addWidget(ok_btn)

        # Main layout of the dialog
        main_layout = QtWidgets.QVBoxLayout(self)
        main_layout.setContentsMargins(10, 10, 10, 10)
        main_layout.setSpacing(0)

        # adding content widget
        for w in self.content_widget:
            main_layout.addWidget(w)

        main_layout.addWidget(btns_widget)

        ok_btn.clicked.connect(self._on_ok_clicked)
        cancel_btn.clicked.connect(self._on_cancel_clicked)

        stylesheet = resolve.api.menu.load_stylesheet()
        self.setStyleSheet(stylesheet)
示例#15
0
        self.thief.quit()
        super(Edits, self).focusOutEvent(event)

    def closeEvent(self, event):
        self.thief.quit()
        super(Edits, self).closeEvent(event)




# test floating panel
e = Edits()
e.show()

def edit_func():
    print('EDITOR!')

a = QtWidgets.QAction(e)
a.triggered.connect(edit_func)
s = QtGui.QKeySequence('Ctrl+S')
a.setShortcut(s)
a.setShortcutContext(QtCore.Qt.WidgetShortcut)
e.addAction(a)

#&& # test docked panel
remove_panel('edits')
panel = nukescripts.registerWidgetAsPanel2(
    'Edits', 'edits', 'edits', create=True
)
dock = nuke.getPaneFor('Viewer.1')
panel.addToPane(dock)
示例#16
0
    def create_ui(self):
        self.setParent(MayaParent)
        self.setWindowFlags(QtCore.Qt.Window)
        self.setWindowTitle(self.WINDOW_OBJECT_NAME)

        self.setDockOptions(qw.QMainWindow.AllowTabbedDocks | qw.QMainWindow.AnimatedDocks)
        self.setUnifiedTitleAndToolBarOnMac(False)
        self.setAttribute(QtCore.Qt.WA_DeleteOnClose)

        mainWidget = qw.QWidget()
        self.setCentralWidget(mainWidget)
        #mainWidget.setFixedHeight(130)
        mainWidget.setAttribute(QtCore.Qt.WA_StyledBackground)
        #mainWidget.setStyleSheet(Mstyle.QWidget())


        vlay = qw.QVBoxLayout()
        mainWidget.setLayout(vlay)



        groupbox1 = qw.QGroupBox()
        vlayout1 = qw.QVBoxLayout(groupbox1)
        vlayout1.setAlignment(QtCore.Qt.AlignCenter)

        hlay0 = qw.QHBoxLayout()

        self.spinC = qw.QSpinBox()
        self.spinC.setRange(0, 100)
        self.spinC.setEnabled(False)
        self.spinC.setValue(0)
        self.spinC.setFixedWidth(60)
        self.spinC.setSuffix('%')
        hlay0.addWidget(self.spinC)

        selA = qw.QPushButton('set')
        selA.setEnabled(False)
        selA.setFixedSize(50,20)
        selA.setToolTip('orig')
        selA.setStyleSheet(Mstyle.QPushButton(kw='b'))
        hlay0.addWidget(selA)

        self.lineEA = qw.QLineEdit()
        self.lineEA.setEnabled(False)
        self.lineEA.setStyleSheet(Mstyle.QLineEdit(kw='c'))
        self.lineEA.setText('click << to pick Orignal mesh')
        hlay0.addWidget(self.lineEA)

        addBtnA = qw.QPushButton('<<')
        addBtnA.setFixedSize(50,20)
        addBtnA.setToolTip('orignal')
        addBtnA.setStyleSheet(Mstyle.QPushButton(kw='on'))
        hlay0.addWidget(addBtnA)
        vlayout1.addLayout(hlay0)

        hlay1 = qw.QHBoxLayout()

        self.spinD = qw.QSpinBox()
        self.spinD.setRange(0, 100)
        self.spinD.setValue(100)
        self.spinD.setFixedWidth(60)
        self.spinD.setSuffix('%')
        hlay1.addWidget(self.spinD)

        selB = qw.QPushButton('set')
        selB.setFixedSize(50, 20)
        selB.setToolTip('bs')
        selB.setStyleSheet(Mstyle.QPushButton(kw='b'))
        hlay1.addWidget(selB)

        self.lineEB = qw.QLineEdit()
        self.lineEB.setStyleSheet(Mstyle.QLineEdit(kw='c'))
        self.lineEB.setEnabled(False)
        self.lineEB.setText('click << to pick Blenshape mesh')
        hlay1.addWidget(self.lineEB)

        addBtnB = qw.QPushButton('<<')
        addBtnB.setFixedSize(50, 20)
        addBtnB.setToolTip('blendshape')
        addBtnB.setStyleSheet(Mstyle.QPushButton(kw='on'))
        hlay1.addWidget(addBtnB)
        vlayout1.addLayout(hlay1)

        tipLab1 = qw.QLabel('')
        tipLab1.setText('Tips: set button >> set selection vertex position like orignal or blendshape mesh')
        vlayout1.addWidget(tipLab1)

        vlay.addWidget(groupbox1)
        # ==========================
        self.typeTab = qw.QTabWidget()
        self.typeTab.setStyleSheet(Mstyle.QTabWidget())
        self.typeTab.setTabPosition(qw.QTabWidget.West)

        groupbox3 = qw.QGroupBox()
        groupbox3 .setStyleSheet(Mstyle.QGroupBox())
        vlayout3 = qw.QVBoxLayout(groupbox3)
        vlayout3.setAlignment(QtCore.Qt.AlignCenter)

        createMidPlaneBtn = qw.QPushButton('create middle fast plane')
        createMidPlaneBtn.setStyleSheet(Mstyle.QPushButton(kw='on'))
        vlayout3.addWidget(createMidPlaneBtn)

        selMidPlaneBtn = qw.QPushButton('select and update')
        selMidPlaneBtn.setStyleSheet(Mstyle.QPushButton(kw='b'))
        #vlayout3.addWidget(selMidPlaneBtn)

        spinHB = qw.QHBoxLayout()
        titleLabSpinB = qw.QLabel('curvility (0-50):')

        self.spinB = qw.QSpinBox()
        self.spinB.setRange(0, 50)
        self.spinB.setValue(30)

        spinHB.addWidget(titleLabSpinB)
        spinHB.addWidget(self.spinB)
        #self.spinB.setPrefix ('curvility: ')
        vlayout3.addLayout(spinHB)

        self.typeTab.addTab(groupbox3, 'type1')

        # ============================
        groupbox2 = qw.QGroupBox()
        groupbox2 .setStyleSheet(Mstyle.QGroupBox())
        vlayout2 = qw.QVBoxLayout(groupbox2)
        vlayout2.setAlignment(QtCore.Qt.AlignCenter)

        hlay10 = qw.QHBoxLayout()
        spinApreLabel = qw.QLabel()
        spinApreLabel.setText('split to ')
        spinApreLabel.setFixedWidth(40)
        hlay10.addWidget(spinApreLabel)

        self.spinA = qw.QSpinBox()
        self.spinA.setRange(2, 20)
        self.spinA.setValue(2)
        self.spinA.setFixedWidth(90)
        self.spinA.setSuffix('parts')

        createPlaneBtn = qw.QPushButton('create plane')

        createPlaneBtn.setStyleSheet(Mstyle.QPushButton(kw='on'))

        hlay10.addWidget(self.spinA)
        hlay10.addWidget(createPlaneBtn)
        vlayout2.addLayout(hlay10)

        self.planeTable = qw.QTableWidget()
        self.planeTable.setColumnCount(2)
        self.planeTable.setHorizontalHeaderLabels(['curvility', 'name'])
        self.planeTable.setRowCount(0)
        self.planeTable.horizontalHeader().setStretchLastSection(True)
        self.planeTable.setSelectionMode(qw.QAbstractItemView.ExtendedSelection)
        self.planeTable.setColumnWidth(0, 50)
        vlayout2.addWidget(self.planeTable)


        hBox196 = qw.QHBoxLayout()
        self.checkCombie = qw.QCheckBox()
        self.checkCombie.setText('isCombieBorder')
        self.checkCombie.setChecked(True)
        self.checkCombie.setFixedWidth(120)
        hBox196.addWidget(self.checkCombie)
        
        updatePlaneBtn = qw.QPushButton('update plane position')
        updatePlaneBtn.setStyleSheet(Mstyle.QPushButton(kw='b'))
        #hBox196.addWidget(updatePlaneBtn)
        #hBox196.addStretch(1)
        #vlayout2.addLayout(hBox196)

        vlayout2.addStretch()

        self.typeTab.addTab(groupbox2, 'type2')

        # =======================================

        groupbox4 = qw.QGroupBox()
        groupbox4 .setStyleSheet(Mstyle.QGroupBox())
        vlayout4 = qw.QVBoxLayout(groupbox4)
        vlayout4.setAlignment(QtCore.Qt.AlignCenter)

        noLab = qw.QLabel()
        noLab.setText('comming soon')
        vlayout4.addWidget(noLab)

        self.typeTab.addTab(groupbox4, 'type3')


        vlay.addWidget(self.typeTab)

        previewBtn = qw.QPushButton('preview')
        previewBtn.setStyleSheet(Mstyle.QPushButton(kw='b'))
        vlay.addWidget(previewBtn)

        vlay.addStretch()


        '''
        stepSlider.sliderMoved.connect(self.slidermoveFn)
        '''
        addBtnA.clicked.connect(self.pickBtnFn)
        addBtnB.clicked.connect(self.pickBtnFn)
        createMidPlaneBtn.clicked.connect(self.fastBtnFn)
        #selMidPlaneBtn.clicked.connect(self.refreshAreaFn)

        createPlaneBtn.clicked.connect(self.createPlaneBtnFn)

        previewBtn.clicked.connect(self.previewBtnFn)

        self.checkCombie.toggled.connect(self.checkCombieFn)

        self.spinB.valueChanged.connect(self.refreshAreaFn)

        selA.clicked.connect(self.resetPointFn)
        selB.clicked.connect(self.resetPointFn)
示例#17
0
    def setup_ui(self):
        # Set up basic dimensions and central layout
        self.program_title = 'NoteTaker'
        self.resize(850, 600)
        self.centralwidget = QtWidgets.QWidget(self)
        self.verticalLayout = QtWidgets.QVBoxLayout(self.centralwidget)

        # Define database configuration widget
        self.dbconfigFrame = QtWidgets.QFrame(self.centralwidget)
        # self.dbconfigFrame.setMaximumSize(QtCore.QSize(16777215, 55))
        self.dbconfigHorizontalLayout = QtWidgets.QHBoxLayout(
            self.dbconfigFrame)
        self.dbconfigHorizontalLayout.setContentsMargins(0, -1, -1, -1)
        self.dbconfigLabel = QtWidgets.QLabel(self.dbconfigFrame)
        self.dbconfigLabel.setText('Notes Database Path')
        self.dbconfigHorizontalLayout.addWidget(self.dbconfigLabel)
        self.dbconfigLineEdit = QtWidgets.QLineEdit(self.dbconfigFrame)
        self.dbconfigComboBox = QtWidgets.QComboBox(self.dbconfigFrame)
        self.dbconfigComboBox.setEditable(True)
        self.dbconfigComboBox.setSizePolicy(QtWidgets.QSizePolicy.Expanding,
                                            QtWidgets.QSizePolicy.Preferred)
        self.dbconfigComboBox.setLineEdit(self.dbconfigLineEdit)
        # TODO: Remember database from previous session and open automatically
        # TODO: Make this field an editable dropdown that remembers up to N previous databases
        self.dbconfigLineEdit.setText('notes.db')
        # Set up data model
        self.sourceTableModel = NoteTakerTableModel(
            self.db_type, self.dbconfigLineEdit.text())
        self.current_db = self.dbconfigLineEdit.text()
        self.proxyTableModel = NoteTakerSortFilterProxyModel()
        self.proxyTableModel.setSourceModel(self.sourceTableModel)
        # TODO: Add dropdown to select db type (or detect automatically)
        # self.dbconfigHorizontalLayout.addWidget(self.dbconfigLineEdit)
        self.dbconfigHorizontalLayout.addWidget(self.dbconfigComboBox)
        self.browseDatabaseButton = QtWidgets.QPushButton(self.dbconfigFrame)
        self.browseDatabaseButton.setText('Browse for database')
        self.browseDatabaseButton.clicked.connect(self.browse_db_connection)
        self.dbconfigHorizontalLayout.addWidget(self.browseDatabaseButton)
        self.loadDatabaseButton = QtWidgets.QPushButton(self.dbconfigFrame)
        self.loadDatabaseButton.setText('Load selected database')
        self.loadDatabaseButton.clicked.connect(self.load_database)
        self.dbconfigHorizontalLayout.addWidget(self.loadDatabaseButton)
        self.verticalLayout.addWidget(self.dbconfigFrame)

        # Define text filter
        self.filterFrame = QtWidgets.QFrame(self.centralwidget)
        # self.filterFrame.setMaximumSize(QtCore.QSize(16777215, 55))
        self.filterHorizontalLayout = QtWidgets.QHBoxLayout(self.filterFrame)
        self.filterHorizontalLayout.setContentsMargins(0, -1, -1, -1)
        self.filterHorizontalLabel = QtWidgets.QLabel(self.filterFrame)
        self.filterHorizontalLabel.setText('Filter')
        self.filterHorizontalLayout.addWidget(self.filterHorizontalLabel)
        self.filterLineEdit = QtWidgets.QLineEdit(self.filterFrame)
        # TODO: Implement find-as-you-type to encompass date
        self.filterLineEdit.textChanged.connect(self.filter_view)
        self.filterHorizontalLayout.addWidget(self.filterLineEdit)
        self.verticalLayout.addWidget(self.filterFrame)

        # Define View and Edit windows
        self.splitter = QtWidgets.QSplitter(self.centralwidget)
        self.splitter.setOrientation(QtCore.Qt.Vertical)
        self.splitter.setHandleWidth(10)
        self.splitter.setChildrenCollapsible(False)
        self.tableView = QtWidgets.QTableView(self.splitter)
        self.tableView.setModel(self.proxyTableModel)
        self.tableView.setFont(
            QtGui.QFont('Courier New'))  # Probably not cross platform
        self.tableView.resizeColumnsToContents()
        self.tableView.setSortingEnabled(True)
        # TODO: Fix sorting (most recent at bottom)
        # __binding__ checks are to handle a caveat https://github.com/mottosso/Qt.py/blob/master/CAVEATS.md#qtwidgetsqheaderviewsetresizemode
        if __binding__ in ("PyQt4", "PySide"):
            self.tableView.horizontalHeader().setResizeMode(
                1, QtWidgets.QHeaderView.Stretch)
        else:
            self.tableView.horizontalHeader().setSectionResizeMode(
                1, QtWidgets.QHeaderView.Stretch)
        self.tableView.sortByColumn(0, QtCore.Qt.AscendingOrder)
        if __binding__ in ("PyQt4", "PySide"):
            self.tableView.verticalHeader().setResizeMode(
                QtWidgets.QHeaderView.ResizeToContents)
        else:
            self.tableView.verticalHeader().setSectionResizeMode(
                QtWidgets.QHeaderView.ResizeToContents)
        self.noteFrame = QtWidgets.QFrame(self.splitter)
        self.noteFrame.setFrameShape(QtWidgets.QFrame.StyledPanel)
        self.noteFrame.setFrameShadow(QtWidgets.QFrame.Raised)
        self.horizontalLayout = QtWidgets.QHBoxLayout(self.noteFrame)
        self.horizontalLayout.setContentsMargins(0, -1, -1, -1)
        self.textEdit = PlainTextEditWithAttachments(self.noteFrame)
        self.textEdit.setFont(
            QtGui.QFont('Courier New'))  # Probably not cross platform
        self.textEdit.viewport().setProperty(
            "cursor", QtGui.QCursor(QtCore.Qt.IBeamCursor))
        self.horizontalLayout.addWidget(self.textEdit)
        self.attachmentWidget = QtWidgets.QListWidget()
        self.attachmentWidget.hide()
        self.horizontalLayout.addWidget(self.attachmentWidget)
        self.commitButton = QtWidgets.QPushButton(self.noteFrame)
        self.commitButton.setText('Commit')
        self.commitButton.setStatusTip(
            'Click or press Control+Enter to commit this message to the database'
        )
        self.commitButton.clicked.connect(self.commit_new_note)
        QtWidgets.QShortcut(QtGui.QKeySequence('Ctrl+Return'), self,
                            self.commit_new_note)
        QtWidgets.QShortcut(QtGui.QKeySequence('Ctrl+Enter'), self,
                            self.commit_new_note)
        self.horizontalLayout.addWidget(self.commitButton)
        self.verticalLayout.addWidget(self.splitter)

        # Define statusbar and toolbar
        self.statusbar = QtWidgets.QStatusBar(self)
        self.setStatusBar(self.statusbar)

        # TODO: Allow user to create custom hotkey-able buttons to insert common text e.g. "Test complete. Pass"
        self.toolBar = QtWidgets.QToolBar(self)
        self.addToolBar(QtCore.Qt.TopToolBarArea, self.toolBar)

        # Define the menu
        self.menubar = QtWidgets.QMenuBar()
        self.menuFile = self.menubar.addMenu('&File')
        self.menuEdit = self.menubar.addMenu('&Edit')
        self.menuHelp = self.menubar.addMenu('&Help')
        self.setMenuBar(self.menubar)

        # File menu options
        self.actionLoad = QtWidgets.QAction(
            QtGui.QIcon.fromTheme("document-open"), '&Load Database', self)
        self.actionLoad.setShortcut('Ctrl+L')
        self.actionLoad.setStatusTip('Load a NoteTaker database')
        self.actionLoad.triggered.connect(self.browse_db_connection)

        self.actionExport = QtWidgets.QAction(
            QtGui.QIcon.fromTheme("document-save-as"), '&Export Notes', self)
        self.actionExport.setShortcut('Ctrl+S')
        self.actionExport.setStatusTip('Export notes')
        self.actionExport.triggered.connect(self.onExportClicked)

        self.actionExit = QtWidgets.QAction('&Exit', self)
        self.actionExit.setShortcut('Ctrl+Q')
        self.actionExit.setStatusTip('Exit application')
        self.actionExit.triggered.connect(self._exit)

        # Edit menu options
        self.actionPrefs = QtWidgets.QAction('&Preferences', self)
        self.actionPrefs.setShortcut('Ctrl+P')
        self.actionPrefs.setStatusTip('Edit preferences')
        # self.actioPrefs.triggered.connect(self.onPrefsClicked)

        self.userDialog = QtWidgets.QAction('&Change User', self)
        self.userDialog.setStatusTip('Change currently logged in user')
        self.userDialog.triggered.connect(self.user_dialog)

        # Help Menu options
        self.actionAbout = QtWidgets.QAction(
            QtGui.QIcon.fromTheme('system-help'), '&About', self)
        self.actionAbout.setStatusTip('Version and Copyright information')
        self.actionAbout.triggered.connect(self._about)

        self.menuFile.addAction(self.actionLoad)
        self.menuFile.addAction(self.actionExport)
        self.menuFile.addSeparator()
        self.menuFile.addAction(self.actionExit)
        self.menuHelp.addAction(self.actionAbout)
        self.menuEdit.addAction(self.actionPrefs)
        self.menuEdit.addAction(self.userDialog)
        self.menuHelp.addAction(self.actionAbout)
        self.menubar.addAction(self.menuFile.menuAction())
        self.menubar.addAction(self.menuEdit.menuAction())
        self.menubar.addAction(self.menuHelp.menuAction())

        self.setWindowTitle('{} - {} - {}'.format(self.program_title,
                                                  self.current_user,
                                                  self.current_db))

        self.setCentralWidget(self.centralwidget)
示例#18
0
    def _main(self):
        self.main = QtWidgets.QVBoxLayout()
        self.main.setObjectName('main')

        self.form = QtWidgets.QFormLayout()
        self.form.setContentsMargins(10, 15, 10, 5)
        self.form.setObjectName('form')

        msg_info = 'You didn\'t work for a long time.'
        msg_question = 'Would you like to stop Timers?'
        msg_stopped = (
            'Your Timers were stopped. Do you want to start them again?'
        )

        self.lbl_info = QtWidgets.QLabel(msg_info)
        self.lbl_info.setFont(self.font)
        self.lbl_info.setTextFormat(QtCore.Qt.RichText)
        self.lbl_info.setObjectName("lbl_info")
        self.lbl_info.setWordWrap(True)

        self.lbl_question = QtWidgets.QLabel(msg_question)
        self.lbl_question.setFont(self.font)
        self.lbl_question.setTextFormat(QtCore.Qt.RichText)
        self.lbl_question.setObjectName("lbl_question")
        self.lbl_question.setWordWrap(True)

        self.lbl_stopped = QtWidgets.QLabel(msg_stopped)
        self.lbl_stopped.setFont(self.font)
        self.lbl_stopped.setTextFormat(QtCore.Qt.RichText)
        self.lbl_stopped.setObjectName("lbl_stopped")
        self.lbl_stopped.setWordWrap(True)

        self.lbl_rest_time = QtWidgets.QLabel("")
        self.lbl_rest_time.setFont(self.font)
        self.lbl_rest_time.setTextFormat(QtCore.Qt.RichText)
        self.lbl_rest_time.setObjectName("lbl_rest_time")
        self.lbl_rest_time.setWordWrap(True)
        self.lbl_rest_time.setAlignment(QtCore.Qt.AlignCenter)

        self.form.addRow(self.lbl_info)
        self.form.addRow(self.lbl_question)
        self.form.addRow(self.lbl_stopped)
        self.form.addRow(self.lbl_rest_time)

        self.group_btn = QtWidgets.QHBoxLayout()
        self.group_btn.addStretch(1)
        self.group_btn.setObjectName("group_btn")

        self.btn_stop = QtWidgets.QPushButton("Stop timer")
        self.btn_stop.setToolTip('Stop\'s All timers')
        self.btn_stop.clicked.connect(self.stop_timer)

        self.btn_continue = QtWidgets.QPushButton("Continue")
        self.btn_continue.setToolTip('Timer won\'t stop')
        self.btn_continue.clicked.connect(self.continue_timer)

        self.btn_close = QtWidgets.QPushButton("Close")
        self.btn_close.setToolTip('Close window')
        self.btn_close.clicked.connect(self.close_widget)

        self.btn_restart = QtWidgets.QPushButton("Start timers")
        self.btn_restart.setToolTip('Timer will be started again')
        self.btn_restart.clicked.connect(self.restart_timer)

        self.group_btn.addWidget(self.btn_continue)
        self.group_btn.addWidget(self.btn_stop)
        self.group_btn.addWidget(self.btn_restart)
        self.group_btn.addWidget(self.btn_close)

        self.main.addLayout(self.form)
        self.main.addLayout(self.group_btn)

        return self.main
示例#19
0
    def __init__(self,
                 ui_name,
                 nodetype_display=None,
                 auto_name=None,
                 auto_comment=None,
                 completer_list=None,
                 parent=None):
        """Pop up window to gather name and comment from user about the preset

        Args:
            ui_name (str): name to give the ui
            auto_name (str, optional): should a name be already set
            auto_comment (str, optional): should a comment already be filled
            completer_list (list, optional): list of names for the completer
            parent (QtWidget, optional): Window to parent over
        """
        super(NameAndDescribePresetUI, self).__init__(parent=parent)
        self.setWindowTitle(ui_name)
        mainLayout = QtWidgets.QVBoxLayout()
        self.setLayout(mainLayout)
        self.result = []
        #  --------------------------------------------------------------------
        if nodetype_display:
            create_layout = QtWidgets.QVBoxLayout()
            msg = "Creating a preset for:"
            creating_label = QtWidgets.QLabel(msg)
            nodetype_label = QtWidgets.QLabel(nodetype_display)
            font = nodetype_label.font()
            font.setBold(True)
            nodetype_label.setFont(font)
            create_layout.addWidget(creating_label)
            create_layout.addWidget(nodetype_label)
            mainLayout.addLayout(create_layout)
        selectionLayout = QtWidgets.QHBoxLayout()
        selectionLabel = QtWidgets.QLabel("Give preset name:")
        self.preset_name_edit = QtWidgets.QLineEdit()
        self.preset_name_edit.setPlaceholderText("name")
        val = QtGui.QRegExpValidator(QtCore.QRegExp("[A-Za-z]+"))
        self.preset_name_edit.setValidator(val)
        if auto_name:
            self.preset_name_edit.setText(auto_name)

        if completer_list:
            com = QtWidgets.QCompleter(completer_list)
            self.preset_name_edit.setCompleter(com)

        selectionLayout.addWidget(selectionLabel)
        selectionLayout.addWidget(self.preset_name_edit)
        mainLayout.addLayout(selectionLayout)
        #  --------------------------------------------------------------------
        self.comment_widget = QtWidgets.QTextEdit()
        self.comment_widget.setPlaceholderText("Details on the preset.")
        mainLayout.addWidget(self.comment_widget)
        if auto_comment:
            self.comment_widget.setText(auto_comment)

        #  --------------------------------------------------------------------
        # buttonLayout = QtWidgets.QHBoxLayout()
        self.okButton = QtWidgets.QPushButton("Ok")
        self.okButton.clicked.connect(self.onOK)
        mainLayout.addWidget(self.okButton)
示例#20
0
    def __init__(self):
        super(Core_TestFlight, self).__init__()

        self.title = QtWidgets.QLabel("<h3>Test Flight</h3>")
        self.title.setAlignment(QtCore.Qt.AlignTop)
        self.title_path = QtWidgets.QLabel("path to files")
        self.path = QtWidgets.QLineEdit()
        self.path.setMinimumWidth(500)
        self.path.editingFinished.connect(self.onPathChanged)
        self.browse = QtWidgets.QPushButton("Browse")
        self.browse.clicked.connect(self.browseDir)
        self.title_file = QtWidgets.QLabel("file to test")
        self.file = QtWidgets.QComboBox()
        self.file.currentIndexChanged.connect(self.onFileChanged)
        self.title_func = QtWidgets.QLabel("function to call")
        self.func = QtWidgets.QLineEdit()
        self.func.setPlaceholderText(
            "a single-line expression to evaluate. ie. 'foo()' or 'print foo()'"
        )
        self.func.setToolTip("a single-line expression to evaluate")
        self.func.editingFinished.connect(self.make_callable)
        self.test = QtWidgets.QPushButton('Take Off')
        self.test.clicked.connect(self.onTakeoff)
        self.reload = QtWidgets.QPushButton('Reload')
        self.reload.clicked.connect(self.onReload)
        self.reload.setMaximumWidth(100)

        self.master_layout = QtWidgets.QVBoxLayout()

        self.file_layout = QtWidgets.QGridLayout()
        self.file_layout.addWidget(self.title_path, 1, 0)
        self.file_layout.addWidget(self.path, 1, 1)
        self.file_layout.addWidget(self.browse, 1, 2)
        self.file_layout.addWidget(self.title_file, 2, 0)
        self.file_layout.addWidget(self.file, 2, 1)
        self.file_layout.addWidget(self.title_func, 3, 0)
        self.file_layout.addWidget(self.func, 3, 1)

        self.button_layout = QtWidgets.QHBoxLayout()
        self.button_layout.setContentsMargins(0, 0, 0, 0)
        self.button_layout.addWidget(self.test)
        self.button_layout.addWidget(self.reload)

        self.master_layout.addWidget(self.title)
        self.master_layout.addLayout(self.file_layout)
        self.master_layout.addSpacing(10)
        self.master_layout.addLayout(self.button_layout)
        self.master_layout.addStretch(1)

        self.setLayout(self.master_layout)
        self.setWindowTitle(__TITLE__)
        self.setDefault()
示例#21
0
from qconcurrency import QApplication
from qconcurrency.threading_ import SoloThreadedTask
from Qt import QtWidgets, QtCore
import six
import supercli.logging
import time
supercli.logging.SetLog(lv=10)


with QApplication():
    wid = QtWidgets.QPushButton('close me')
    wid.show()

    queue_finished = six.moves.queue.Queue()
    threadpool     = QtCore.QThreadPool()
    threadpool.setMaxThreadCount(3)

    def _callback( queue_finished, signalmgr=None ):
        for i in range(30):
            signalmgr.handle_if_abort()
            time.sleep(0.05)
        queue_finished.put(True)
        print('finished')


    task = SoloThreadedTask(
        callback = _callback,
    )
    task.start( queue_finished=queue_finished, threadpool=threadpool )
    task.start( queue_finished=queue_finished, threadpool=threadpool )
    task.start( queue_finished=queue_finished, threadpool=threadpool )
示例#22
0
class EventLoop( object ) :

	__RunStyle = IECore.Enum.create( "Normal", "PumpThread", "AlreadyRunning", "Houdini" )

	## Creates a new EventLoop. Note that if you are creating the primary
	# EventLoop for an application then you should use mainEventLoop() instead.
	def __init__( self, __qtEventLoop=None ) :

		if __qtEventLoop is None :
			if self.__mainEventLoop is None or self.__mainEventLoop.__startCount==0 :
				raise Exception( "Main event loop is not running - perhaps you should use EventLoop.mainEventLoop()?" )
			self.__qtEventLoop = QtCore.QEventLoop()
		else :
			self.__qtEventLoop = __qtEventLoop

		self.__runStyle = self.__RunStyle.Normal
		if isinstance( self.__qtEventLoop, QtWidgets.QApplication ) :
			try :
				import maya.OpenMaya
				if maya.OpenMaya.MGlobal.apiVersion() < 201100 :
					self.__runStyle = self.__RunStyle.PumpThread
				else :
					self.__runStyle = self.__RunStyle.AlreadyRunning
			except ImportError :
				pass

			try :
				import hou
				if hou.applicationVersion()[0] < 14 :
					self.__runStyle = self.__RunStyle.Houdini
				else :
					self.__runStyle = self.__RunStyle.AlreadyRunning
			except ImportError :
				pass

			try :
				import nuke
				self.__runStyle = self.__RunStyle.AlreadyRunning
			except ImportError :
				pass

		self.__startCount = 0
		self.__pumpThread = None
		self.__houdiniCallback = None

	## Starts the event loop, passing control to the UI code. This function returns
	# when the corresponding stop() method is called. See documentation for
	# mainEventLoop() for exceptions to this rule.
	def start( self ) :

		self.__startCount += 1

		if self.__runStyle == self.__RunStyle.Normal :
			assert( self.__startCount == 1 )
			self.__qtEventLoop.exec_()
		elif self.__runStyle == self.__RunStyle.PumpThread :
			if self.__pumpThread is None :
				self.__pumpThread = threading.Thread( target = self.__pumpThreadFn )
				self.__pumpThread.start()
		elif self.__runStyle == self.__RunStyle.Houdini :
			if self.__houdiniCallback is None :
				import hou
				hou.ui.addEventLoopCallback( functools.partial( self.__pump, 5 ) )
				self.__houdiniCallback = hou.ui.eventLoopCallbacks()[-1]
		else :
			# RunStyle.AlreadyRunning
			# host application is using qt natively, no need to do anything.
			pass

	## Stops the event loop last started using start().
	def stop( self ) :

		assert( self.__startCount > 0 )

		if self.__runStyle == self.__RunStyle.Normal :
			assert( self.__startCount == 1 )
			self.__qtEventLoop.exit()
		elif self.__runStyle == self.__RunStyle.PumpThread :
			## \todo Should we try to stop the pump thread
			# when self.__startCount hits 0? Right not we're
			# just keeping it running on the assumption we'll
			# need it again soon.
			pass
		elif self.__runStyle == self.__RunStyle.Houdini :
			if self.__startCount == 1 and self.__houdiniCallback :
				import hou
				hou.ui.removeEventLoopCallback( self.__houdiniCallback )
				self.__houdiniCallback = None
		else :
			# RunStyle.AlreadyRunning
			pass

		self.__startCount -= 1

	## Returns true if this event loop is currently running.
	def running( self ) :

		return self.__startCount > 0

	# if we're running embedded in an application which already uses qt (like maya 2011 or later)
	# then there'll already be an application, which we'll share. if not we'll make our own.
	if QtWidgets.QApplication.instance() :
		__qtApplication = QtWidgets.QApplication.instance()
	else :
		# set the style explicitly so we don't inherit one from the desktop
		# environment, which could mess with our own style (on gnome for instance,
		# our icons can come out the wrong size).
		QtWidgets.QApplication.setStyle( "plastique" )
		__qtApplication = QtWidgets.QApplication( [ "gaffer" ] )

	__mainEventLoop = None
	## Returns the main event loop for the application. This should always
	# be started before running any other nested event loops. In the standalone
	# Gaffer applications, the main event loop acts like any other, but when
	# GafferUI is embedded in another application (like Maya) it behaves slightly
	# differently. In this case, the start() method returns immediately so that
	# the GafferUI event loop may be interleaved with the event loop of the host
	# application. Additionally, the start() method may also be called multiple
	# times to allow several GafferUI-based applications to run in the same host.
	# The main event loop will therefore only cease running when the number of
	# calls to stop() matches the number of calls to start().
	@classmethod
	def mainEventLoop( cls ) :

		if cls.__mainEventLoop is None :
			cls.__mainEventLoop = cls( cls.__qtApplication )

		return cls.__mainEventLoop

	__idleCallbacks = []
	__idleTimer = None
	## Adds a function to be called when the event loop is idle (has no events
	# remaining to be processed). If callback returns False then it will be removed
	# automatically after running, if it returns True it will be called again until
	# it returns False, or until removeIdleCallback() is called.
	## \todo This should probably be replaced with an idleSignal() like the one we
	# have in GafferUI.Gadget.
	@classmethod
	def addIdleCallback( cls, callback ) :

		assert( callback not in cls.__idleCallbacks )
		cls.__idleCallbacks.append( callback )
		cls.__ensureIdleTimer()

	## Removes an idle callback previously created with addIdleCallback().
	@classmethod
	def removeIdleCallback( cls, callback ) :

		cls.__idleCallbacks.remove( callback )

	## Convenience method to introduce a delay on the mainEventLoop().
	@classmethod
	def waitForIdle( cls, count = 1000 ) :

		cls.__idleCount = 0

		def f() :

			cls.__idleCount += 1

			if cls.__idleCount >= count :
				EventLoop.mainEventLoop().stop()
				return False

			return True

		EventLoop.addIdleCallback( f )
		EventLoop.mainEventLoop().start()

	## Widgets may only be manipulated on the thread where mainEventLoop() is running. It
	# is common to want to perform some background processing on a secondary thread, and
	# to update the UI during processing or upon completion. This function can be used from
	# such a secondary thread to queue a callable to be called on the main thread. If called
	# from the main thread, the callable is called immediately.
	@classmethod
	def executeOnUIThread( cls, callable, waitForResult=False ) :

		if QtCore.QThread.currentThread() == cls.__qtApplication.thread() :
			# Already on the UI thread - just do it.
			return callable()

		resultCondition = threading.Condition() if waitForResult else None

		# we only use a weakref here, because we don't want to be keeping the object
		# alive from this thread, and hence deleting it from this thread. instead it
		# is deleted in _UIThreadExecutor.event().
		uiThreadExecutor = weakref.ref( _UIThreadExecutor( callable, resultCondition ) )
		uiThreadExecutor().moveToThread( cls.__qtApplication.thread() )

		if resultCondition is not None :
			resultCondition.acquire()
			cls.__qtApplication.postEvent( uiThreadExecutor(), QtCore.QEvent( QtCore.QEvent.Type( _UIThreadExecutor.executeEventType ) ) )
			resultCondition.wait()
			resultCondition.release()
			return resultCondition.resultValue
		else :
			cls.__qtApplication.postEvent( uiThreadExecutor(), QtCore.QEvent( QtCore.QEvent.Type( _UIThreadExecutor.executeEventType ) ) )
			return None

	@classmethod
	def __ensureIdleTimer( cls ) :

		assert( QtCore.QThread.currentThread() == EventLoop.__qtApplication.thread() )

		if cls.__idleTimer is None :
			cls.__idleTimer = QtCore.QTimer( cls.__qtApplication )
			cls.__idleTimer.timeout.connect( cls.__qtIdleCallback )

		if not cls.__idleTimer.isActive() :
			cls.__idleTimer.start()

	# This is a staticmethod rather than a classmethod because PySide 1.0.5
	# doesn't support classmethods as slots.
	@staticmethod
	def __qtIdleCallback() :

		assert( QtCore.QThread.currentThread() == EventLoop.__qtApplication.thread() )

		GafferUI.Gadget.idleSignal()()

		for c in EventLoop.__idleCallbacks[:] : # slice takes copy, so we can remove during iteration
			try :
				if not c() :
					EventLoop.__idleCallbacks.remove( c )
			except Exception as e :
				# if the callback throws then we remove it anyway, because
				# we don't want to keep invoking the same error over and over.
				EventLoop.__idleCallbacks.remove( c )
				# report the error
				IECore.msg( IECore.Msg.Level.Error, "EventLoop.__qtIdleCallback", "".join( traceback.format_exc( e ) ) )

		if len( EventLoop.__idleCallbacks )==0 and GafferUI.Gadget.idleSignal().empty() :
			EventLoop.__idleTimer.stop()

	@classmethod
	def _gadgetIdleSignalAccessed( cls ) :

		# It would be an error to access the idle signal from anything but the main
		# thread, because it would imply multiple threads fighting over the same signal.
		assert( QtCore.QThread.currentThread() == EventLoop.__qtApplication.thread() )

		cls.__ensureIdleTimer()

	def __pumpThreadFn( self ) :

		import maya.utils

		while 1 :
			time.sleep( 0.01 )
			maya.utils.executeDeferred( self.__pump )

	def __pump( self, thrusts=1 ) :

		for thrust in range( 0, thrusts ) :
			self.__qtEventLoop.processEvents()
示例#23
0
    def __init__(self, parent, **kwargs):
        """
        Initialises the widget and adds it to the parent widget

        args:
            parent, required, pass your main widget "self"
        kwargs:

            numColumns,     (int), The number of columns that you need to have in the table,
            columnWidths,   ([int,int..]), list of column widths, set to 0 to set column to stretch to available size,
            columnsVisible, ([bool,bool..]), sets each columns visibility,
            height,         (int), height of the widget,
            width,          (int), width of the widget,
            headers,        ([str,str..]), the name for each column, shown in the header row,
            alternateRows,  (bool), to alternate the rows background colour, set this to True
            setWidgetBG,    (bool), to force the background colour, set this to True, **OVERRIDES** alternateRows
            columnAlignment,([str,str..]), side to align each column: [left, right, top, bottom], defaults to left
            disableHeaderSortText, (bool), if set will remove the "(a-z)" or "(z-a)" from the header text!
            rowBorder,      (bool), if set will add a border around each row, default is True
        
        """
        QtWid.QScrollArea.__init__(self, parent)
        self.rowIndexs = []
        self.currentRowIndex = 0
        self.rows = {}
        self.cellWidgets = {}
        self.rowVisibility = {}
        self.parent = parent
        self.wdth = kwargs.get("width", 300)
        self.hght = kwargs.get("height", 300)
        self.numColumns = kwargs.get("numColumns", 1)
        self.altRows = kwargs.get("alternateRows", False)
        self.rowBorder = kwargs.get("rowBorder", True)
        self.setWidgetBG = kwargs.get("setWidgetBG", True)
        self.columnWidths = kwargs.get("columnWidths",
                                       [0 for x in range(0, self.numColumns)])
        self.columnAlignment = kwargs.get(
            "columnAlignment", ["left" for x in range(0, self.numColumns)])
        self.columnsVisible = kwargs.get(
            "columnsVisible", [True for x in range(0, self.numColumns)])
        self.headers = kwargs.get("headers", None)
        self.disableHeaderSortText = kwargs.get("disableHeaderSortText", None)
        self.QValueFunctionDict = {
            "QToolButton": ".text()",
            "QPushButton": ".text()",
            "QLabel": ".text()",
            "QLinEdit": ".text()",
            "QSpinBox": ".value()",
            "QSlider": ".value()",
            "QComboBox": ".currentText()",
        }
        self.mainWidget = QtWid.QWidget()
        self.setWidget(self.mainWidget)
        sizePolicy = QtWid.QSizePolicy(QtWid.QSizePolicy.Minimum,
                                       QtWid.QSizePolicy.Fixed)
        self.mainWidget.setSizePolicy(sizePolicy)
        self.setSizePolicy(QtWid.QSizePolicy.Minimum,
                           QtWid.QSizePolicy.Minimum)
        self.setAutoFillBackground(False)
        self.setVerticalScrollBarPolicy(QtCore.Qt.ScrollBarAlwaysOn)
        self.setHorizontalScrollBarPolicy(QtCore.Qt.ScrollBarAlwaysOff)
        self.sLayout = QtWid.QVBoxLayout(self.widget())
        self.mLayout = QtWid.QVBoxLayout()
        self.sLayout.setContentsMargins(2, 2, 2, 2)
        self.widget().setObjectName("scrollWidgetBG")
        self.setGeometry(0, 0, self.wdth, self.hght)
        self.setObjectName("scrollWidgetBG")
        self.sortData = {}
        self.sorted = False
        self.AlignmentDict = {
            "left": QtCore.Qt.AlignLeft | QtCore.Qt.AlignVCenter,
            "right": QtCore.Qt.AlignRight | QtCore.Qt.AlignVCenter,
            "center": QtCore.Qt.AlignCenter | QtCore.Qt.AlignVCenter,
            "top": QtCore.Qt.AlignTop | QtCore.Qt.AlignVCenter,
            "bottom": QtCore.Qt.AlignBottom | QtCore.Qt.AlignVCenter,
        }
        self.setWidgetResizable(True)
        if self.headers:
            self.headerFrame = QtWid.QFrame(self)
            self.headerFrame.setFrameShape(QtWid.QFrame.StyledPanel)
            self.headerFrame.setFrameShadow(QtWid.QFrame.Raised)
            self.headerRow = QtWid.QHBoxLayout(self.headerFrame)
            self.headerRow.setSpacing(0)
            self.headerItems = {}
            self.mLayout.addLayout(self.headerRow, QtCore.Qt.AlignTop)
            self.headerRow.setContentsMargins(0, 0, 16, 0)
            self.mLayout.setContentsMargins(0, 23, 0, 0)
            self.setHorizontalHeaderLabels(self.headers)
        else:
            self.mLayout.setContentsMargins(0, 0, 0, 0)
        self.mLayout.setSpacing(0)

        self.sLayout.addLayout(self.mLayout)
        self.sLayout.addStretch(1)
示例#24
0
    def setupUi(self, Form):
        Form.setObjectName(_fromUtf8("Form"))
        Form.resize(498, 189)
        Form.setMaximumSize(QtCore.QSize(16777215, 195))
        self.mainLayout = QtGui.QVBoxLayout(Form)
        # self.mainLayout.setMargin(2)
        self.mainLayout.setSpacing(2)
        self.mainLayout.setObjectName(_fromUtf8("mainLayout"))
        self.delete_this = QtGui.QPushButton(Form)
        sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Minimum,
                                       QtGui.QSizePolicy.Fixed)
        sizePolicy.setHorizontalStretch(25)
        sizePolicy.setVerticalStretch(25)
        sizePolicy.setHeightForWidth(
            self.delete_this.sizePolicy().hasHeightForWidth())
        self.delete_this.setSizePolicy(sizePolicy)
        self.delete_this.setMinimumSize(QtCore.QSize(25, 25))
        self.delete_this.setMaximumSize(QtCore.QSize(25, 25))
        self.delete_this.setText(_fromUtf8(""))
        self.delete_this.setObjectName(_fromUtf8("delete_this"))
        self.mainLayout.addWidget(self.delete_this)
        self.gridLayout = QtGui.QGridLayout()
        self.gridLayout.setObjectName(_fromUtf8("gridLayout"))
        self.horizontalLayout = QtGui.QHBoxLayout()
        self.horizontalLayout.setObjectName(_fromUtf8("horizontalLayout"))
        self.label = QtGui.QLabel(Form)
        self.label.setObjectName(_fromUtf8("label"))
        self.horizontalLayout.addWidget(self.label)
        self.attr_name = QtGui.QLineEdit(Form)
        self.attr_name.setMaximumSize(QtCore.QSize(270, 16777215))
        self.attr_name.setObjectName(_fromUtf8("attr_name"))
        self.horizontalLayout.addWidget(self.attr_name)
        self.gridLayout.addLayout(self.horizontalLayout, 0, 0, 1, 2)
        self.label_10 = QtGui.QLabel(Form)
        self.label_10.setObjectName(_fromUtf8("label_10"))
        self.gridLayout.addWidget(self.label_10, 1, 0, 1, 1)
        self.horizontalLayout_5 = QtGui.QHBoxLayout()
        self.horizontalLayout_5.setObjectName(_fromUtf8("horizontalLayout_5"))
        self.variation = QtGui.QRadioButton(Form)
        self.variation.setChecked(True)
        self.variation.setObjectName(_fromUtf8("variation"))
        self.horizontalLayout_5.addWidget(self.variation)
        self.uniform = QtGui.QRadioButton(Form)
        self.uniform.setObjectName(_fromUtf8("uniform"))
        self.horizontalLayout_5.addWidget(self.uniform)
        self.type = QtGui.QComboBox(Form)
        self.type.setObjectName(_fromUtf8("type"))
        self.type.addItem(_fromUtf8(""))
        self.type.addItem(_fromUtf8(""))
        self.horizontalLayout_5.addWidget(self.type)
        spacerItem = QtGui.QSpacerItem(40, 20, QtGui.QSizePolicy.Expanding,
                                       QtGui.QSizePolicy.Minimum)
        self.horizontalLayout_5.addItem(spacerItem)
        self.gridLayout.addLayout(self.horizontalLayout_5, 1, 1, 1, 1)
        self.label_2 = QtGui.QLabel(Form)
        self.label_2.setObjectName(_fromUtf8("label_2"))
        self.gridLayout.addWidget(self.label_2, 2, 0, 1, 1)
        self.horizontalLayout_3 = QtGui.QHBoxLayout()
        self.horizontalLayout_3.setObjectName(_fromUtf8("horizontalLayout_3"))
        self.label_3 = QtGui.QLabel(Form)
        self.label_3.setObjectName(_fromUtf8("label_3"))
        self.horizontalLayout_3.addWidget(self.label_3)
        self.min_x_value = QtGui.QDoubleSpinBox(Form)
        self.min_x_value.setSingleStep(0.1)
        self.min_x_value.setObjectName(_fromUtf8("min_x_value"))
        self.horizontalLayout_3.addWidget(self.min_x_value)
        spacerItem1 = QtGui.QSpacerItem(40, 20, QtGui.QSizePolicy.Expanding,
                                        QtGui.QSizePolicy.Minimum)
        self.horizontalLayout_3.addItem(spacerItem1)
        self.label_7 = QtGui.QLabel(Form)
        self.label_7.setObjectName(_fromUtf8("label_7"))
        self.horizontalLayout_3.addWidget(self.label_7)
        self.min_y_value = QtGui.QDoubleSpinBox(Form)
        self.min_y_value.setSingleStep(0.1)
        self.min_y_value.setObjectName(_fromUtf8("min_y_value"))
        self.horizontalLayout_3.addWidget(self.min_y_value)
        spacerItem2 = QtGui.QSpacerItem(40, 20, QtGui.QSizePolicy.Expanding,
                                        QtGui.QSizePolicy.Minimum)
        self.horizontalLayout_3.addItem(spacerItem2)
        self.label_8 = QtGui.QLabel(Form)
        self.label_8.setObjectName(_fromUtf8("label_8"))
        self.horizontalLayout_3.addWidget(self.label_8)
        self.min_z_value = QtGui.QDoubleSpinBox(Form)
        self.min_z_value.setSingleStep(0.1)
        self.min_z_value.setObjectName(_fromUtf8("min_z_value"))
        self.horizontalLayout_3.addWidget(self.min_z_value)
        self.gridLayout.addLayout(self.horizontalLayout_3, 2, 1, 1, 1)
        self.horizontalLayout_4 = QtGui.QHBoxLayout()
        self.horizontalLayout_4.setObjectName(_fromUtf8("horizontalLayout_4"))
        self.label_4 = QtGui.QLabel(Form)
        self.label_4.setObjectName(_fromUtf8("label_4"))
        self.horizontalLayout_4.addWidget(self.label_4)
        self.max_x_value = QtGui.QDoubleSpinBox(Form)
        self.max_x_value.setSingleStep(0.1)
        self.max_x_value.setProperty("value", 1.0)
        self.max_x_value.setObjectName(_fromUtf8("max_x_value"))
        self.horizontalLayout_4.addWidget(self.max_x_value)
        spacerItem3 = QtGui.QSpacerItem(40, 20, QtGui.QSizePolicy.Expanding,
                                        QtGui.QSizePolicy.Minimum)
        self.horizontalLayout_4.addItem(spacerItem3)
        self.label_6 = QtGui.QLabel(Form)
        self.label_6.setObjectName(_fromUtf8("label_6"))
        self.horizontalLayout_4.addWidget(self.label_6)
        self.max_y_value = QtGui.QDoubleSpinBox(Form)
        self.max_y_value.setSingleStep(0.1)
        self.max_y_value.setProperty("value", 1.0)
        self.max_y_value.setObjectName(_fromUtf8("max_y_value"))
        self.horizontalLayout_4.addWidget(self.max_y_value)
        spacerItem4 = QtGui.QSpacerItem(40, 20, QtGui.QSizePolicy.Expanding,
                                        QtGui.QSizePolicy.Minimum)
        self.horizontalLayout_4.addItem(spacerItem4)
        self.label_9 = QtGui.QLabel(Form)
        self.label_9.setObjectName(_fromUtf8("label_9"))
        self.horizontalLayout_4.addWidget(self.label_9)
        self.max_z_value = QtGui.QDoubleSpinBox(Form)
        self.max_z_value.setSingleStep(0.1)
        self.max_z_value.setProperty("value", 1.0)
        self.max_z_value.setObjectName(_fromUtf8("max_z_value"))
        self.horizontalLayout_4.addWidget(self.max_z_value)
        self.gridLayout.addLayout(self.horizontalLayout_4, 3, 1, 1, 1)
        self.mainLayout.addLayout(self.gridLayout)
        self.horizontalLayout_2 = QtGui.QHBoxLayout()
        self.horizontalLayout_2.setObjectName(_fromUtf8("horizontalLayout_2"))
        self.label_5 = QtGui.QLabel(Form)
        self.label_5.setObjectName(_fromUtf8("label_5"))
        self.horizontalLayout_2.addWidget(self.label_5)
        self.primvar_node_name = QtGui.QLineEdit(Form)
        self.primvar_node_name.setMinimumSize(QtCore.QSize(110, 0))
        self.primvar_node_name.setObjectName(_fromUtf8("primvar_node_name"))
        self.horizontalLayout_2.addWidget(self.primvar_node_name)
        self.get_node_name = QtGui.QPushButton(Form)
        self.get_node_name.setObjectName(_fromUtf8("get_node_name"))
        self.horizontalLayout_2.addWidget(self.get_node_name)
        self.create_node = QtGui.QPushButton(Form)
        self.create_node.setObjectName(_fromUtf8("create_node"))
        self.horizontalLayout_2.addWidget(self.create_node)
        self.mainLayout.addLayout(self.horizontalLayout_2)

        self.retranslateUi(Form)
        QtCore.QMetaObject.connectSlotsByName(Form)
示例#25
0
    def custom_context_menu(self, pos):
        """Builds context menu to act upon right clicked layer.
        """
        index = self.indexAt(pos)
        layer = index.internalPointer()
        menu = QtWidgets.QMenu(self)
        if not layer:
            menu.addAction(self.actions.save_all_layers_action)
            menu.popup(QtGui.QCursor.pos())
            return
        stage_model = self.model().stage_model

        self.actions.save_layer_action.setData(layer)
        menu.addAction(self.actions.save_layer_action)
        self.actions.save_layer_as_action.setData(layer)
        menu.addAction(self.actions.save_layer_as_action)
        menu.addAction(self.actions.save_all_layers_action)
        if layer != stage_model.top_layer:
            self.actions.open_source_action.setData(layer)
            menu.addAction(self.actions.open_source_action)
            self.actions.remove_layer_action.setData(layer)
            menu.addAction(self.actions.remove_layer_action)
        menu.addSeparator()
        self.actions.change_color_action.setData(layer)
        menu.addAction(self.actions.change_color_action)

        def start_edit_alias():
            alias_idx = self.model().index(index.row(),
                                           LayerModel.ALIAS_COLUMN,
                                           index.parent())
            self.edit(alias_idx)

        menu.addAction("Edit Alias", start_edit_alias)

        if layer != stage_model.target_layer:
            layer_path = stage_model.get_layer_path(layer)

            def set_target_layer():
                stage_model.set_target_layer(layer_path)

            menu.addAction("Make Target Layer", set_target_layer)

        if layer != stage_model.display_layer:

            def set_disp_layer():
                stage_model.set_display_layer(layer)

            menu.addAction("Make Display Layer", set_disp_layer)

        self.actions.solo_layer_action.setData(layer)
        soloed = layer.get_soloed()
        text = 'Un-Solo' if soloed else 'Solo'
        menu.addAction(text, self.actions.solo_layer_action.trigger)

        self.actions.mute_layer_action.setData(layer)
        muted = layer.get_muted()
        text = 'Un-Mute' if muted else 'Mute'
        menu.addAction(text, self.actions.mute_layer_action.trigger)

        menu.addSeparator()
        self.actions.new_layer_above_action.setData(layer)
        menu.addAction(self.actions.new_layer_above_action)
        self.actions.new_layer_below_action.setData(layer)
        menu.addAction(self.actions.new_layer_below_action)
        self.actions.ref_layer_above_action.setData(layer)
        menu.addAction(self.actions.ref_layer_above_action)
        self.actions.ref_layer_below_action.setData(layer)
        menu.addAction(self.actions.ref_layer_below_action)
        menu.addSeparator()
        builtins_menu = QtWidgets.QMenu('Reference Builtin Graph')
        nxt_editor.main_window.populate_builtins_menu(
            qmenu=builtins_menu, main_window=self.actions.main_window)
        menu.addMenu(builtins_menu)
        menu.popup(QtGui.QCursor.pos())
示例#26
0
    def __init__(self, parent=None):
        QtWidgets.QSystemTrayIcon.__init__(self, parent)
        # self.activated.connect(self.showMainWidget)
        self.setIcon(QtGui.QIcon(Tank().get_img_path('software/default')))

        self.parent = parent

        Tank().init_os()
        self.data = Tank().data
        self.user = Tank().user
        self.project_data = Tank().data_project

        menu = QtWidgets.QMenu()
        menu.setStyleSheet(self.data['script'][TITLE]['style'])

        # ADMIN UI
        if True: # self.user.is_admin:
            adminMenu = QtWidgets.QMenu('Admin')
            adminMenu.setStyleSheet(self.data['script'][TITLE]['style'])
            menu.addMenu(adminMenu)

            menuItem = adminMenu.addAction(QtGui.QIcon(Tank().get_img_path('btn/btn_folder')), 'Open Project Data')
            menuItem.triggered.connect(self.press_btnOpenProjectLog)
            menuItem = adminMenu.addAction(QtGui.QIcon(Tank().get_img_path('btn/btn_folder')), 'Open User Data')
            menuItem.triggered.connect(self.press_btnOpenLocalLog)

            menu.addSeparator()

        menuItem = menu.addAction(QtGui.QIcon(Tank().get_img_path('user/' + self.user.id)), self.user.id)
        menuItem.triggered.connect(self.press_btnShowUserData)

        menuItem = menu.addAction(QtGui.QIcon(Tank().get_img_path('btn/btn_folder')), Tank().data_project['name'])
        menuItem.triggered.connect(self.press_btnOpenProjectPath)

        menu.addSeparator()

        subMenu = QtWidgets.QMenu('Software')
        subMenu.setStyleSheet(self.data['script'][TITLE]['style'])
        menu.addMenu(subMenu)

        for soft, soft_func in self.data['script'][TITLE]['SOFTWARE'].items():
            menuItem = subMenu.addAction(QtGui.QIcon(Tank().get_img_path('software/' + soft)), soft.title())
            menuItem.triggered.connect(eval(soft_func))

        menu.addSeparator()

        menuItem = menu.addAction(QtGui.QIcon(Tank().get_img_path('btn/btn_folder_get')), 'Load')
        menuItem.triggered.connect(self.press_btnLoad)

        menu.addSeparator()

        menuItem = menu.addAction(QtGui.QIcon(Tank().get_img_path('btn/btn_report')), 'Report')
        menuItem.triggered.connect(self.press_btnReport)

        menuItem = menu.addAction(QtGui.QIcon(Tank().get_img_path('btn/btn_help')), 'Help')
        menuItem.triggered.connect(self.press_btnHelp)

        menu.addSeparator()

        menuItem = menu.addAction(QtGui.QIcon(Tank().get_img_path('btn/btn_denial')), 'Quit')
        menuItem.triggered.connect(self.press_closeStartup)

        self.setContextMenu(menu)
示例#27
0
            offs_x = x * width
            offs_y = (1 - y) * height

            if self._selected_point and self._selected_point == cv_index:
                painter.setPen(QtGui.QColor(255, 0, 0))
            else:
                painter.setPen(QtGui.QColor(100, 100, 100))
            painter.drawRect(offs_x - self._cv_point_size,
                             offs_y - self._cv_point_size,
                             2 * self._cv_point_size, 2 * self._cv_point_size)

        # Draw selected value
        if self._drag_point:
            painter.setBrush(QtGui.QColor(200, 200, 200))
            painter.setPen(QtGui.QColor(200, 200, 200))
            offs_x = max(0, min(width + 10, self._drag_value * width - 19))
            painter.drawText(
                offs_x + 7, height - 20,
                "{:.2f} , {:.2f}".format(self._drag_value, self._height))
            painter.setPen(QtGui.QColor(150, 150, 150))
            painter.drawLine(offs_x + 19, 0, offs_x + 19, height + 5)


if __name__ == '__main__':
    app = QtWidgets.QApplication()
    editor = CurveWidget()

    editor.show()
    print(editor.value())
    app.exec_()
示例#28
0
import sys
from Qt import QtCore, QtGui, QtWidgets

from chip import Chip

if __name__ == "__main__":
    app = QtWidgets.QApplication(sys.argv)
    app.setAttribute(QtCore.Qt.AA_DontCreateNativeWidgetSiblings)

    window = QtWidgets.QWidget()
    scene = QtWidgets.QGraphicsScene(window)
    chip = Chip(QtGui.QColor(QtCore.Qt.green), 0, 0)
    scene.addItem(chip)

    layout = QtWidgets.QGridLayout()
    view = QtWidgets.QGraphicsView(scene)
    layout.addWidget(view)
    window.setLayout(layout)

    window.show()
    sys.exit(app.exec_())
示例#29
0
    def processfinished(self, exitCode):
        print('Exit code = %d' % exitCode)
        if exitCode != 0:
            return
        self.saveRecent()
        self.save(FileLast)
        self.output += '\n The job successfully sent.'
        self.teCmd.setText(self.output)
        self.bStart.setEnabled(False)

    def processoutput(self):
        output = self.process.readAll()
        print(output.__class__.__name__)
        if sys.version_info[0] < 3:
            output = str(output)
        else:
            if output.__class__.__name__ == 'QByteArray':
                output = str(output.data(), 'utf-8')
            else:
                output = str(output, 'utf-8')
        print(output)
        self.teCmd.insertPlainText(output)
        self.teCmd.moveCursor(QtGui.QTextCursor.End)
        self.output += output


app = QtWidgets.QApplication(sys.argv)
dialog = Dialog()
dialog.show()
app.exec_()
示例#30
0
    def setupUi(self, scriptEditor):
        scriptEditor.setObjectName("scriptEditor")
        scriptEditor.resize(800, 609)
        self.centralwidget = QtWidgets.QWidget(scriptEditor)
        self.centralwidget.setObjectName("centralwidget")
        self.verticalLayout_2 = QtWidgets.QVBoxLayout(self.centralwidget)
        self.verticalLayout_2.setSpacing(0)
        self.verticalLayout_2.setContentsMargins(0, 0, 0, 0)
        self.verticalLayout_2.setObjectName("verticalLayout_2")
        self.frame_2 = QtWidgets.QFrame(self.centralwidget)
        self.frame_2.setFrameShape(QtWidgets.QFrame.NoFrame)
        self.frame_2.setFrameShadow(QtWidgets.QFrame.Raised)
        self.frame_2.setObjectName("frame_2")
        self.verticalLayout = QtWidgets.QVBoxLayout(self.frame_2)
        self.verticalLayout.setContentsMargins(3, 3, 3, 3)
        self.verticalLayout.setObjectName("verticalLayout")
        self.splitter = QtWidgets.QSplitter(self.frame_2)
        self.splitter.setOrientation(QtCore.Qt.Vertical)
        self.splitter.setObjectName("splitter")
        self.verticalLayoutWidget = QtWidgets.QWidget(self.splitter)
        self.verticalLayoutWidget.setObjectName("verticalLayoutWidget")
        self.out_ly = QtWidgets.QVBoxLayout(self.verticalLayoutWidget)
        self.out_ly.setContentsMargins(0, 0, 0, 0)
        self.out_ly.setObjectName("out_ly")
        self.verticalLayoutWidget_2 = QtWidgets.QWidget(self.splitter)
        self.verticalLayoutWidget_2.setObjectName("verticalLayoutWidget_2")
        self.in_ly = QtWidgets.QVBoxLayout(self.verticalLayoutWidget_2)
        self.in_ly.setContentsMargins(0, 0, 0, 0)
        self.in_ly.setObjectName("in_ly")
        self.verticalLayout.addWidget(self.splitter)
        self.verticalLayout_2.addWidget(self.frame_2)
        scriptEditor.setCentralWidget(self.centralwidget)
        self.menubar = QtWidgets.QMenuBar()
        self.menubar.setGeometry(QtCore.QRect(0, 0, 800, 21))
        self.menubar.setObjectName("menubar")
        self.file_menu = QtWidgets.QMenu(self.menubar)
        self.file_menu.setTearOffEnabled(True)
        self.file_menu.setObjectName("file_menu")
        self.help_menu = QtWidgets.QMenu(self.menubar)
        self.help_menu.setTearOffEnabled(True)
        self.help_menu.setObjectName("help_menu")
        self.tools_menu = QtWidgets.QMenu(self.menubar)
        self.tools_menu.setTearOffEnabled(True)
        self.tools_menu.setObjectName("tools_menu")
        self.options_menu = QtWidgets.QMenu(self.menubar)
        self.options_menu.setTearOffEnabled(True)
        self.options_menu.setObjectName("options_menu")
        self.theme_menu = QtWidgets.QMenu(self.options_menu)
        self.theme_menu.setTearOffEnabled(True)
        self.theme_menu.setObjectName("theme_menu")
        self.run_menu = QtWidgets.QMenu(self.menubar)
        self.run_menu.setTearOffEnabled(True)
        self.run_menu.setObjectName("run_menu")
        scriptEditor.setMenuBar(self.menubar)
        self.toolBar = QtWidgets.QToolBar(scriptEditor)
        self.toolBar.setObjectName("toolBar")
        scriptEditor.addToolBar(QtCore.Qt.TopToolBarArea, self.toolBar)
        self.clearHistory_act = QtWidgets.QAction(scriptEditor)
        self.clearHistory_act.setObjectName("clearHistory_act")
        self.save_act = QtWidgets.QAction(scriptEditor)
        self.save_act.setObjectName("save_act")
        self.load_act = QtWidgets.QAction(scriptEditor)
        self.load_act.setObjectName("load_act")
        self.exit_act = QtWidgets.QAction(scriptEditor)
        self.exit_act.setObjectName("exit_act")
        self.quickHelp_act = QtWidgets.QAction(scriptEditor)
        self.quickHelp_act.setObjectName("quickHelp_act")
        self.saveSeccion_act = QtWidgets.QAction(scriptEditor)
        self.saveSeccion_act.setObjectName("saveSeccion_act")
        self.tabToSpaces_act = QtWidgets.QAction(scriptEditor)
        self.tabToSpaces_act.setObjectName("tabToSpaces_act")
        self.spacesToTabs_act = QtWidgets.QAction(scriptEditor)
        self.spacesToTabs_act.setObjectName("spacesToTabs_act")
        self.settingsFile_act = QtWidgets.QAction(scriptEditor)
        self.settingsFile_act.setObjectName("settingsFile_act")
        self.editTheme_act = QtWidgets.QAction(scriptEditor)
        self.editTheme_act.setObjectName("editTheme_act")
        self.shortcuts_act = QtWidgets.QAction(scriptEditor)
        self.shortcuts_act.setObjectName("shortcuts_act")
        self.execAll_act = QtWidgets.QAction(scriptEditor)
        self.execAll_act.setObjectName("execAll_act")
        self.execSel_act = QtWidgets.QAction(scriptEditor)
        self.execSel_act.setObjectName("execSel_act")
        self.copy_act = QtWidgets.QAction(scriptEditor)
        self.copy_act.setObjectName("copy_act")
        self.cut_act = QtWidgets.QAction(scriptEditor)
        self.cut_act.setObjectName("cut_act")
        self.paste_act = QtWidgets.QAction(scriptEditor)
        self.paste_act.setObjectName("paste_act")
        self.find_act = QtWidgets.QAction(scriptEditor)
        self.find_act.setObjectName("find_act")
        self.undo_act = QtWidgets.QAction(scriptEditor)
        self.undo_act.setObjectName("undo_act")
        self.redo_act = QtWidgets.QAction(scriptEditor)
        self.redo_act.setObjectName("redo_act")
        self.printHelp_act = QtWidgets.QAction(scriptEditor)
        self.printHelp_act.setObjectName("printHelp_act")
        self.comment_cat = QtWidgets.QAction(scriptEditor)
        self.comment_cat.setObjectName("comment_cat")
        self.file_menu.addAction(self.saveSeccion_act)
        self.file_menu.addAction(self.save_act)
        self.file_menu.addAction(self.load_act)
        self.help_menu.addAction(self.shortcuts_act)
        self.help_menu.addSeparator()
        self.help_menu.addAction(self.printHelp_act)
        self.tools_menu.addAction(self.undo_act)
        self.tools_menu.addAction(self.redo_act)
        self.tools_menu.addSeparator()
        self.tools_menu.addAction(self.copy_act)
        self.tools_menu.addAction(self.cut_act)
        self.tools_menu.addAction(self.paste_act)
        self.tools_menu.addSeparator()
        self.tools_menu.addAction(self.tabToSpaces_act)
        self.tools_menu.addAction(self.comment_cat)
        self.tools_menu.addAction(self.find_act)
        self.theme_menu.addAction(self.editTheme_act)
        self.theme_menu.addSeparator()
        self.options_menu.addAction(self.theme_menu.menuAction())
        self.options_menu.addAction(self.settingsFile_act)
        self.run_menu.addAction(self.execAll_act)
        self.run_menu.addAction(self.execSel_act)
        self.run_menu.addAction(self.clearHistory_act)
        self.menubar.addAction(self.file_menu.menuAction())
        self.menubar.addAction(self.tools_menu.menuAction())
        self.menubar.addAction(self.run_menu.menuAction())
        self.menubar.addAction(self.options_menu.menuAction())
        self.menubar.addAction(self.help_menu.menuAction())
        self.toolBar.addAction(self.execAll_act)
        self.toolBar.addAction(self.execSel_act)
        self.toolBar.addAction(self.clearHistory_act)

        self.retranslateUi(scriptEditor)
        QtCore.QMetaObject.connectSlotsByName(scriptEditor)