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


Python QtGui.QAction方法代码示例

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


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

示例1: keyReleaseEvent

# 需要导入模块: from PyQt4 import QtGui [as 别名]
# 或者: from PyQt4.QtGui import QAction [as 别名]
def keyReleaseEvent(self,e):
        # Ctrl key changes mouse cursor
        if e.key() == QtCore.Qt.Key_Control:
            QtGui.QApplication.restoreOverrideCursor()
        # check for zero to release temporary zero
        # somehow, for the numpad key in some machines, a check on Insert is needed aswell
        elif e.key() == QtCore.Qt.Key_0 or e.key() == QtCore.Qt.Key_Insert:
            self.transpTempZero = False
            self.update()

    #############################
    ## Little helper methods
    #############################

    # Helper method that sets tooltip and statustip
    # Provide an QAction and the tip text
    # This text is appended with a hotkeys and then assigned 
开发者ID:pierluigiferrari,项目名称:fcn8s_tensorflow,代码行数:19,代码来源:cityscapesLabelTool.py

示例2: menuViewsNew_Click

# 需要导入模块: from PyQt4 import QtGui [as 别名]
# 或者: from PyQt4.QtGui import QAction [as 别名]
def menuViewsNew_Click(self, event):

    # Ask for views's name
    enteredText, ok = QtGui.QInputDialog.getText(self, "Input Dialog", "Enter views' name:")
    if ok:
      view = View()
      view.name = enteredText
      view.menu = QtGui.QAction(self)
      view.menu.setText(view.name)
      view.menu.setCheckable(True)
      view.menu.triggered.connect(self.menuView_Click)

      Global.views.append(view)
      self.menuViews.addAction(view.menu)

      self.selectView(view.menu) 
开发者ID:htm-community,项目名称:nupic.studio,代码行数:18,代码来源:simulation_form.py

示例3: setupMenuSmoothing

# 需要导入模块: from PyQt4 import QtGui [as 别名]
# 或者: from PyQt4.QtGui import QAction [as 别名]
def setupMenuSmoothing(self):
        # unfortunately Qt Designer doesn't support QActionGroup, we have to code it up
        self.uiMenuSmoothingGroup = QtGui.QActionGroup(self.uiSmoothingMenu, exclusive=True)

        def onSmoothingToggled(boolean):
            if boolean:
                result = re.search(r'[0-9]+', self.sender().text())
                if result:
                    Settings.setValue(Settings.SMOOTHING, result.group(0))

        desc = defaultdictinit({0: ' More jerky', 1: ' Default', 10: ' Laggy'})
        for smooth in range(11):
            act = QtGui.QAction('&' + str(smooth) + desc[smooth], self)
            act.setCheckable(True)
            act.toggled.connect(onSmoothingToggled)
            self.uiSmoothingMenu.addAction(self.uiMenuSmoothingGroup.addAction(act))
            cleanname = self.buildInSmoothingToActionName(smooth)
            setattr(self, cleanname, act) 
开发者ID:doctorguile,项目名称:pyqtggpo,代码行数:20,代码来源:ggpowindow.py

示例4: __init__

# 需要导入模块: from PyQt4 import QtGui [as 别名]
# 或者: from PyQt4.QtGui import QAction [as 别名]
def __init__(self, *args, **kwargs):
        super(EmoticonDialog, self).__init__(*args, **kwargs)
        saved = Settings.value(Settings.EMOTICON_DIALOG_GEOMETRY)
        if saved:
            self.restoreGeometry(saved)
        self._value = ''
        flowLayout = FlowLayout(self)
        customEmoticons = Settings.value(Settings.CUSTOM_EMOTICONS)
        if customEmoticons:
            customEmoticons = filter(None, [line.strip()
                                            for line in customEmoticons.split("\n")
                                            if 0 < len(line) < 64])
        else:
            customEmoticons = []
        for emoticon in customEmoticons + _emoticons.split("\n"):
            act = QtGui.QAction(emoticon, self)
            act.triggered.connect(self.onActionTriggered)
            btn = QtGui.QToolButton(self)
            btn.setDefaultAction(act)
            flowLayout.addWidget(btn)
        self.setLayout(flowLayout)
        self.setWindowTitle("Insert emoticon")
        self.accepted.connect(self.saveGeometrySettings)
        self.finished.connect(self.saveGeometrySettings)
        self.rejected.connect(self.saveGeometrySettings) 
