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


Python QtWidgets.QAction方法代码示例

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


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

示例1: createPullDown

# 需要导入模块: from PySide2 import QtWidgets [as 别名]
# 或者: from PySide2.QtWidgets import QAction [as 别名]
def createPullDown(self, menu, eachPullDown):
        """create the submenu structure to method createMenus"""
        for name, tip, short, icon, handler in eachPullDown:

            if len(name) == 0:
                menu.addSeparator()
                continue

            icon = QtGui.QIcon(ICONS_S + icon)

            logger.debug('HANDLER: {}'.format(handler))

            if 'aboutQt' not in handler:
                handler = 'self.parent.slots.' + handler

            action = QtWidgets.QAction(icon, name, self.parent,
                                       shortcut=short, statusTip=tip,
                                       triggered=eval(handler))
            menu.addAction(action) 
开发者ID:chiefenne,项目名称:PyAero,代码行数:21,代码来源:MenusTools.py

示例2: createTools

# 需要导入模块: from PySide2 import QtWidgets [as 别名]
# 或者: from PySide2.QtWidgets import QAction [as 别名]
def createTools(self):
        """create the toolbar and populate it automatically
         from  method toolData
        """
        # create a tool bar
        self.toolbar = self.parent.addToolBar('Toolbar')

        for tip, icon, handler in self.getToolbarData():
            if len(tip) == 0:
                self.toolbar.addSeparator()
                continue
            icon = QtGui.QIcon(ICONS_L + icon)
            action = QtWidgets.QAction(
                icon, tip, self.parent, triggered=eval(
                    'self.parent.slots.' + handler))
            self.toolbar.addAction(action) 
开发者ID:chiefenne,项目名称:PyAero,代码行数:18,代码来源:MenusTools.py

示例3: onCustomContextMenu

# 需要导入模块: from PySide2 import QtWidgets [as 别名]
# 或者: from PySide2.QtWidgets import QAction [as 别名]
def onCustomContextMenu(self, localPosition: QPoint):
        """
        Show a custom context menu with a "Download file" action when a file is right-clicked.
        :param localPosition: position where the user clicked.
        """
        selectedFile = self.selectedFile()

        if selectedFile is None:
            return

        globalPosition = self.listWidget.mapToGlobal(localPosition)

        downloadAction = QAction("Download file")
        downloadAction.setEnabled(selectedFile.type in [FileSystemItemType.File])
        downloadAction.triggered.connect(self.downloadFile)

        downloadRecursiveAction = QAction("Download files recursively")
        downloadRecursiveAction.setEnabled(selectedFile.type in [FileSystemItemType.Directory])
        downloadRecursiveAction.triggered.connect(self.downloadDirectoryRecursively)

        itemMenu = QMenu()
        itemMenu.addAction(downloadAction)
        itemMenu.addAction(downloadRecursiveAction)

        itemMenu.exec_(globalPosition) 
开发者ID:GoSecure,项目名称:pyrdp,代码行数:27,代码来源:FileSystemWidget.py

示例4: qui_menu

# 需要导入模块: from PySide2 import QtWidgets [as 别名]
# 或者: from PySide2.QtWidgets import QAction [as 别名]
def qui_menu(self, action_list_str, menu_str):
        # qui menu creation
        # syntax: self.qui_menu('right_menu_createFolder_atn;Create Folder,Ctrl+D | right_menu_openFolder_atn;Open Folder', 'right_menu')
        if menu_str not in self.uiList.keys():
            self.uiList[menu_str] = QtWidgets.QMenu()
        create_opt_list = [ x.strip() for x in action_list_str.split('|') ]
        for each_creation in create_opt_list:
            ui_info = [ x.strip() for x in each_creation.split(';') ]
            atn_name = ui_info[0]
            atn_title = ''
            atn_hotkey = ''
            if len(ui_info) > 1:
                options = ui_info[1].split(',')
                atn_title = '' if len(options) < 1 else options[0]
                atn_hotkey = '' if len(options) < 2 else options[1]
            if atn_name != '':
                if atn_name == '_':
                    self.uiList[menu_str].addSeparator()
                else:
                    if atn_name not in self.uiList.keys():
                        self.uiList[atn_name] = QtWidgets.QAction(atn_title, self)
                        if atn_hotkey != '':
                            self.uiList[atn_name].setShortcut(QtGui.QKeySequence(atn_hotkey))
                    self.uiList[menu_str].addAction(self.uiList[atn_name]) 
