Exemplo n.º 1
0
    def show_context_menu(self):
        """
        Creates and shows the context menu for the search widget
        :return: QAction
        """

        menu = QMenu(self)
        standard_menu = self.createStandardContextMenu()
        standard_menu.setTitle('Edit')
        menu.addMenu(standard_menu)

        sub_menu = QMenu(menu)
        sub_menu.setTitle('Space Operator')
        menu.addMenu(sub_menu)

        or_action = QAction('OR', menu)
        or_action.setCheckable(True)
        or_callback = partial(self.set_space_operator, 'or')
        or_action.triggered.connect(or_callback)
        if self.space_operator() == 'or':
            or_action.setChecked(True)
        sub_menu.addAction(or_action)

        and_action = QAction('AND', menu)
        and_action.setCheckable(True)
        and_callback = partial(self.set_space_operator, 'and')
        and_action.triggered.connect(and_callback)
        if self.space_operator() == 'and':
            and_action.setChecked(True)
        sub_menu.addAction(and_action)

        action = menu.exec_(QCursor.pos())

        return action
Exemplo n.º 2
0
    def contextMenuEvent(self, event):
        menu = QMenu(self)
        remove_icon = resources.icon(name='delete')
        remove_action = QAction(remove_icon, 'Remove', menu)
        remove_tooltip = 'Delete selected project'
        remove_action.setStatusTip(remove_tooltip)
        remove_action.setToolTip(remove_tooltip)
        remove_action.triggered.connect(self._on_remove_project)

        folder_icon = resources.icon(name='open_folder', extension='png')
        folder_action = QAction(folder_icon, 'Open in Browser', menu)
        open_project_in_explorer_tooltip = 'Open project folder in explorer'
        folder_action.setStatusTip(open_project_in_explorer_tooltip)
        folder_action.setToolTip(open_project_in_explorer_tooltip)
        folder_action.triggered.connect(self._on_open_in_browser)

        image_icon = resources.icon(name='picture', extension='png')
        set_image_action = QAction(image_icon, 'Set Project Image', menu)
        set_project_image_tooltip = 'Set the image used by the project'
        set_image_action.setToolTip(set_project_image_tooltip)
        set_image_action.setStatusTip(set_project_image_tooltip)
        set_image_action.triggered.connect(self._on_set_project_image)

        for action in [remove_action, None, folder_action, None, set_image_action]:
            if action is None:
                menu.addSeparator()
            else:
                menu.addAction(action)

        menu.exec_(self.mapToGlobal(event.pos()))
Exemplo n.º 3
0
    def __init__(self, name, parent, dataType, direction, **kwargs):
        QGraphicsWidget.__init__(self)
        PinBase.__init__(self, name, parent, dataType, direction, **kwargs)
        self.setParentItem(parent)
        self.setCursor(QtCore.Qt.CrossCursor)
        ## context menu for pin
        self.menu = QMenu()
        ## Disconnect all connections
        self.actionDisconnect = self.menu.addAction('disconnect all')
        self.actionDisconnect.triggered.connect(self.disconnectAll)
        ## Copy UUID to buffer
        self.actionCopyUid = self.menu.addAction('copy uid')
        self.actionCopyUid.triggered.connect(self.saveUidToClipboard)

        ## Call exec pin
        self.actionCall = self.menu.addAction('execute')
        self.actionCall.triggered.connect(self.call)
        self.newPos = QtCore.QPointF()
        self.setFlag(QGraphicsWidget.ItemSendsGeometryChanges)
        self.setCacheMode(self.DeviceCoordinateCache)
        self.setAcceptHoverEvents(True)
        self.setZValue(2)
        self.width = 8 + 1
        self.height = 8 + 1
        self.hovered = False
        self.startPos = None
        self.endPos = None
        self._container = None
        self._execPen = QtGui.QPen(Colors.Exec, 0.5, QtCore.Qt.SolidLine)
        self.setGeometry(0, 0, self.width, self.height)
        self._dirty_pen = QtGui.QPen(Colors.DirtyPen, 0.5, QtCore.Qt.DashLine,
                                     QtCore.Qt.RoundCap, QtCore.Qt.RoundJoin)

        self.pinImage = QtGui.QImage(':/icons/resources/array.png')
