当前位置: 首页>>代码示例>>Python>>正文


Python Qt.CustomContextMenu方法代码示例

本文整理汇总了Python中PyQt5.QtCore.Qt.CustomContextMenu方法的典型用法代码示例。如果您正苦于以下问题:Python Qt.CustomContextMenu方法的具体用法?Python Qt.CustomContextMenu怎么用?Python Qt.CustomContextMenu使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在PyQt5.QtCore.Qt的用法示例。


在下文中一共展示了Qt.CustomContextMenu方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: __init__

# 需要导入模块: from PyQt5.QtCore import Qt [as 别名]
# 或者: from PyQt5.QtCore.Qt import CustomContextMenu [as 别名]
def __init__(self, model, parent=None):
        super().__init__(parent)
        if not utils.is_mac:
            self.setStyle(QStyleFactory.create('Fusion'))
        stylesheet.set_register(self)
        self.setResizeMode(QListView.Adjust)
        self.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOff)
        self.setSizePolicy(QSizePolicy.MinimumExpanding, QSizePolicy.Fixed)
        self.setFocusPolicy(Qt.NoFocus)
        self.setFlow(QListView.LeftToRight)
        self.setSpacing(1)
        self._menu = None
        model.rowsInserted.connect(functools.partial(update_geometry, self))
        model.rowsRemoved.connect(functools.partial(update_geometry, self))
        model.dataChanged.connect(functools.partial(update_geometry, self))
        self.setModel(model)
        self.setWrapping(True)
        self.setContextMenuPolicy(Qt.CustomContextMenu)
        self.customContextMenuRequested.connect(self.show_context_menu)
        self.clicked.connect(self.on_clicked) 
开发者ID:qutebrowser,项目名称:qutebrowser,代码行数:22,代码来源:downloadview.py

示例2: __init__

# 需要导入模块: from PyQt5.QtCore import Qt [as 别名]
# 或者: from PyQt5.QtCore.Qt import CustomContextMenu [as 别名]
def __init__(self, view):
        QObject.__init__(self, view)
        self.view = view
        self.model = QStandardItemModel()
        self.view.setModel(self.model)
        self.nodesets = []
        self.server_mgr = None
        self.view.header().setSectionResizeMode(1)
        
        addNodeSetAction = QAction("Add Reference Node Set", self.model)
        addNodeSetAction.triggered.connect(self.add_nodeset)
        self.removeNodeSetAction = QAction("Remove Reference Node Set", self.model)
        self.removeNodeSetAction.triggered.connect(self.remove_nodeset)

        self.view.setContextMenuPolicy(Qt.CustomContextMenu)
        self.view.customContextMenuRequested.connect(self.showContextMenu)
        self._contextMenu = QMenu()
        self._contextMenu.addAction(addNodeSetAction)
        self._contextMenu.addAction(self.removeNodeSetAction) 
开发者ID:FreeOpcUa,项目名称:opcua-modeler,代码行数:21,代码来源:refnodesets_widget.py

示例3: __init__

# 需要导入模块: from PyQt5.QtCore import Qt [as 别名]
# 或者: from PyQt5.QtCore.Qt import CustomContextMenu [as 别名]
def __init__(self, view):
        QObject.__init__(self, view)
        self.view = view
        self.model = QStandardItemModel()
        self.view.setModel(self.model)
        delegate = MyDelegate(self.view, self)
        delegate.error.connect(self.error.emit)
        self.view.setItemDelegate(delegate)
        self.node = None
        self.view.header().setSectionResizeMode(1)
        
        self.addNamespaceAction = QAction("Add Namespace", self.model)
        self.addNamespaceAction.triggered.connect(self.add_namespace)
        self.removeNamespaceAction = QAction("Remove Namespace", self.model)
        self.removeNamespaceAction.triggered.connect(self.remove_namespace)

        self.view.setContextMenuPolicy(Qt.CustomContextMenu)
        self.view.customContextMenuRequested.connect(self.showContextMenu)
        self._contextMenu = QMenu()
        self._contextMenu.addAction(self.addNamespaceAction)
        self._contextMenu.addAction(self.removeNamespaceAction) 
开发者ID:FreeOpcUa,项目名称:opcua-modeler,代码行数:23,代码来源:namespace_widget.py

示例4: setup_context_menu_tree