开发者ID:doctorguile,项目名称:pyqtggpo,代码行数:27,代码来源:emoticonsdialog.py

示例5: qui_menu

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

示例6: setLang

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

示例7: setLang

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

示例8: qui_menu

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

示例9: get_actual_action_list

# 需要导入模块: from PyQt4 import QtGui [as 别名]
# 或者: from PyQt4.QtGui import QAction [as 别名]
def get_actual_action_list(self, button_widget):
        actionList = []

        action = QAction(self.tr("Save G-Code"), self)
        action.triggered.connect(self.controller.generate_button_pressed)
        actionList.append(action)

        for address in self.controller.list_of_printing_services:
            action_tmp = QAction("Print on %s" % address, self)
            action_tmp.triggered.connect(self.make_action)
            actionList.append(action_tmp)

        action_tmp = QAction("Add OctoPrint", self)
        action_tmp.triggered.connect(self.controller.add_new_octoprint)
        actionList.append(action_tmp)

        return actionList 
开发者ID:prusa3d,项目名称:PrusaControl,代码行数:19,代码来源:gui.py

示例10: initMenubar

# 需要导入模块: from PyQt4 import QtGui [as 别名]
# 或者: from PyQt4.QtGui import QAction [as 别名]
def initMenubar(self):

        menubar = self.menuBar()

        file = menubar.addMenu("File")
        edit = menubar.addMenu("Edit")
        view = menubar.addMenu("View")

        # Add the most important actions to the menubar

        file.addAction(self.newAction)
        file.addAction(self.openAction)
        file.addAction(self.saveAction)
        file.addAction(self.printAction)
        file.addAction(self.previewAction)

        edit.addAction(self.undoAction)
        edit.addAction(self.redoAction)
        edit.addAction(self.cutAction)
        edit.addAction(self.copyAction)
        edit.addAction(self.pasteAction)
        edit.addAction(self.findAction)

        # Toggling actions for the various bars
        toolbarAction = QtGui.QAction("Toggle Toolbar",self)
        toolbarAction.triggered.connect(self.toggleToolbar)

        formatbarAction = QtGui.QAction("Toggle Formatbar",self)
        formatbarAction.triggered.connect(self.toggleFormatbar)

        statusbarAction = QtGui.QAction("Toggle Statusbar",self)
        statusbarAction.triggered.connect(self.toggleStatusbar)

        view.addAction(toolbarAction)
        view.addAction(formatbarAction)
        view.addAction(statusbarAction) 
开发者ID:goldsborough,项目名称:Writer,代码行数:38,代码来源:writer.py

示例11: wheelEvent

# 需要导入模块: from PyQt4 import QtGui [as 别名]
# 或者: from PyQt4.QtGui import QAction [as 别名]
def wheelEvent(self, event):
        ctrlPressed = event.modifiers() & QtCore.Qt.ControlModifier

        deltaDegree = event.delta() / 8 # Rotation in degree
        deltaSteps  = deltaDegree / 15 # Usually one step on the mouse is 15 degrees

        if ctrlPressed:
            self.transp = max(min(self.transp+(deltaSteps*0.1),1.0),0.0)
            self.update()
        else:
            if self.zoom:
                # If shift is pressed, change zoom window size
                if event.modifiers() and QtCore.Qt.Key_Shift:
                    self.zoomSize += deltaSteps * 10
                    self.zoomSize = max( self.zoomSize, 10   )
                    self.zoomSize = min( self.zoomSize, 1000 )
                # Change zoom factor
                else:
                    self.zoomFactor += deltaSteps * 0.05
                    self.zoomFactor = max( self.zoomFactor, 0.1 )
                    self.zoomFactor = min( self.zoomFactor, 10 )
                self.update()


    #############################
    ## Little helper methods
    #############################

    # Helper method that sets tooltip and statustip
    # Provide an QAction and the tip text
    # This text is appended with a hotkeys and then assigned 
开发者ID:pierluigiferrari,项目名称:fcn8s_tensorflow,代码行数:33,代码来源:cityscapesViewer.py

示例12: setupMenuTheme