Exemplo n.º 4
0
    def _create_context_menu(self):
        self._context_menu = QMenu()

        move_up_icon = resources.icon('sort_up')
        move_down_icon = resources.icon('sort_down')
        rename_icon = resources.icon('rename')
        remove_icon = resources.icon('delete')
        copy_icon = resources.icon('copy')

        move_up_action = QAction(move_up_icon, 'Move Up', self._context_menu)
        self._context_menu.addAction(move_up_action)
        move_down_action = QAction(move_down_icon, 'Move Down',
                                   self._context_menu)
        self._context_menu.addAction(move_down_action)
        self._context_menu.addSeparator()
        copy_action = QAction(copy_icon, 'Copy', self._context_menu)
        self._context_menu.addAction(copy_action)
        rename_action = QAction(rename_icon, 'Rename', self._context_menu)
        self._context_menu.addAction(rename_action)
        remove_action = QAction(remove_icon, 'Remove', self._context_menu)
        self._context_menu.addAction(remove_action)

        move_up_action.triggered.connect(self.move_up)
        move_down_action.triggered.connect(self.move_down)
        rename_action.triggered.connect(self.rename)
        remove_action.triggered.connect(self.remove)
Exemplo n.º 5
0
    def contextMenuEvent(self, event):
        menu = QMenu(self)
        remove_icon = resources.icon(name='delete')
        remove_action = QAction(remove_icon, 'Remove', menu)
        remove_action.setStatusTip(consts.DELETE_PROJECT_TOOLTIP)
        remove_action.setToolTip(consts.DELETE_PROJECT_TOOLTIP)
        remove_action.triggered.connect(self._on_remove_project)

        folder_icon = resources.icon(name='open_folder', extension='png')
        folder_action = QAction(folder_icon, 'Open in Browser', menu)
        folder_action.setStatusTip(consts.OPEN_PROJECT_IN_EXPLORER_TOOLTIP)
        folder_action.setToolTip(consts.OPEN_PROJECT_IN_EXPLORER_TOOLTIP)
        folder_action.triggered.connect(self._on_open_in_browser)

        image_icon = resources.icon(name='picture', extension='png')
        set_image_action = QAction(image_icon, 'Set Project Image', menu)
        set_image_action.setToolTip(consts.SET_PROJECT_IMAGE_TOOLTIP)
        set_image_action.setStatusTip(consts.SET_PROJECT_IMAGE_TOOLTIP)
        set_image_action.triggered.connect(self._on_set_project_image)

        for action in [
                remove_action, None, folder_action, None, set_image_action
        ]:
            if action is None:
                menu.addSeparator()
            else:
                menu.addAction(action)

        menu.exec_(self.mapToGlobal(event.pos()))
Exemplo n.º 6
0
    def build(self):
        menu_data = self._builder.get()
        menu = QMenu()
        for menu_entry in menu_data:
            self._create_menu_entry(menu, menu_entry)

        return menu