# 需要导入模块: from PyQt5.QtCore import Qt [as 别名]
# 或者: from PyQt5.QtCore.Qt import CustomContextMenu [as 别名]
def setup_context_menu_tree(self):
        self.ui.treeView.setContextMenuPolicy(Qt.CustomContextMenu)
        self.ui.treeView.customContextMenuRequested.connect(self._show_context_menu_tree)
        self._contextMenu = QMenu()

        # tree view menu
        self._contextMenu.addAction(self.ui.actionCopy)
        self._contextMenu.addAction(self.ui.actionPaste)
        self._contextMenu.addAction(self.ui.actionDelete)
        self._contextMenu.addSeparator()
        self._contextMenu.addAction(self.tree_ui.actionReload)
        self._contextMenu.addSeparator()
        self._contextMenu.addAction(self.ui.actionAddFolder)
        self._contextMenu.addAction(self.ui.actionAddObject)
        self._contextMenu.addAction(self.ui.actionAddVariable)
        self._contextMenu.addAction(self.ui.actionAddProperty)
        self._contextMenu.addAction(self.ui.actionAddMethod)
        self._contextMenu.addAction(self.ui.actionAddObjectType)
        self._contextMenu.addAction(self.ui.actionAddVariableType)
        self._contextMenu.addAction(self.ui.actionAddDataType) 
开发者ID:FreeOpcUa,项目名称:opcua-modeler,代码行数:22,代码来源:uamodeler.py

示例5: setupUi

# 需要导入模块: from PyQt5.QtCore import Qt [as 别名]
# 或者: from PyQt5.QtCore.Qt import CustomContextMenu [as 别名]
def setupUi(self, tab_content):
        super().setupUi(tab_content)
        self._tab_content = tab_content

        self.loadProtocolButton.clicked.connect(lambda: self._select_protocol())
        self.saveButton.clicked.connect(lambda: self._save_protocol())
        self.loadColumnButton.clicked.connect(lambda: self._load_column_action())
        self.loadGB.clicked.connect(lambda: self._load_g_and_b())
        self.clearButton.clicked.connect(self._clear_table)

        self.protocol_table.setSortingEnabled(True)

        headers = self.protocol_table.horizontalHeader()
        headers.setContextMenuPolicy(Qt.CustomContextMenu)
        headers.customContextMenuRequested.connect(self.show_header_context_menu)
        headers.setSelectionMode(QAbstractItemView.SingleSelection) 
开发者ID:robbert-harms,项目名称:MDT,代码行数:18,代码来源:generate_protocol_tab.py

示例6: __init__

# 需要导入模块: from PyQt5.QtCore import Qt [as 别名]
# 或者: from PyQt5.QtCore.Qt import CustomContextMenu [as 别名]
def __init__(self, parent=None):
        super(VideoList, self).__init__(parent)
        self.parent = parent
        self.theme = self.parent.theme
        self._progressbars = []
        self.setMouseTracking(True)
        self.setDropIndicatorShown(True)
        self.setFixedWidth(190)
        self.setAttribute(Qt.WA_MacShowFocusRect, False)
        self.setContentsMargins(0, 0, 0, 0)
        self.setItemDelegate(VideoItem(self))
        self.setSizePolicy(QSizePolicy.Fixed, QSizePolicy.Expanding)
        self.setUniformItemSizes(True)
        self.setDragEnabled(True)
        self.setDragDropMode(QAbstractItemView.InternalMove)
        self.setContextMenuPolicy(Qt.CustomContextMenu)
        self.setAlternatingRowColors(True)
        self.setVerticalScrollMode(QAbstractItemView.ScrollPerPixel)
        self.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff)
        self.setObjectName('cliplist')
        self.setStyleSheet('QListView::item { border: none; }')
        self.opacityEffect = OpacityEffect(0.3)
        self.opacityEffect.setEnabled(False)
        self.setGraphicsEffect(self.opacityEffect) 
开发者ID:ozmartian,项目名称:vidcutter,代码行数:26,代码来源:videolist.py

示例7: createTable