开发者ID:shiningdesign,项目名称:universal_tool_template.py,代码行数:26,代码来源:universal_tool_template_1116.py

示例5: setLang

# 需要导入模块: from PySide2 import QtWidgets [as 别名]
# 或者: from PySide2.QtWidgets import QAction [as 别名]
def setLang(self, langName):
        uiList_lang_read = self.memoData['lang'][langName]
        for ui_name in uiList_lang_read:
            ui_element = self.uiList[ui_name]
            if type(ui_element) in [ QtWidgets.QLabel, QtWidgets.QPushButton, QtWidgets.QAction, QtWidgets.QCheckBox ]:
                # uiType: QLabel, QPushButton, QAction(menuItem), QCheckBox
                if uiList_lang_read[ui_name] != "":
                    ui_element.setText(uiList_lang_read[ui_name])
            elif type(ui_element) in [ QtWidgets.QGroupBox, QtWidgets.QMenu ]:
                # uiType: QMenu, QGroupBox
                if uiList_lang_read[ui_name] != "":
                    ui_element.setTitle(uiList_lang_read[ui_name])
            elif type(ui_element) in [ QtWidgets.QTabWidget]:
                # uiType: QTabWidget
                tabCnt = ui_element.count()
                if uiList_lang_read[ui_name] != "":
                    tabNameList = uiList_lang_read[ui_name].split(';')
                    if len(tabNameList) == tabCnt:
                        for i in range(tabCnt):
                            if tabNameList[i] != "":
                                ui_element.setTabText(i,tabNameList[i])
            elif type(ui_element) == str:
                # uiType: string for msg
                if uiList_lang_read[ui_name] != "":
                    self.uiList[ui_name] = uiList_lang_read[ui_name] 
开发者ID:shiningdesign,项目名称:universal_tool_template.py,代码行数:27,代码来源:UITranslator.py

示例6: qui_menu

# 需要导入模块: from PySide2 import QtWidgets [as 别名]
# 或者: from PySide2.QtWidgets import QAction [as 别名]
def qui_menu(self, action_list_str, menu_str):
        # qui menu creation
        # syntax: self.qui_menu('right_menu_createFolder_atn;Create Folder,Ctrl+D | right_menu_openFolder_atn;Open Folder', 'right_menu')
        if menu_str not in self.uiList.keys():
            self.uiList[menu_str] = QtWidgets.QMenu()
        create_opt_list = [ x.strip() for x in action_list_str.split('|') ]
        for each_creation in create_opt_list:
            ui_info = [ x.strip() for x in each_creation.split(';') ]
            atn_name = ui_info[0]
            atn_title = ''
            atn_hotkey = ''
            if len(ui_info) > 1:
                options = ui_info[1].split(',')
                atn_title = '' if len(options) < 1 else options[0]
                atn_hotkey = '' if len(options) < 2 else options[1]
            if atn_name != '':
                if atn_name not in self.uiList.keys():
                    self.uiList[atn_name] = QtWidgets.QAction(atn_title, self)
                    if atn_hotkey != '':
                        self.uiList[atn_name].setShortcut(QtGui.QKeySequence(atn_hotkey))
                self.uiList[menu_str].addAction(self.uiList[atn_name]) 
开发者ID:shiningdesign,项目名称:universal_tool_template.py,代码行数:23,代码来源:universal_tool_template_1010.py

示例7: _translate_element

# 需要导入模块: from PySide2 import QtWidgets [as 别名]
# 或者: from PySide2.QtWidgets import QAction [as 别名]
def _translate_element(toolbar, action):
        if isinstance(action, ToolbarSplitter):
            toolbar.addSeparator()
            return None
        elif isinstance(action, ToolbarAction):
            if action.icon is not None:
                act = QAction(action.icon, action.name, toolbar)
            else:
                act = QAction(action.name, toolbar)
            if action.triggered is not None:
                act.triggered.connect(action.triggered)
            if action.tooltip:
                act.setToolTip(action.tooltip)
            act.setCheckable(action.checkable)
            toolbar.addAction(act)
            return act
        else:
            raise TypeError("Bad toolbar action", action) 
开发者ID:angr,项目名称:angr-management,代码行数:20,代码来源:toolbar.py

示例8: initUI

