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


Python QtWidgets.QAction方法代码示例

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


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

示例1: build_menu

# 需要导入模块: from qtpy import QtWidgets [as 别名]
# 或者: from qtpy.QtWidgets import QAction [as 别名]
def build_menu(self): 
        self.file_menu = QtWidgets.QMenu('&File', self)
        self.file_menu.addAction('&Open directory', self.open_directory, QtCore.Qt.CTRL + QtCore.Qt.Key_O)
        self.file_menu.addAction('&Export image', self.export_image, QtCore.Qt.CTRL + QtCore.Qt.Key_S)
        self.file_menu.addAction('&Quit', self.close, QtCore.Qt.CTRL + QtCore.Qt.Key_Q)      

        self.view_menu = QtWidgets.QMenu('&View', self)
        self.view_menu.addAction('Zoom In', self.pix_label.increase_zoom, QtCore.Qt.CTRL + QtCore.Qt.Key_Plus)
        self.view_menu.addAction('Zoom Out', self.pix_label.decrease_zoom, QtCore.Qt.CTRL + QtCore.Qt.Key_Minus)
        self.view_menu.addAction('Zoom 1:1', self.pix_label.reset_zoom, QtCore.Qt.CTRL + QtCore.Qt.Key_0)
        fullscreen = QtWidgets.QAction('&Full Screen', self)
        fullscreen.setCheckable(True)
        fullscreen.setShortcut(QtCore.Qt.Key_F11)
        fullscreen.toggled.connect(self.toggle_full_screen)
        self.view_menu.addAction(fullscreen)

        self.tools_menu = QtWidgets.QMenu("&Tools", self)
        self.tools_menu.addAction('&Show DICOM structure', self.show_structure, QtCore.Qt.Key_F2)

        self.menuBar().addMenu(self.file_menu)
        self.menuBar().addMenu(self.view_menu)
        self.menuBar().addMenu(self.tools_menu) 
开发者ID:janpipek,项目名称:pydiq,代码行数:24,代码来源:viewer.py

示例2: __enable_point_context

# 需要导入模块: from qtpy import QtWidgets [as 别名]
# 或者: from qtpy.QtWidgets import QAction [as 别名]
def __enable_point_context(self) -> None:
        """Adjust the status of QActions.

        What ever we have least one point or not,
        need to enable / disable QAction.
        """
        selection = self.entities_point.selected_rows()
        # Set grounded state
        if selection:
            self.action_p_lock.setChecked(all(
                VLink.FRAME in self.vpoint_list[row].links for row in selection
            ))
        self.context.point_enable(len(selection))

        def mj_func(order: int) -> Callable[[], None]:
            """Generate a merge function."""
            @Slot()
            def func() -> None:
                self.__to_multiple_joint(order, selection)
            return func

        for i, p in enumerate(selection):
            action = QAction(f"Base on Point{p}", self)
            action.triggered.connect(mj_func(i))
            self.pop_point_m.addAction(action) 
开发者ID:KmolYuan,项目名称:Pyslvs-UI,代码行数:27,代码来源:actions.py

示例3: __enable_link_context

# 需要导入模块: from qtpy import QtWidgets [as 别名]
# 或者: from qtpy.QtWidgets import QAction [as 别名]
def __enable_link_context(self) -> None:
        """Enable / disable link's QAction, same as point table."""
        selection = self.entities_link.selected_rows()
        row = self.entities_link.currentRow()
        self.context.link_enable(len(selection), row)

        def ml_func(order: int) -> Callable[[], None]:
            """Generate a merge function."""
            @Slot(int)
            def func() -> None:
                self.__merge_link(order, selection)
            return func

        for i, row in enumerate(selection):
            action = QAction(f"Base on \"{self.vlink_list[row].name}\"", self)
            action.triggered.connect(ml_func(i))
            self.pop_link_m.addAction(action) 
开发者ID:KmolYuan,项目名称:Pyslvs-UI,代码行数:19,代码来源:actions.py

示例4: add_dock_widget