# 需要导入模块: from PyQt4 import QtGui [as 别名]
# 或者: from PyQt4.QtGui import QAction [as 别名]
def setupMenuTheme(self):
        # unfortunately Qt Designer doesn't support QActionGroup, we have to code it up
        actionTitleShortcuts = set()

        def actionTitle(title):
            shortcutFound = False
            ret = ''
            for c in title:
                l = c.lower()
                if not shortcutFound and l in 'abcdefghijklmnopqrstuvwxy' and l not in actionTitleShortcuts:
                    ret += '&'
                    actionTitleShortcuts.add(l)
                    shortcutFound = True
                ret += c
            return ret

        self.uiMenuThemeGroup = QtGui.QActionGroup(self.uiThemeMenu, exclusive=True)
        self.uiDarkThemeAct = QtGui.QAction(actionTitle("Dark Orange"), self)
        self.uiDarkThemeAct.setCheckable(True)
        self.uiDarkThemeAct.toggled.connect(ColorTheme.setDarkTheme)
        self.uiThemeMenu.addAction(self.uiMenuThemeGroup.addAction(self.uiDarkThemeAct))
        for k in QtGui.QStyleFactory.keys():
            act = QtGui.QAction(actionTitle(k), self)
            act.setCheckable(True)
            act.toggled.connect(self.setStyleCallback(k))
            self.uiThemeMenu.addAction(self.uiMenuThemeGroup.addAction(act))
            cleanname = self.buildInStyleToActionName(k)
            setattr(self, cleanname, act)
        self.uiCustomQssFileAct = QtGui.QAction(actionTitle("Custom Qss stylesheet"), self)
        self.uiCustomQssFileAct.triggered.connect(self.setCustomQss)
        self.uiThemeMenu.addAction(self.uiCustomQssFileAct) 
开发者ID:doctorguile,项目名称:pyqtggpo,代码行数:33,代码来源:ggpowindow.py

示例13: initMenubar

# 需要导入模块: from PyQt4 import QtGui [as 别名]
# 或者: from PyQt4.QtGui import QAction [as 别名]
def initMenubar(self):

      menubar = self.menuBar()

      file = menubar.addMenu("File")
      edit = menubar.addMenu("Edit")
      view = menubar.addMenu("View")

      file.addAction(self.newAction)
      file.addAction(self.openAction)
      file.addAction(self.saveAction)
      file.addAction(self.printAction)
      file.addAction(self.previewAction)

      edit.addAction(self.undoAction)
      edit.addAction(self.redoAction)
      edit.addAction(self.cutAction)
      edit.addAction(self.copyAction)
      edit.addAction(self.pasteAction)

      # Toggling actions for the various bars
      toolbarAction = QtGui.QAction("Toggle Toolbar",self)
      toolbarAction.triggered.connect(self.toggleToolbar)

      formatbarAction = QtGui.QAction("Toggle Formatbar",self)
      formatbarAction.triggered.connect(self.toggleFormatbar)

      statusbarAction = QtGui.QAction("Toggle Statusbar",self)
      statusbarAction.triggered.connect(self.toggleStatusbar)

      view.addAction(toolbarAction)
      view.addAction(formatbarAction)
      view.addAction(statusbarAction) 
开发者ID:goldsborough,项目名称:Writer-Tutorial,代码行数:35,代码来源:part-2.py

示例14: contextMenuEvent

# 需要导入模块: from PyQt4 import QtGui [as 别名]
# 或者: from PyQt4.QtGui import QAction [as 别名]
def contextMenuEvent(self, event):
        pos = event.pos()
        index = self.indexAt(pos)
        menu = widgets.QMenu()

        if index.column() == 0:
            item_name = self.itemAt(pos).text()
            if not item_name:
                return
            action_goto = widgets.QAction(_("Goto data"), menu)
            action_remove = widgets.QAction(_("Remove"), menu)

            action_goto.triggered.connect(lambda state, it=item_name: self.goto_item(it))
            action_remove.triggered.connect(lambda state, it=item_name: self.remove_item(it))

            screenMenu = widgets.QMenu(_("Add to screen"))
            for sn in options.main_window.screennames:
                sa = widgets.QAction(sn, screenMenu)
                sa.triggered.connect(lambda state, name=sn, it=item_name: self.add_to_screen(name, it))
                screenMenu.addAction(sa)

            menu.addActions([action_goto, action_remove])
            menu.addMenu(screenMenu)

            menu.exec_(event.globalPos())
            event.accept() 
开发者ID:cedricp,项目名称:ddt4all,代码行数:28,代码来源:dataeditor.py


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