# 需要导入模块: from PyQt5.QtCore import Qt [as 别名]
# 或者: from PyQt5.QtCore.Qt import CustomContextMenu [as 别名]
def createTable(self):
        # Set up location table
        self.locationTable = QTableWidget(self)
        self.locationTable.setColumnCount(8)
        self.locationTable.setGeometry(10, 10, self.geometry().width()/2-20, self.geometry().height()/2)
        self.locationTable.setShowGrid(True)
        self.locationTable.setHorizontalHeaderLabels(['macAddr','SSID', 'Strength', 'Timestamp','GPS', 'Latitude', 'Longitude', 'Altitude'])
        self.locationTable.resizeColumnsToContents()
        self.locationTable.setRowCount(0)
        self.locationTable.horizontalHeader().setSectionResizeMode(1, QHeaderView.Stretch)
        
        self.ntRightClickMenu = QMenu(self)
        newAct = QAction('Copy', self)        
        newAct.setStatusTip('Copy data to clipboard')
        newAct.triggered.connect(self.onCopy)
        self.ntRightClickMenu.addAction(newAct)
        
        self.locationTable.setContextMenuPolicy(Qt.CustomContextMenu)
        self.locationTable.customContextMenuRequested.connect(self.showNTContextMenu) 
开发者ID:ghostop14,项目名称:sparrow-wifi,代码行数:21,代码来源:telemetry.py

示例8: __init__

# 需要导入模块: from PyQt5.QtCore import Qt [as 别名]
# 或者: from PyQt5.QtCore.Qt import CustomContextMenu [as 别名]
def __init__(self, device_name, is_current_device, certified_on):
        super().__init__()
        self.setupUi(self)
        self.is_current_device = is_current_device
        self.label_icon.apply_style()
        self.device_name = device_name
        self.certified_on = certified_on
        self.label_device_name.setText(self.device_name)
        if self.is_current_device:
            self.label_is_current.setText("({})".format(_("TEXT_DEVICE_IS_CURRENT")))
        self.setContextMenuPolicy(Qt.CustomContextMenu)
        self.customContextMenuRequested.connect(self.show_context_menu)
        effect = QGraphicsDropShadowEffect(self)
        effect.setColor(QColor(0x99, 0x99, 0x99))
        effect.setBlurRadius(10)
        effect.setXOffset(2)
        effect.setYOffset(2)
        self.setGraphicsEffect(effect) 
开发者ID:Scille,项目名称:parsec-cloud,代码行数:20,代码来源:devices_widget.py

示例9: __init__

# 需要导入模块: from PyQt5.QtCore import Qt [as 别名]
# 或者: from PyQt5.QtCore.Qt import CustomContextMenu [as 别名]
def __init__(self, parent=None):
        super(BacktraceWidget, self).__init__(parent=parent)
        self._app_window = parent

        self._app_window.dwarf.onBackTrace.connect(self.set_backtrace)

        self._model = QStandardItemModel(0, 2)
        self._model.setHeaderData(0, Qt.Horizontal, 'Address')
        self._model.setHeaderData(1, Qt.Horizontal, 'Symbol')
        self.setModel(self._model)

        self.header().setSectionResizeMode(0, QHeaderView.ResizeToContents)
        self.header().setSectionResizeMode(1, QHeaderView.ResizeToContents)
        self.doubleClicked.connect(self._item_double_clicked)
        self.setContextMenuPolicy(Qt.CustomContextMenu)
        self.customContextMenuRequested.connect(self._on_context_menu)
        self._mode = 'native' 
开发者ID:iGio90,项目名称:Dwarf,代码行数:19,代码来源:backtrace.py

示例10: create_func_doc

# 需要导入模块: from PyQt5.QtCore import Qt [as 别名]
# 或者: from PyQt5.QtCore.Qt import CustomContextMenu [as 别名]
def create_func_doc(self):
        self.func_doc = QWidget()
        self.func_doc_layout = QVBoxLayout()
        self.func_doc_layout.setSpacing(0)
        self.func_doc_layout.setContentsMargins(0, 0, 0, 0)
        self.func_doc_line = QLabel()
        self.func_doc_line.setText('函数简介')
        self.func_doc_line.setObjectName("FuncDetailLabel")
        self.func_content = QTextBrowser()
        self.func_content.setObjectName("FuncContent")
        self.func_content.setContextMenuPolicy(Qt.CustomContextMenu)
        self.func_content.customContextMenuRequested[QPoint].connect(self.func_doc_right_menu)
        self.func_doc_layout.addWidget(self.func_doc_line)
        self.func_doc_layout.addWidget(self.func_content)
        self.func_doc.setLayout(self.func_doc_layout)
        self.func_doc.setContentsMargins(0, 0, 0, 0) 
开发者ID:epolestar,项目名称:equant,代码行数:18,代码来源:view.py

示例11: init_signals