# 需要导入模块: from qtpy import QtWidgets [as 别名]
# 或者: from qtpy.QtWidgets import QAction [as 别名]
def add_dock_widget(self, create_widget, name):
        dock_widget = MyDockWidget(create_widget,
                                   name + ' (%s)' % self.parent.name)
        self.dock_widgets[name] = dock_widget
        self.addDockWidget(QtCore.Qt.TopDockWidgetArea,
                           dock_widget)
        if self.last_docked is not None:
            self.tabifyDockWidget(self.last_docked, dock_widget)
        # put tabs on top
        self.setTabPosition(dock_widget.allowedAreas(),
                            QtWidgets.QTabWidget.North)
        self.last_docked = dock_widget
        self.last_docked.hide()  # by default no widget is created...

        action = QtWidgets.QAction(name, self.menu_modules)
        action.setCheckable(True)
        self.module_actions.append(action)
        self.menu_modules.addAction(action)

        # make sure menu and widget are in sync
        action.changed.connect(lambda: dock_widget.setVisible(action.isChecked()))
        dock_widget.visibilityChanged.connect(lambda:action.setChecked(dock_widget.isVisible()))
        dock_widget.visibilityChanged.connect(self.hide_centralbutton)
        self.set_background_color(dock_widget) 
开发者ID:lneuhaus,项目名称:pyrpl,代码行数:26,代码来源:pyrpl_widget.py

示例5: add_actions

# 需要导入模块: from qtpy import QtWidgets [as 别名]
# 或者: from qtpy.QtWidgets import QAction [as 别名]
def add_actions(target, actions, insert_before=None):
    """Add actions to a menu"""
    previous_action = None
    target_actions = list(target.actions())
    if target_actions:
        previous_action = target_actions[-1]
        if previous_action.isSeparator():
            previous_action = None
    for action in actions:
        if (action is None) and (previous_action is not None):
            if insert_before is None:
                target.addSeparator()
            else:
                target.insertSeparator(insert_before)
        elif isinstance(action, QMenu):
            if insert_before is None:
                target.addMenu(action)
            else:
                target.insertMenu(insert_before, action)
        elif isinstance(action, QAction):
            if insert_before is None:
                target.addAction(action)
            else:
                target.insertAction(insert_before, action)
        previous_action = action 
开发者ID:spyder-ide,项目名称:conda-manager,代码行数:27,代码来源:qthelpers.py

示例6: openWidgetMenu

# 需要导入模块: from qtpy import QtWidgets [as 别名]
# 或者: from qtpy.QtWidgets import QAction [as 别名]
def openWidgetMenu(self,position):
        indexes = self.ui.treeWidget_2.selectedIndexes()
        item = self.ui.treeWidget_2.itemAt(position)
        if item == None:
            return
        #item = self.ui.listWidget.itemAt(position)
        if len(indexes) > 0:
            menu = QMenu()
            menu.addAction(QAction("Delete", menu,checkable = True))#This function is perhaps useless
            #menu.triggered.connect(self.eraseItem)
            item = self.ui.treeWidget_2.itemAt(position)
            #collec = str(item.text())
            menu.triggered.connect(lambda action: self.ListMethodSelected(action, item))
        menu.exec_(self.ui.treeWidget_2.viewport().mapToGlobal(position)) 
开发者ID:Seedarchangel,项目名称:TuChart,代码行数:16,代码来源:main.py

示例7: _add_start

# 需要导入模块: from qtpy import QtWidgets [as 别名]
# 或者: from qtpy.QtWidgets import QAction [as 别名]
def _add_start(self):
        """Add Start Recording action.
        """
        start = QAction('Start Recording...', self.main_window._qt_window)
        start.setShortcut('Alt+T')
        start.setStatusTip('Start recording a trace file')
        start.triggered.connect(self._start_trace)
        self.sub_menu.addAction(start)
        return start 
开发者ID:napari,项目名称:napari,代码行数:11,代码来源:qt_debug_menu.py

示例8: _add_stop

# 需要导入模块: from qtpy import QtWidgets [as 别名]
# 或者: from qtpy.QtWidgets import QAction [as 别名]
def _add_stop(self):
        """Add Stop Recording action.
        """
        stop = QAction('Stop Recording', self.main_window._qt_window)
        stop.setShortcut('Shift+Alt+T')
        stop.setStatusTip('Stop recording a trace file')
        stop.triggered.connect(self._stop_trace)
        self.sub_menu.addAction(stop)
        return stop 
开发者ID:napari,项目名称:napari,代码行数:11,代码来源:qt_debug_menu.py

示例9: init_kernel_menu