# 需要导入模块: from PySide2 import QtWidgets [as 别名]
# 或者: from PySide2.QtWidgets import QAction [as 别名]
def initUI(self):
		grid = QtWidgets.QGridLayout()
		#Create actions dictionary and group dictionary
		self.atomActionGroup = QtWidgets.QActionGroup(self, exclusive=True)
		self.atomActions = {}								   
		#for atomname in self.editor.atomtypes.keys(): Gives unsorted list
		for key in self.ptable.keys():
			atomname = self.ptable[key]["Symbol"]
			action = QtWidgets.QAction( '%s'%atomname,
								   self, 
								   statusTip="Set atomtype to %s"%atomname,
								   triggered=self.atomtypePush, objectName=atomname,
								   checkable=True)
			self.atomActionGroup.addAction(action)
			self.atomActions[atomname] = action
			if action.objectName() == "C":
				action.setChecked(True)		
		
			button = QtWidgets.QToolButton()
			button.setDefaultAction(action)
			button.setFocusPolicy(QtCore.Qt.NoFocus)
			button.setMaximumWidth(40)
			
			if self.ptable[key]["Group"] != None:
				grid.addWidget(button, self.ptable[key]["Period"], self.ptable[key]["Group"])
			else:
				if key <72:
					grid.addWidget(button, 9, key-54)
				else:
					grid.addWidget(button, 10, key-86)
		#Ensure spacing between main table and actinides/lathanides			
		grid.addWidget(QtWidgets.QLabel(''), 8,1)

		self.setLayout(grid)   
		
		self.move(300, 150)
		self.setWindowTitle('Periodic Table') 
开发者ID:EBjerrum,项目名称:rdeditor,代码行数:39,代码来源:ptable_widget.py

示例9: __init__

# 需要导入模块: from PySide2 import QtWidgets [as 别名]
# 或者: from PySide2.QtWidgets import QAction [as 别名]
def __init__(self, parent=None):
        super(HotboxManagerToolbar, self).__init__(parent)
        self.setIconSize(QtCore.QSize(16, 16))
        self.new = QtWidgets.QAction(icon('manager-new.png'), '', self)
        self.new.setToolTip('Create new hotbox')
        self.new.triggered.connect(self.newRequested.emit)
        self.edit = QtWidgets.QAction(icon('manager-edit.png'), '', self)
        self.edit.setToolTip('Edit hotbox')
        self.edit.triggered.connect(self.editRequested.emit)
        self.delete = QtWidgets.QAction(icon('manager-delete.png'), '', self)
        self.delete.setToolTip('Delete hotbox')
        self.delete.triggered.connect(self.deleteRequested.emit)
        self.link = QtWidgets.QAction(icon('link.png'), '', self)
        self.link.setToolTip('Link to external hotbox file')
        self.link.triggered.connect(self.linkRequested.emit)
        self.unlink = QtWidgets.QAction(icon('unlink.png'), '', self)
        self.unlink.setToolTip('Remove hotbox file link')
        self.unlink.triggered.connect(self.unlinkRequested.emit)
        self.import_ = QtWidgets.QAction(icon('manager-import.png'), '', self)
        self.import_.setToolTip('Import hotbox')
        self.import_.triggered.connect(self.importRequested.emit)
        self.export = QtWidgets.QAction(icon('manager-export.png'), '', self)
        self.export.setToolTip('Export hotbox')
        self.export.triggered.connect(self.exportRequested.emit)
        self.hotkeyset = QtWidgets.QAction(icon('touch.png'), '', self)
        self.hotkeyset.setToolTip('Set hotkey')
        self.hotkeyset.triggered.connect(self.setHotkeyRequested.emit)

        self.addAction(self.new)
        self.addAction(self.edit)
        self.addAction(self.delete)
        self.addSeparator()
        self.addAction(self.link)
        self.addAction(self.unlink)
        self.addSeparator()
        self.addAction(self.import_)
        self.addAction(self.export)
        self.addSeparator()
        self.addAction(self.hotkeyset) 
开发者ID:luckylyk,项目名称:hotbox_designer,代码行数:41,代码来源:manager.py

示例10: setLang