Exemplo n.º 7
0
    def __init__(self, owningNode, raw_pin):
        """UI wrapper for :class:`PyFlow.Core.PinBase`

        :param owningNode: Owning node
        :type owningNode: :class:`PyFlow.UI.Canvas.NodeBase`
        :param raw_pin: PinBase reference
        :type raw_pin: :class:`PyFlow.Core.PinBase`
        """

        super(UIPinBase, self).__init__()
        self.setGraphicsItem(self)
        self.setFlag(QGraphicsWidget.ItemSendsGeometryChanges)
        self.setCacheMode(self.DeviceCoordinateCache)
        self.setAcceptHoverEvents(True)
        self.setZValue(1)
        self.setParentItem(owningNode)

        self.UiNode = weakref.ref(owningNode)
        self._rawPin = raw_pin
        if self._rawPin is not None:
            self._rawPin.serializationHook.connect(self.serializationHook)
            self._rawPin.containerTypeChanged.connect(
                self.onContainerTypeChanged)
            self._displayName = self._rawPin.name
            self._rawPin.setWrapper(self)
            self._rawPin.killed.connect(self.kill)
            self._rawPin.nameChanged.connect(self.setDisplayName)

            # Context menu for pin
            self.menu = QMenu()
            self.menu.addAction("Rename").triggered.connect(self.onRename)
            self.menu.addAction("Remove").triggered.connect(self._rawPin.kill)
            self.actionDisconnect = self.menu.addAction('Disconnect all')
            self.actionDisconnect.triggered.connect(self._rawPin.disconnectAll)
            self.actionResetValue = self.menu.addAction("Reset value")
            self.actionResetValue.triggered.connect(self.resetToDefault)
            if self._rawPin._structure == PinStructure.Multi:
                self.menu.addAction("changeStructure").triggered.connect(
                    self.selectStructure)

        # GUI
        self._font = QtGui.QFont("Consolas")
        self._font.setPointSize(6)
        self.pinSize = 6
        self.hovered = False
        self.bLabelHidden = False
        if self._rawPin is not None:
            self._pinColor = QtGui.QColor(*self._rawPin.color())
        self._labelColor = QtCore.Qt.white
        self._execPen = QtGui.QPen(Colors.White, 0.5, QtCore.Qt.SolidLine)
        self._dirty_pen = QtGui.QPen(Colors.DirtyPen, 0.5, QtCore.Qt.DashLine,
                                     QtCore.Qt.RoundCap, QtCore.Qt.RoundJoin)

        self.uiConnectionList = []

        self.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Maximum)
        self.pinCircleDrawOffset = QtCore.QPointF()
        # TODO: This is check is for PinGroup. Improve it
        if self._rawPin is not None:
            self.setToolTip(self._rawPin.description)
Exemplo n.º 8
0
    def create(self, delete_if_exists=True):
        """
        Creates a new shelf
        """

        if delete_if_exists:
            if gui.shelf_exists(shelf_name=self._name):
                gui.delete_shelf(shelf_name=self._name)
        else:
            assert not gui.shelf_exists(self._name), 'Shelf with name {} already exists!'.format(self._name)

        self._name = gui.create_shelf(name=self._name)

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

        self._category_btn = QPushButton('')
        if self._category_icon:
            self._category_btn.setIcon(self._category_icon)
        self._category_btn.setIconSize(QSize(18, 18))
        self._category_menu = QMenu(self._category_btn)
        self._category_btn.setStyleSheet(
            'QPushButton::menu-indicator {image: url(myindicator.png);'
            'subcontrol-position: right center;subcontrol-origin: padding;left: -2px;}')
        self._category_btn.setMenu(self._category_menu)
        self._category_lbl = QLabel('MAIN')
        self._category_lbl.setAlignment(Qt.AlignCenter)
        font = self._category_lbl.font()
        font.setPointSize(6)
        self._category_lbl.setFont(font)
        menu_ptr = maya.OpenMayaUI.MQtUtil.findControl(self._name)
        menu_widget = qtutils.wrapinstance(menu_ptr, QWidget)
        menu_widget.layout().addWidget(self._category_btn)
        menu_widget.layout().addWidget(self._category_lbl)

        self.add_separator()