# 需要导入模块: from qtpy import QtWidgets [as 别名]
# 或者: from qtpy.QtWidgets import QAction [as 别名]
def init_kernel_menu(self):
        self.kernel_menu = self.menuBar().addMenu("&Kernel")
        # Qt on OSX maps Ctrl to Cmd, and Meta to Ctrl
        # keep the signal shortcuts to ctrl, rather than
        # platform-default like we do elsewhere.

        ctrl = "Meta" if sys.platform == 'darwin' else "Ctrl"

        self.interrupt_kernel_action = QtWidgets.QAction("&Interrupt current Kernel",
            self,
            triggered=self.interrupt_kernel_active_frontend,
            shortcut=ctrl+"+C",
            )
        self.add_menu_action(self.kernel_menu, self.interrupt_kernel_action)

        self.restart_kernel_action = QtWidgets.QAction("&Restart current Kernel",
            self,
            triggered=self.restart_kernel_active_frontend,
            shortcut=ctrl+"+.",
            )
        self.add_menu_action(self.kernel_menu, self.restart_kernel_action)

        self.kernel_menu.addSeparator()

        self.confirm_restart_kernel_action = QtWidgets.QAction("&Confirm kernel restart",
            self,
            checkable=True,
            checked=self.active_frontend.confirm_restart,
            triggered=self.toggle_confirm_restart_active_frontend
            )

        self.add_menu_action(self.kernel_menu, self.confirm_restart_kernel_action)
        self.tab_widget.currentChanged.connect(self.update_restart_checkbox) 
开发者ID:jupyter,项目名称:qtconsole,代码行数:35,代码来源:mainwindow.py

示例10: init_help_menu

# 需要导入模块: from qtpy import QtWidgets [as 别名]
# 或者: from qtpy.QtWidgets import QAction [as 别名]
def init_help_menu(self):
        # please keep the Help menu in Mac Os even if empty. It will
        # automatically contain a search field to search inside menus and
        # please keep it spelled in English, as long as Qt Doesn't support
        # a QAction.MenuRole like HelpMenuRole otherwise it will lose
        # this search field functionality
        self.help_menu = self.menuBar().addMenu("&Help")

        # Help Menu
        self.help_action = QtWidgets.QAction("Show &QtConsole help", self,
                                         triggered=self._show_help)
        self.online_help_action = QtWidgets.QAction("Open online &help", self,
                                                triggered=self._open_online_help)
        self.add_menu_action(self.help_menu, self.help_action)
        self.add_menu_action(self.help_menu, self.online_help_action) 
开发者ID:jupyter,项目名称:qtconsole,代码行数:17,代码来源:mainwindow.py

示例11: get_menu

# 需要导入模块: from qtpy import QtWidgets [as 别名]
# 或者: from qtpy.QtWidgets import QAction [as 别名]
def get_menu(self):
        menu = QtWidgets.QMenu(self)
        self.actions = []
        for state in self.module.states:
            action = QtWidgets.QAction(state, self)
            self.actions.append(action)
            action.triggered.connect(functools.partial(self.func, state))
            menu.addAction(action)
        return menu 
开发者ID:lneuhaus,项目名称:pyrpl,代码行数:11,代码来源:base_module_widget.py

示例12: contextMenuEvent

# 需要导入模块: from qtpy import QtWidgets [as 别名]
# 或者: from qtpy.QtWidgets import QAction [as 别名]
def contextMenuEvent(self, event):
        for widget in self.module_widgets:
            if widget.geometry().contains(event.pos()):
                if widget.module.owner is not None:
                    act = QtWidgets.QAction('Free %s'%widget.module.name, self)
                    act.triggered.connect(widget.module.free)
                    menu = QtWidgets.QMenu()
                    menu.addAction(act)
                    menu.exec_(event.globalPos()) 
开发者ID:lneuhaus,项目名称:pyrpl,代码行数:11,代码来源:module_manager_widget.py

示例13: action2button

# 需要导入模块: from qtpy import QtWidgets [as 别名]
# 或者: from qtpy.QtWidgets import QAction [as 别名]
def action2button(action, autoraise=True, text_beside_icon=False, parent=None):
    """Create a QToolButton directly from a QAction object"""
    if parent is None:
        parent = action.parent()
    button = QToolButton(parent)
    button.setDefaultAction(action)
    button.setAutoRaise(autoraise)
    if text_beside_icon:
        button.setToolButtonStyle(Qt.ToolButtonTextBesideIcon)
    return button 
开发者ID:spyder-ide,项目名称:conda-manager,代码行数:12,代码来源:qthelpers.py