# 需要导入模块: from PySide2 import QtWidgets [as 别名]
# 或者: from PySide2.QtWidgets import QAction [as 别名]
def setLang(self, langName):
        lang_data = self.memoData['lang'][langName]
        for ui_name in lang_data.keys():
            if ui_name in self.uiList.keys() and lang_data[ui_name] != '':
                ui_element = self.uiList[ui_name]
                # '' means no translation availdanle in that data file
                if isinstance(ui_element, (QtWidgets.QLabel, QtWidgets.QPushButton, QtWidgets.QAction, QtWidgets.QCheckBox) ):
                    # uiType: QLabel, QPushButton, QAction(menuItem), QCheckBox
                    ui_element.setText(lang_data[ui_name])
                elif isinstance(ui_element, (QtWidgets.QGroupBox, QtWidgets.QMenu) ):
                    # uiType: QMenu, QGroupBox
                    ui_element.setTitle(lang_data[ui_name])
                elif isinstance(ui_element, QtWidgets.QTabWidget):
                    # uiType: QTabWidget
                    tabCnt = ui_element.count()
                    tabNameList = lang_data[ui_name].split(';')
                    if len(tabNameList) == tabCnt:
                        for i in range(tabCnt):
                            if tabNameList[i] != '':
                                ui_element.setTabText(i,tabNameList[i])
                elif isinstance(ui_element, QtWidgets.QComboBox):
                    # uiType: QComboBox
                    itemCnt = ui_element.count()
                    itemNameList = lang_data[ui_name].split(';')
                    ui_element.clear()
                    ui_element.addItems(itemNameList)
                elif isinstance(ui_element, QtWidgets.QTreeWidget):
                    # uiType: QTreeWidget
                    labelCnt = ui_element.headerItem().columnCount()
                    labelList = lang_data[ui_name].split(';')
                    ui_element.setHeaderLabels(labelList)
                elif isinstance(ui_element, QtWidgets.QTableWidget):
                    # uiType: QTableWidget
                    colCnt = ui_element.columnCount()
                    headerList = lang_data[ui_name].split(';')
                    cur_table.setHorizontalHeaderLabels( headerList )
                elif isinstance(ui_element, (str, unicode) ):
                    # uiType: string for msg
                    self.uiList[ui_name] = lang_data[ui_name] 
开发者ID:shiningdesign,项目名称:universal_tool_template.py,代码行数:41,代码来源:universal_tool_template_1116.py

示例11: qui_atn

# 需要导入模块: from PySide2 import QtWidgets [as 别名]
# 或者: from PySide2.QtWidgets import QAction [as 别名]
def qui_atn(self, ui_name, title, tip=None, icon=None, parent=None, key=None):
        self.uiList[ui_name] = QtWidgets.QAction(title, self)
        if icon!=None:
            self.uiList[ui_name].setIcon(QtGui.QIcon(icon))
        if tip !=None:
            self.uiList[ui_name].setStatusTip(tip)
        if key != None:
            self.uiList[ui_name].setShortcut(QtGui.QKeySequence(key))
        if parent !=None:
            if isinstance(parent, (str, unicode)) and parent in self.uiList.keys():
                self.uiList[parent].addAction(self.uiList[ui_name])
            elif isinstance(parent, QtWidgets.QMenu):
                parent.addAction(self.uiList[ui_name])
        return ui_name 
开发者ID:shiningdesign,项目名称:universal_tool_template.py,代码行数:16,代码来源:universal_tool_template_1116.py

示例12: quickMenuAction

# 需要导入模块: from PySide2 import QtWidgets [as 别名]
# 或者: from PySide2.QtWidgets import QAction [as 别名]
def quickMenuAction(self, objName, title, tip, icon, menuObj):
        self.uiList[objName] = QtWidgets.QAction(QtGui.QIcon(icon), title, self)
        self.uiList[objName].setStatusTip(tip)
        menuObj.addAction(self.uiList[objName]) 
开发者ID:shiningdesign,项目名称:universal_tool_template.py,代码行数:6,代码来源:GearBox_template_1010.py

示例13: quickMenuAction

# 需要导入模块: from PySide2 import QtWidgets [as 别名]
# 或者: from PySide2.QtWidgets import QAction [as 别名]
def quickMenuAction(self, objName, title, tip, icon, menuObj):
        self.uiList[objName] = QtWidgets.QAction(QtGui.QIcon(icon), title, self)        
        self.uiList[objName].setStatusTip(tip)
        menuObj.addAction(self.uiList[objName]) 
开发者ID:shiningdesign,项目名称:universal_tool_template.py,代码行数:6,代码来源:UITranslator.py


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