Exemplo n.º 9
0
    def __init__(self, search_line=None, parent=None):
        super(SearchFindWidget, self).__init__(parent=parent)

        self.setObjectName('SearchFindWidget')

        self.text = ''
        self._placeholder_text = ''

        main_layout = layouts.HorizontalLayout(spacing=2, margins=(2, 2, 2, 2))
        self.setLayout(main_layout)

        self._search_line = search_line or QLineEdit(self)
        self._search_menu = QMenu()
        self._search_menu.addAction('Test')

        icon_size = self.style().pixelMetric(QStyle.PM_SmallIconSize)

        delete_icon = resources.icon('delete')
        search_icon = QIcon(resources.icon('search'))

        self._clear_btn = buttons.IconButton(delete_icon,
                                             icon_padding=2,
                                             parent=self)
        self._clear_btn.setIconSize(QSize(icon_size, icon_size))
        self._clear_btn.setFixedSize(QSize(icon_size, icon_size))
        self._clear_btn.hide()

        self._search_btn = buttons.IconButton(search_icon,
                                              icon_padding=2,
                                              parent=self)
        self._search_btn.setIconSize(QSize(icon_size, icon_size))
        self._search_btn.setFixedSize(QSize(icon_size, icon_size))
        # self._search_btn.setStyleSheet('border: none;')
        # self._search_btn.setPopupMode(QToolButton.InstantPopup)
        self._search_btn.setEnabled(True)

        self._search_line.setStyleSheet("""
            QLineEdit { padding-left: %spx; padding-right: %spx; border-radius:10px; border:2px; border-color:red; }
            """ % (self._search_button_padded_width(),
                   self._clear_button_padded_width()))
        self._search_line.setMinimumSize(
            max(
                self._search_line.minimumSizeHint().width(),
                self._clear_button_padded_width() +
                self._search_button_padded_width()),
            max(
                self._search_line.minimumSizeHint().height(),
                max(self._clear_button_padded_width(),
                    self._search_button_padded_width())))

        main_layout.addWidget(self._search_line)

        self._search_line.setFocus()

        self._search_line.textChanged.connect(self.textChanged)
        self._search_line.textChanged.connect(self.set_text)
        # self._search_line.editingFinished.connect(self.editingFinished)
        # self._search_line.returnPressed.connect(self.returnPressed)
        self._clear_btn.clicked.connect(self.clear)
        self._search_btn.clicked.connect(self._popup_menu)
    def ui(self):
        super(RotationAxisView, self).ui()

        set_rot_top_layout = layouts.HorizontalLayout(spacing=5)
        self._set_rot_axis_box = combobox.BaseComboBox(parent=self)
        set_rot_top_layout.addWidget(self._set_rot_axis_box)
        for rotAxis in ROTATION_AXES:
            self._set_rot_axis_box.addItem(rotAxis)
        set_rot_axis_common_btn = buttons.BaseButton('   <', parent=self)
        set_rot_axis_common_btn.setMaximumWidth(45)
        set_rot_axis_common_btn.setStyleSheet(
            "QPushButton::menu-indicator{image:url(none.jpg);}")
        self._set_rot_axis_common_btn_menu = QMenu(self)
        # self._set_common_rotation_axis()
        set_rot_axis_common_btn.setMenu(self._set_rot_axis_common_btn_menu)
        set_rot_top_layout.addWidget(set_rot_axis_common_btn)

        set_rot_axis_btn_layout = layouts.HorizontalLayout()
        set_rot_axis_btn_layout.setAlignment(Qt.AlignCenter)
        self._set_rot_axis_btn = buttons.BaseButton('Apply', parent=self)
        self._set_rot_axis_btn.setIcon(resources.icon('ok'))
        self._affect_children_cbx = checkbox.BaseCheckBox('Affect Children',
                                                          parent=self)
        self._set_rot_axis_btn.setMaximumWidth(100)
        set_rot_axis_btn_layout.addWidget(self._set_rot_axis_btn)
        set_rot_axis_btn_layout.addWidget(self._affect_children_cbx)

        self.main_layout.addLayout(set_rot_top_layout)
        self.main_layout.addLayout(set_rot_axis_btn_layout)
Exemplo n.º 11
0
    def _on_show_menu(self):
        """
        Internal callback that shows field menu using the actions from the data
        """

        menu = QMenu(self)

        actions = self.data().get('actions', list())
        for action in actions:
            name = action.get('name', 'No name found')
            enabled = action.get('enabled', True)
            callback = action.get('callback')
            fn = partial(self._action_callback, callback)
            action = menu.addAction(name)
            action.setEnabled(enabled)
            action.triggered.connect(fn)

        point = QCursor.pos()
        point.setX(point.x() + 3)
        point.setY(point.y() + 3)

        self._action_result = None

        menu.exec_(point)

        if self._action_result is not None:
            self.set_value(self._action_result)