示例14: create_action

# 需要导入模块: from qtpy import QtWidgets [as 别名]
# 或者: from qtpy.QtWidgets import QAction [as 别名]
def create_action(parent, text, shortcut=None, icon=None, tip=None,
                  toggled=None, triggered=None, data=None, menurole=None,
                  context=Qt.WindowShortcut):
    """Create a QAction"""
    action = QAction(text, parent)
    if triggered is not None:
        action.triggered.connect(triggered)
    if toggled is not None:
        action.toggled.connect(toggled)
        action.setCheckable(True)
    if icon is not None:
        action.setIcon(icon)
    if shortcut is not None:
        action.setShortcut(shortcut)
    if tip is not None:
        action.setToolTip(tip)
        action.setStatusTip(tip)
    if data is not None:
        action.setData(to_qvariant(data))
    if menurole is not None:
        action.setMenuRole(menurole)
    #TODO: Hard-code all shortcuts and choose context=Qt.WidgetShortcut
    # (this will avoid calling shortcuts from another dockwidget
    #  since the context thing doesn't work quite well with these widgets)
    action.setShortcutContext(context)
    return action 
开发者ID:spyder-ide,项目名称:conda-manager,代码行数:28,代码来源:qthelpers.py

示例15: openMenu

# 需要导入模块: from qtpy import QtWidgets [as 别名]
# 或者: from qtpy.QtWidgets import QAction [as 别名]
def openMenu(self,position):
        indexes = self.ui.treeWidget.selectedIndexes()
        item = self.ui.treeWidget.itemAt(position)
        db_origin = ""
        #if item.parent():
         #   db_origin = item.parent().text(0)
        collec = item.text(0)
        if len(indexes) > 0:
            level = 0
            index = indexes[0]
            while index.parent().isValid():
                index = index.parent()
                level = level + 1
            menu = QMenu()
            #print((collec, db_origin))
            if level ==0:
                pass
            else:
                #keyarray = GetKeys(collec, db_origin)
                #if "Open" in keyarray:
                if self.ui.combobox.currentText()==u"K线":
                    menu.addAction(QAction("Kline", menu, checkable=True))
                    menu.addAction(QAction("Open", menu, checkable=True))
                    menu.addAction(QAction("Close", menu, checkable=True))#open up different menu with different kind of graphs
                    menu.addAction(QAction("High", menu, checkable=True))
                    menu.addAction(QAction("Low", menu, checkable=True))
                    menu.addAction(QAction("Volume", menu, checkable=True))
                    #menu.addAction(QAction("P_change", menu, checkable=True))
                    #menu.addAction(QAction("Turnover",menu,checkable=True))
                if self.ui.combobox.currentText()==u"复权":
                    menu.addAction(QAction("Kline", menu, checkable=True))
                    menu.addAction(QAction("Open", menu, checkable=True))
                    menu.addAction(QAction("Close", menu, checkable=True))
                    menu.addAction(QAction("High", menu, checkable=True))
                    menu.addAction(QAction("Low", menu, checkable=True))
                    menu.addAction(QAction("Volume", menu, checkable=True))
                    menu.addAction(QAction("Amount", menu, checkable=True))
                if self.ui.combobox.currentText()==u"分笔数据":
                    menu.addAction(QAction("分笔", menu, checkable=True))
                if self.ui.combobox.currentText()==u"历史分钟":
                    menu.addAction(QAction("Kline", menu, checkable=True))
                    menu.addAction(QAction("Open", menu, checkable=True))
                    menu.addAction(QAction("Close", menu, checkable=True))
                    menu.addAction(QAction("High", menu, checkable=True))
                    menu.addAction(QAction("Low", menu, checkable=True))
                    menu.addAction(QAction("Volume", menu, checkable=True))
                    menu.addAction(QAction("Amount", menu, checkable=True))
                if self.ui.combobox.currentText()==u"十大股东":
                    menu.addAction(QAction("季度饼图", menu, checkable=True))
                    #menu.addAction(QAction("持股比例", menu, checkable=True))
                #for g in keyarray:
                #menu.addAction(QAction(g, menu, checkable=True))
        menu.triggered.connect(lambda action: self.methodSelected(action, collec))
        menu.exec_(self.ui.treeWidget.viewport().mapToGlobal(position)) 
开发者ID:Seedarchangel,项目名称:TuChart,代码行数:56,代码来源:main.py


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