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


Python QtGui.QAction方法代码示例

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


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

示例1: add_button

# 需要导入模块: from PySide import QtGui [as 别名]
# 或者: from PySide.QtGui import QAction [as 别名]
def add_button(self, **kwargs):

        # so not sure if this is going to work, yay programming!
        # intercept/adjust some of the arguments

        cmd = kwargs.get('command', 'print "No action defined"')
        label = kwargs.get('label', 'Unknown')
        annotation = kwargs.get('annotation', '')
        image = QtGui.QPixmap()

        for (key, val) in kwargs.iteritems():
            if key.startswith("image") and IconFactory.is_icon_path(val):
                image = QtGui.QIcon(self.icon_factory.disk_path(val))

        action = QtGui.QAction(self.widget)
        action.setIcon(image)
        action.setToolTip(annotation)
        action.triggered.connect(lambda: self._exec_cmd(cmd))

        button = QtGui.QToolButton()
        button.setAutoRaise(True)
        button.setDefaultAction(action)
        self.layout.addWidget(button)

    # ------------------------------------------------------------------------- 
开发者ID:Clemson-DPA,项目名称:dpa-pipe,代码行数:27,代码来源:shelf.py

示例2: CustomContextMenuHandler

# 需要导入模块: from PySide import QtGui [as 别名]
# 或者: from PySide.QtGui import QAction [as 别名]
def CustomContextMenuHandler(self, pos):
        menu = QtGui.QMenu(self)
        menu.addAction(QtGui.QAction("Xref ...", self,
                statusTip="List the references where this element is used",
                triggered=self.actionXref))
        menu.addAction(QtGui.QAction("Go to...", self,
                statusTip="Go to element definition",
                triggered=self.actionGoto))
        menu.addAction(QtGui.QAction("Rename...", self,
                statusTip="Rename an element (class, method, ...)",
                triggered=self.actionRename))
        menu.addAction(QtGui.QAction("Info...", self,
                statusTip="Display info of an element (anything useful in the document)",
                triggered=self.actionInfo))
        menu.addAction(QtGui.QAction("Reload sources...", self,
                statusTip="Reload sources (needed when renaming changed other tabs)",
                triggered=self.reload_java_sources))
        menu.addAction(QtGui.QAction("Open bytecodes...", self,
                statusTip="",
                triggered=self.display_bytecodes))
        menu.exec_(QtGui.QCursor.pos()) 
开发者ID:DroidTest,项目名称:TimeMachine,代码行数:23,代码来源:sourcewindow.py

示例3: qui_menu

# 需要导入模块: from PySide import QtGui [as 别名]
# 或者: from PySide.QtGui 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

示例4: setLang

# 需要导入模块: from PySide import QtGui [as 别名]
# 或者: from PySide.QtGui 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

示例5: setLang

# 需要导入模块: from PySide import QtGui [as 别名]
# 或者: from PySide.QtGui 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 [ QtGui.QLabel, QtGui.QPushButton, QtGui.QAction, QtGui.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 [ QtGui.QGroupBox, QtGui.QMenu ]:
                # uiType: QMenu, QGroupBox
                if uiList_lang_read[ui_name] != "":
                    ui_element.setTitle(uiList_lang_read[ui_name])
            elif type(ui_element) in [ QtGui.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_v1.0.py

示例6: qui_menu

# 需要导入模块: from PySide import QtGui [as 别名]
# 或者: from PySide.QtGui 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: setupSortMenu

# 需要导入模块: from PySide import QtGui [as 别名]
# 或者: from PySide.QtGui import QAction [as 别名]
def setupSortMenu(menu,func,func2):
    action = QtGui.QAction(QtGui.QIcon(),"Sort element A~Z",menu)
    QtCore.QObject.connect(action,QtCore.SIGNAL("triggered()"),func)
    menu.addAction(action)
    action = QtGui.QAction(QtGui.QIcon(),"Sort element Z~A",menu)
    QtCore.QObject.connect(
            action,QtCore.SIGNAL("triggered()"),func2)
    menu.addAction(action) 
开发者ID:realthunder,项目名称:FreeCAD_assembly3,代码行数:10,代码来源:assembly.py

示例8: setupContextMenu

# 需要导入模块: from PySide import QtGui [as 别名]
# 或者: from PySide.QtGui import QAction [as 别名]
def setupContextMenu(self,vobj,menu):
        obj = vobj.Object
        action = QtGui.QAction(QtGui.QIcon(),
                "Enable constraint" if obj.Disabled else "Disable constraint", menu)
        QtCore.QObject.connect(
                action,QtCore.SIGNAL("triggered()"),self.toggleDisable)
        menu.addAction(action) 
开发者ID:realthunder,项目名称:FreeCAD_assembly3,代码行数:9,代码来源:assembly.py

示例9: get_QAction

# 需要导入模块: from PySide import QtGui [as 别名]
# 或者: from PySide.QtGui import QAction [as 别名]
def get_QAction():
    """QAction getter."""

    try:
        import PySide.QtGui as QtGui
        return QtGui.QAction
    except ImportError:
        import PyQt5.QtWidgets as QtWidgets
        return QtWidgets.QAction 
开发者ID:AirbusCyber,项目名称:grap,代码行数:11,代码来源:QtShim.py

示例10: createActions

# 需要导入模块: from PySide import QtGui [as 别名]
# 或者: from PySide.QtGui import QAction [as 别名]
def createActions(self):
        self.xrefAct = QtGui.QAction("Xref from/to...", self,
#                shortcut=QtGui.QKeySequence("CTRL+B"),
                statusTip="List the references where this element is used",
                triggered=self.actionXref)
        self.expandAct = QtGui.QAction("Expand...", self,
                statusTip="Expand all the subtrees",
                triggered=self.actionExpand)
        self.collapseAct = QtGui.QAction("Collapse...", self,
                statusTip="Collapse all the subtrees",
                triggered=self.actionCollapse) 
开发者ID:DroidTest,项目名称:TimeMachine,代码行数:13,代码来源:treewindow.py

示例11: setLang

# 需要导入模块: from PySide import QtGui [as 别名]
# 或者: from PySide.QtGui 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

示例12: qui_atn

# 需要导入模块: from PySide import QtGui [as 别名]
# 或者: from PySide.QtGui 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


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