Exemplo n.º 12
0
 def __init__(self, name, graph):
     super(implicitPinCall, self).__init__(name, graph)
     self.inExec = self.addInputPin('inp', DataTypes.Exec, self.compute, hideLabel=True)
     self.uidInp = self.addInputPin('UUID', DataTypes.String)
     self.outExec = self.addOutputPin('out', DataTypes.Exec, hideLabel=True)
     self.menu = QMenu()
     self.actionFindPin = self.menu.addAction('Find pin')
     self.actionFindPin.triggered.connect(self.OnFindPin)
Exemplo n.º 13
0
 def showContextMenu(self, pos):
     self.row = self.propertiesTableView.indexAt(pos).row()
     self.menu = QMenu(self)
     deleteRowAction = QAction('Delete', self)
     deleteRowAction.triggered.connect(self.deleteRow)
     self.menu.addAction(deleteRowAction)
     # add other required actions
     self.menu.popup(QCursor.pos())
Exemplo n.º 14
0
def getOrCreateMenu(menuBar, title):
    for child in menuBar.findChildren(QMenu):
        if child.title() == title:
            return child
    menu = QMenu(menuBar)
    menu.setObjectName(title)
    menu.setTitle(title)
    return menu
Exemplo n.º 15
0
 def __init__(self, name, graph):
     super(sequence, self).__init__(name, graph)
     self.inExecPin = self.addInputPin('inExec',
                                       DataTypes.Exec,
                                       self.compute,
                                       hideLabel=True)
     self.menu = QMenu()
     self.action = self.menu.addAction('add pin')
     self.action.triggered.connect(self.addOutPin)
Exemplo n.º 16
0
    def _on_open_menu(self):
        """
        Internal function that is called when the user opens the context menu of the tab menu bar
        :param pos: QPos
        """

        menu = QMenu(self)
        menu.addAction(
            QAction('Rename Current Tab', self, triggered=self._on_rename_tab))
        menu.exec_(QCursor.pos())
Exemplo n.º 17
0
 def __init__(self, name, graph):
     super(pythonNode, self).__init__(name, graph)
     self.menu = QMenu()
     self.actionEdit = self.menu.addAction('edit')
     self.actionEdit.triggered.connect(self.openEditor)
     self.actionEdit.setIcon(QtGui.QIcon(':/icons/resources/py.png'))
     self.editorUUID = None
     self.bKillEditor = True
     self.label().icon = QtGui.QImage(':/icons/resources/py.png')
     self.currentComputeCode = Node.jsonTemplate()['computeCode']
 def __init__(self, parent=None, dataSetCallback=None, defaultValue=None, **kwds):
     super(InputWidgetRaw, self).__init__(parent=parent)
     self._defaultValue = defaultValue
     # function with signature void(object)
     # this will set data to pin
     self.dataSetCallback = dataSetCallback
     self._widget = None
     self._menu = QMenu()
     self.actionReset = self._menu.addAction("ResetValue")
     self.actionReset.triggered.connect(self.onResetValue)
Exemplo n.º 19
0
    def handlePopupMenu(self):
        """
        Called when user right-clicks on a trace
        """
        menu = QMenu()

        selected = self.selectedDataNames()
        if len(selected) != 0:
            menu.addAction(self.actionDeleteTrace)

        menu.exec_(QCursor.pos())
Exemplo n.º 20
0
    def __init__(self, parent=None, msg='--Select--', triState=False):
        super(MultiSelectComboBox, self).__init__(parent)
        loadUi(osp.join(uiPath, 'multiSelectComboBox.ui'), self)

        self.triState = triState
        self.msg = msg
        self.menu = QMenu(self)
        self.menu.setStyleSheet("QMenu { menu-scrollable: 1; }")
        self.button.setMenu(self.menu)

        self.menu.hideEvent = self.menuHideEvent
        self.setHintText(self.msg)