# 需要导入模块: from PyQt5.QtCore import Qt [as 别名]
# 或者: from PyQt5.QtCore.Qt import CustomContextMenu [as 别名]
def init_signals(self):
            if not self.should_show:
                return

            super(FIRSTUI.CheckAll, self).init_signals()
            self.select_highest_ranked.stateChanged.connect(self.select_highest)
            self.filter_sub_funcs_only.stateChanged.connect(self.filter_only_subs)
            self.tree_view.clicked.connect(self.tree_clicked)

            #   A reference is needed to the dialog or else it closes quickly
            #   after showing
            self.history_dialogs = []
            self.tree_view.setContextMenuPolicy(Qt.CustomContextMenu)
            self.tree_view.customContextMenuRequested.connect(self.custom_menu) 
开发者ID:vrtadmin,项目名称:FIRST-plugin-ida,代码行数:16,代码来源:first.py

示例12: initUI

# 需要导入模块: from PyQt5.QtCore import Qt [as 别名]
# 或者: from PyQt5.QtCore.Qt import CustomContextMenu [as 别名]
def initUI(self):

        self.text = QtWidgets.QTextEdit(self)

        # Set the tab stop width to around 33 pixels which is
        # more or less 8 spaces
        self.text.setTabStopWidth(33)

        self.initToolbar()
        self.initFormatbar()
        self.initMenubar()

        self.setCentralWidget(self.text)

        # Initialize a statusbar for the window
        self.statusbar = self.statusBar()

        # If the cursor position changes, call the function that displays
        # the line and column number
        self.text.cursorPositionChanged.connect(self.cursorPosition)

        # We need our own context menu for tables
        self.text.setContextMenuPolicy(Qt.CustomContextMenu)
        self.text.customContextMenuRequested.connect(self.context)

        self.text.textChanged.connect(self.changed)

        self.setGeometry(100,100,1030,800)
        self.setWindowTitle("Writer")
        self.setWindowIcon(QtGui.QIcon("icons/icon.png")) 
开发者ID:goldsborough,项目名称:Writer-Tutorial,代码行数:32,代码来源:part-4.py

示例13: prepareMenu

# 需要导入模块: from PyQt5.QtCore import Qt [as 别名]
# 或者: from PyQt5.QtCore.Qt import CustomContextMenu [as 别名]
def prepareMenu(self):

        self.tree.setContextMenuPolicy(Qt.CustomContextMenu)

        self._context_menu = QMenu(self)
        self._context_menu.addActions(self._toolbar_actions)
        self._context_menu.addActions((self._export_STL_action,
                                       self._export_STEP_action)) 
开发者ID:CadQuery,项目名称:CQ-editor,代码行数:10,代码来源:object_tree.py

示例14: __init__

# 需要导入模块: from PyQt5.QtCore import Qt [as 别名]
# 或者: from PyQt5.QtCore.Qt import CustomContextMenu [as 别名]
def __init__(self, parents=None):
        self._init_context_menu()
        self.setContextMenuPolicy(Qt.CustomContextMenu)
        self.customContextMenuRequested.connect(self._show_context_menu)
        self._base_pos = self.pos()
        self.parents = parents 
开发者ID:chroming,项目名称:pdfdir,代码行数:8,代码来源:base.py

示例15: __init__

# 需要导入模块: from PyQt5.QtCore import Qt [as 别名]
# 或者: from PyQt5.QtCore.Qt import CustomContextMenu [as 别名]
def __init__(self, labels, parent=None):
        super(TTable, self).__init__(parent)
        self.labels = labels
        self.setColumnCount(len(labels))
        self.setHorizontalHeaderLabels(labels)
        self.verticalHeader().hide()
        self.setContextMenuPolicy(Qt.CustomContextMenu)
        self.horizontalHeader().model().setHeaderData(0, Qt.Horizontal, 
            Qt.AlignJustify, Qt.TextAlignmentRole)    
        self.horizontalHeader().setStretchLastSection(1)
        self.setSelectionMode(QtWidgets.QTableView.SingleSelection)
        self.setSelectionBehavior(QtWidgets.QTableView.SelectRows)
        self.setEditTriggers(QtWidgets.QAbstractItemView.NoEditTriggers) 
开发者ID:danigargu,项目名称:heap-viewer,代码行数:15,代码来源:custom.py


注:本文中的PyQt5.QtCore.Qt.CustomContextMenu方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。