Exemplo n.º 21
0
    def _on_show_menu(self):
        """
        Internal callback function triggered when item menu should be opened
        :return: QAction
        """

        menu = QMenu(self)
        self.item().context_edit_menu(menu)
        point = QCursor.pos()
        point.setX(point.x() + 3)
        point.setY(point.y() + 3)

        return menu.exec_(point)
Exemplo n.º 22
0
    def _on_show_menu(self):
        """
        Internal callback function that is called when menu button is clicked byu the user
        :return: QAction
        """

        menu = QMenu(self)
        self._item_view.context_edit_menu(menu)
        point = QCursor.pos()
        point.setX(point.x() + 3)
        point.setY(point.y() + 3)

        return menu.exec_(point)
Exemplo n.º 23
0
    def handlePopupMenu(self):
        """
        Called when user right-clicks on the sources tree
        """
        menu = QMenu()
        menu.addAction(self.actionAdd)

        selected = self.main.treeView.selectedItems()
        if len(selected) != 0:
            if "config" in selected[0].source.__dict__:
                menu.addAction(self.actionConfig)
            menu.addAction(self.actionDelete)

        menu.exec_(QCursor.pos())
Exemplo n.º 24
0
    def __init__(self, source, destination, canvas):
        QGraphicsPathItem.__init__(self)
        self.setAcceptedMouseButtons(QtCore.Qt.LeftButton)
        self.setAcceptHoverEvents(True)
        self.setFlag(QGraphicsPathItem.ItemIsSelectable)
        self._menu = QMenu()
        self.actionDisconnect = self._menu.addAction("Disconnect")
        self.actionDisconnect.triggered.connect(self.kill)
        self._uid = uuid4()
        self.canvasRef = weakref.ref(canvas)
        self.source = weakref.ref(source)
        self.destination = weakref.ref(destination)
        self.drawSource = self.source()
        self.drawDestination = self.destination()

        # Overrides for getting endpoints positions
        # if None - pin centers will be used
        self.sourcePositionOverride = None
        self.destinationPositionOverride = None

        self.mPath = QtGui.QPainterPath()

        self.cp1 = QtCore.QPointF(0.0, 0.0)
        self.cp2 = QtCore.QPointF(0.0, 0.0)

        self.setZValue(NodeDefaults().Z_LAYER - 1)

        self.color = self.source().color()
        self.selectedColor = self.color.lighter(150)

        self.thickness = 1
        if source.isExec():
            self.thickness = 2

        self.pen = QtGui.QPen(self.color, self.thickness, QtCore.Qt.SolidLine,
                              QtCore.Qt.RoundCap, QtCore.Qt.RoundJoin)

        points = self.getEndPoints()
        self.updateCurve(points[0], points[1])

        self.setPen(self.pen)

        self.source().update()
        self.destination().update()
        self.fade = 0.0
        self.source().uiConnectionList.append(self)
        self.destination().uiConnectionList.append(self)
        self.source().pinConnected(self.destination())
        self.destination().pinConnected(self.source())
Exemplo n.º 25
0
    def __init__(self, parent=None):
        super(TrayMessage, self).__init__(parent=parent)

        self._tools_icon = None

        self.tray_icon_menu = QMenu(self)
        self.tray_icon = QSystemTrayIcon(self)
        # self.tray_icon.setIcon(self._tools_icon)
        self.tray_icon.setToolTip('Tray')
        self.tray_icon.setContextMenu(self.tray_icon_menu)

        if not QSystemTrayIcon.isSystemTrayAvailable():
            raise OSError('Tray Icon is not available!')

        self.tray_icon.show()
Exemplo n.º 26
0
 def __init__(self, name, graph):
     super(switchOnString, self).__init__(name, graph)
     self.inExecPin = self.addInputPin('inExec',
                                       DataTypes.Exec,
                                       self.compute,
                                       hideLabel=True)
     self.defaultPin = None
     self.outString = None
     self.inString = self.addInputPin('String', DataTypes.String)
     self.menu = QMenu()
     self.action = self.menu.addAction('add pin')
     self.action.triggered.connect(self.addOutPin)
     self.actionDebug = self.menu.addAction('debug')
     self.actionDebug.triggered.connect(self.OnDebug)
     self._map = {}
Exemplo n.º 27
0
    def create_settings_menu(self):
        """
        Creates and returns the settings menu for this widget
        :return: QMenu
        """

        menu = QMenu('Item View', self)
        menu.setIcon(resources.icon('eye'))
        menu.addSeparator()

        # copy_text_menu = self.tree_widget().create_copy_text_menu()
        # menu.addMenu(copy_text_menu)
        # menu.addSeparator()

        size_action = action.SliderAction('Size', menu)
        size_action.slider().setMinimum(10)
        size_action.slider().setMaximum(200)
        size_action.slider().setValue(self.zoom_amount())
        size_action.slider().valueChanged.connect(self.set_zoom_amount)
        menu.addAction(size_action)

        border_action = action.SliderAction('Border', menu)
        border_action.slider().setMinimum(0)
        border_action.slider().setMaximum(20)
        border_action.slider().setValue(self.padding())
        border_action.slider().valueChanged.connect(self.set_padding)
        menu.addAction(border_action)

        spacing_action = action.SliderAction('Spacing', menu)
        spacing_action.slider().setMinimum(self.DEFAULT_MIN_SPACING)
        spacing_action.slider().setMaximum(self.DEFAULT_MAX_SPACING)
        spacing_action.slider().setValue(self.spacing())
        spacing_action.slider().valueChanged.connect(self.set_spacing)
        menu.addAction(spacing_action)

        menu.addAction(action.SeparatorAction('Label Options', menu))

        for option in item.LabelDisplayOption.values():
            option_action = QAction(option.title(), menu)
            option_action.setCheckable(True)
            option_action.setChecked(option == self.label_display_option())
            option_callback = partial(self.set_label_display_option, option)
            option_action.triggered.connect(option_callback)
            menu.addAction(option_action)

        return menu
Exemplo n.º 28
0
    def _create_header_menu(self, column):
        """
        Internal function that creates a new header menu
        :param column, iht
        :return: QMenu
        """

        menu = QMenu(self)
        label = self.label_from_column(column)
        hide_action = menu.addAction('Hide "{}"'.format(label))
        hide_callback = partial(self.setColumnHidden, column, True)
        hide_action.triggered.connect(hide_callback)
        menu.addSeparator()
        resize_action = menu.addAction('Resize to Contents')
        resize_callback = partial(self.resizeColumnToContents, column)
        resize_action.triggered.connect(resize_callback)

        return menu
Exemplo n.º 29
0
    def __init__(self, name, graph):
        super(scene_inputs, self).__init__(name, graph)
        self.menu = QMenu()
        self.action = self.menu.addAction('add port')
        self.action.triggered.connect(self.addInPin)
        self.setPos(self.graph().mapToScene(self.graph().viewport().rect().x(),self.graph().viewport().rect().y()+50) )
        self.asGraphSides = True
        self.sizes[4] = 0
        self.sizes[5] = 0

        self.setFlag(QGraphicsItem.ItemIsMovable,False)
        self.setFlag(QGraphicsItem.ItemIsFocusable,False)
        self.setFlag(QGraphicsItem.ItemIsSelectable,False)
        self.setFlag(QGraphicsItem.ItemSendsGeometryChanges,False)
        
        #self.setFlag(QGraphicsItem.ItemIgnoresTransformations)
        self.label().hide() 
        self.sender = sender()    
Exemplo n.º 30
0
def get_or_create_menu(menu_bar, menu_title):
    """
    Creates a new menu in the given menubar with the given menubar or return Menu object if the a menu
    with the given name already exists in the menu bar
    :param menu_bar: QMenuBar or QMenu
    :param menu_title: str
    :return: QMenu
    """

    for child in menu_bar.findChildren(QMenu):
        if child.title() == menu_title:
            return child

    menu = QMenu(menu_bar)
    menu.setObjectName(menu_title)
    menu.setTitle(menu_title)

    return menu