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


Python QtGui.QShortcut类代码示例

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


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

示例1: define_global_shortcuts

    def define_global_shortcuts(self):
        sequence = {
            'Ctrl+Shift+Left': self.view_container.prev_chapter,
            'Ctrl+Left': self.view_container.first_page,
            'Left': self.view_container.page_up,
            'Right': self.view_container.page_down,
            'Space': self.view_container.page_down,
            'Ctrl+Right': self.view_container.last_page,
            'Ctrl+Shift+Right': self.view_container.next_chapter,
            'Ctrl+R': self.view_container.rotate_right,
            'Ctrl+Shift+R': self.view_container.rotate_left,
            'Ctrl+B': self.view_container.first_page,
            'Ctrl+E': self.view_container.last_page,
            'S': self.switch_double_page_direction,
            'D': self.switch_double_page,
            'M': self.switch_viewing_modes,
            '1': self.view_container.original_fit,
            '2': self.view_container.vertical_fit,
            '3': self.view_container.horizontal_fit,
            '4': self.view_container.best_fit,
            'Q': self.close,
        }

        for key, value in sequence.items():
            s = QShortcut(QKeySequence(key), self.view_container, value)
            s.setEnabled(True)
            self.global_shortcuts.append(s)
开发者ID:CruizeMissile,项目名称:Shiro,代码行数:27,代码来源:reading_window.py

示例2: _shortcutHelper

 def _shortcutHelper(self, keySequence, group, description, parent, function, context = None, enabled = None):
     shortcut = QShortcut(QKeySequence(keySequence), parent, member=function, ambiguousMember=function)
     if context != None:
         shortcut.setContext(context)
     if enabled != None:
         shortcut.setEnabled(True)
     return shortcut, group, description
开发者ID:lcroitor,项目名称:volumeeditor,代码行数:7,代码来源:volumeEditorWidget.py

示例3: __init__

    def __init__(self, fileBrowser):
        QTreeView.__init__(self, fileBrowser)

        self._fileBrowser = fileBrowser

        self.setAttribute( Qt.WA_MacShowFocusRect, False )
        self.setAttribute( Qt.WA_MacSmallSize )
        self.setContextMenuPolicy( Qt.ActionsContextMenu )
        self.setHeaderHidden( True )
        self.setUniformRowHeights( True )
        self.setTextElideMode(Qt.ElideMiddle)

        # dir model
        self._dirsModel = _FileSystemModel( self )
        self._dirsModel.setNameFilterDisables( False )
        self._dirsModel.setFilter( QDir.AllDirs | QDir.AllEntries | QDir.CaseSensitive | QDir.NoDotAndDotDot )
        # self._dirsModel.directoryLoaded.connect(self.setFocus)  TODO don't have this signal in my Qt version

        # create proxy model
        self._filteredModel = FileBrowserFilteredModel( self )
        self._filteredModel.setSourceModel( self._dirsModel )

        self.setModel( self._filteredModel)

        if not sys.platform.startswith('win'):
            self._dirsModel.setRootPath( "/" )
        else:
            self._dirsModel.setRootPath('')

        # shortcut accessible only when self._tree has focus
        self._upShortcut = QShortcut( QKeySequence( "BackSpace" ), self )
        self._upShortcut.setContext( Qt.WidgetShortcut )
        self._upShortcut.activated.connect(self.moveUp)

        # shortcut accessible only when self._tree has focus
        self._homeShortcut = QShortcut( QKeySequence( "`" ), self )
        self._homeShortcut.setContext( Qt.WidgetShortcut )
        self._homeShortcut.activated.connect(self._goUserHomeDir)

        # shortcut accessible only when self._tree has focus
        self._homeShortcut = QShortcut( QKeySequence( "." ), self )
        self._homeShortcut.setContext( Qt.WidgetShortcut )
        self._homeShortcut.activated.connect(self._goCurrentDir)

        self.activated.connect(self._onActivated)
        self._fileActivated.connect(fileBrowser.fileActivated)

        # QDirModel loads item asynchronously, therefore we need timer for setting focus to the first item
        self._setFocusTimer = QTimer()
        self._setFocusTimer.timeout.connect(self._setFirstItemAsCurrent)
        self._setFocusTimer.setInterval(50)
        self.destroyed.connect(self._setFocusTimer.stop)
        self._timerAttempts = 0
开发者ID:adjustive,项目名称:enki,代码行数:53,代码来源:filebrowser.py

示例4: __init__

 def __init__(self, parent, actions=None):
     QTabWidget.__init__(self, parent)
     tab_bar = TabsBase(self, parent)
     self.connect(tab_bar, SIGNAL('move_tab(int,int)'), self.move_tab)
     self.connect(tab_bar, SIGNAL('move_tab(long,int,int)'),
                  self.move_tab_from_another_tabwidget)
     self.setTabBar(tab_bar)
     self.menu = QMenu(self)
     if actions:
         add_actions(self.menu, actions)
     self.index_history = []
     self.connect(self, SIGNAL('currentChanged(int)'),
                  self.__current_changed)
     tabsc = QShortcut(QKeySequence("Ctrl+Tab"), parent, self.tab_navigate)
     tabsc.setContext(Qt.WidgetWithChildrenShortcut)
开发者ID:Brainsciences,项目名称:luminoso,代码行数:15,代码来源:tabs.py

示例5: __init__

    def __init__(self, name):
        QWebView.__init__(self)
        self.setPage(PlotWebPage(name))
        self.setRenderHint(QPainter.Antialiasing, True)
        self.setContextMenuPolicy(Qt.NoContextMenu)
        self.settings().setAttribute(QWebSettings.JavascriptEnabled, True)
        self.settings().setAttribute(QWebSettings.LocalContentCanAccessFileUrls, True)
        self.settings().setAttribute(QWebSettings.LocalContentCanAccessRemoteUrls, True)
        self.settings().clearMemoryCaches()

        self.__inspector_window = None

        shortcut = QShortcut(self)
        shortcut.setKey(Qt.Key_F12)
        shortcut.activated.connect(self.toggleInspector)
开发者ID:YingfangZhou,项目名称:ert,代码行数:15,代码来源:plot_panel.py

示例6: DockWidget

class DockWidget(QDockWidget):
    """Extended QDockWidget for Enki main window
    """
    def __init__(self, *args):
        QDockWidget.__init__(self, *args)

        self._showAction = None
        self._titleBar = _TitleBar( self )
        self.setTitleBarWidget( self._titleBar )
        
        self._closeShortcut = QShortcut( QKeySequence( "Esc" ), self )
        self._closeShortcut.setContext( Qt.WidgetWithChildrenShortcut )
        self._closeShortcut.activated.connect(self._hide)

    def showAction(self):
        """Action shows the widget and set focus on it.
        
        Add this action to the main menu
        """
        if  not self._showAction :
            self._showAction = QAction(self.windowIcon(), self.windowTitle(), self)
            self._showAction.triggered.connect(self.show)
            self._showAction.triggered.connect(self._handleFocusProxy)

        return self._showAction

    def titleBarWidget(self):
        """QToolBar on the title.
        
        You may add own actions to this tool bar
        """
        # method was added only for documenting
        return QDockWidget.titleBarWidget(self)
    
    def _handleFocusProxy(self):
        """Set focus to focus proxy.
        Called after widget has been shown
        """
        if self.focusProxy() is not None:
            self.setFocus()

    def _hide(self):
        """Hide and return focus to MainWindow focus proxy
        """
        self.hide()
        if self.parent() is not None and \
           self.parent().focusProxy() is not None:
            self.parent().focusProxy().setFocus()
开发者ID:daffodil,项目名称:enki,代码行数:48,代码来源:dockwidget.py

示例7: __init__

    def __init__(self, plugin):
        QFrame.__init__(self, core.workspace())
        self._mode = None
        self.plugin = plugin
        from PyQt4 import uic  # lazy import for better startup performance

        uic.loadUi(os.path.join(os.path.dirname(__file__), "SearchWidget.ui"), self)

        self.cbSearch.setCompleter(None)
        self.cbReplace.setCompleter(None)
        self.cbMask.setCompleter(None)

        self.fsModel = QDirModel(self.cbPath.lineEdit())
        self.fsModel.setFilter(QDir.AllDirs | QDir.NoDotAndDotDot)
        self.cbPath.lineEdit().setCompleter(QCompleter(self.fsModel, self.cbPath.lineEdit()))
        # TODO QDirModel is deprecated but QCompleter does not yet handle
        # QFileSystemodel - please update when possible."""
        self.cbSearch.setCompleter(None)
        self.pbSearchStop.setVisible(False)
        self.pbReplaceCheckedStop.setVisible(False)

        self._progress = QProgressBar(self)
        self._progress.setAlignment(Qt.AlignCenter)
        self._progress.setToolTip(self.tr("Search in progress..."))
        self._progress.setMaximumSize(QSize(80, 16))
        core.mainWindow().statusBar().insertPermanentWidget(1, self._progress)
        self._progress.setVisible(False)

        # cd up action
        self.tbCdUp = QToolButton(self.cbPath.lineEdit())
        self.tbCdUp.setIcon(QIcon(":/enkiicons/go-up.png"))
        self.tbCdUp.setCursor(Qt.ArrowCursor)
        self.tbCdUp.installEventFilter(self)  # for drawing button

        self.cbSearch.installEventFilter(self)  # for catching Tab and Shift+Tab
        self.cbReplace.installEventFilter(self)  # for catching Tab and Shift+Tab
        self.cbPath.installEventFilter(self)  # for catching Tab and Shift+Tab
        self.cbMask.installEventFilter(self)  # for catching Tab and Shift+Tab

        self._closeShortcut = QShortcut(QKeySequence("Esc"), self)
        self._closeShortcut.setContext(Qt.WidgetWithChildrenShortcut)
        self._closeShortcut.activated.connect(self.hide)

        # connections
        self.cbSearch.lineEdit().textChanged.connect(self._onSearchRegExpChanged)

        self.cbSearch.lineEdit().returnPressed.connect(self._onReturnPressed)
        self.cbReplace.lineEdit().returnPressed.connect(self._onReturnPressed)
        self.cbPath.lineEdit().returnPressed.connect(self._onReturnPressed)
        self.cbMask.lineEdit().returnPressed.connect(self._onReturnPressed)

        self.cbRegularExpression.stateChanged.connect(self._onSearchRegExpChanged)
        self.cbCaseSensitive.stateChanged.connect(self._onSearchRegExpChanged)

        self.tbCdUp.clicked.connect(self._onCdUpPressed)

        core.mainWindow().hideAllWindows.connect(self.hide)
        core.workspace().currentDocumentChanged.connect(
            lambda old, new: self.setVisible(self.isVisible() and new is not None)
        )
开发者ID:rolandschulz,项目名称:enki,代码行数:60,代码来源:searchwidget.py

示例8: __init__

    def __init__(self, parent, history_filename, profile=False):
        ShellBaseWidget.__init__(self, parent, history_filename, profile)
        TracebackLinksMixin.__init__(self)
        InspectObjectMixin.__init__(self)

        # Local shortcuts
        self.inspectsc = QShortcut(QKeySequence("Ctrl+I"), self,
                                   self.inspect_current_object)
        self.inspectsc.setContext(Qt.WidgetWithChildrenShortcut)
开发者ID:koll00,项目名称:Gui_SM,代码行数:9,代码来源:shell.py

示例9: __init__

 def __init__(self, parent, mainwin):
     QWebView.__init__(self, parent)
     self.mainwin = mainwin
     self.setUrl(QUrl("about:blank"))
     self.setObjectName("webview")
     self.setTextSizeMultiplier(self.ZOOM_DEFAULT)
     shortcut = QShortcut(QKeySequence.ZoomIn, self)
     shortcut.activated.connect(self._zoom_in)
     shortcut.setContext(Qt.WidgetShortcut)
     shortcut = QShortcut(QKeySequence(Qt.CTRL | Qt.Key_Equal), self)
     shortcut.activated.connect(self._zoom_neutral)
     shortcut.setContext(Qt.WidgetShortcut)
     shortcut = QShortcut(QKeySequence.ZoomOut, self)
     shortcut.activated.connect(self._zoom_out)
     shortcut.setContext(Qt.WidgetShortcut)
开发者ID:eblot,项目名称:ezsphinx,代码行数:15,代码来源:web.py

示例10: __init__

    def __init__(self, *args):
        QDockWidget.__init__(self, *args)

        self._showAction = None
        self._titleBar = _TitleBar( self )
        self.setTitleBarWidget( self._titleBar )
        
        self._closeShortcut = QShortcut( QKeySequence( "Esc" ), self )
        self._closeShortcut.setContext( Qt.WidgetWithChildrenShortcut )
        self._closeShortcut.activated.connect(self._hide)
开发者ID:daffodil,项目名称:enki,代码行数:10,代码来源:dockwidget.py

示例11: __init__

 def __init__(self, parent, actions=None):
     BaseTabs.__init__(self, parent, actions)
     tab_bar = TabBar(self, parent)
     self.connect(tab_bar, SIGNAL('move_tab(int,int)'), self.move_tab)
     self.connect(tab_bar, SIGNAL('move_tab(long,int,int)'),
                  self.move_tab_from_another_tabwidget)
     self.setTabBar(tab_bar)
     self.index_history = []
     self.connect(self, SIGNAL('currentChanged(int)'),
                  self.__current_changed)
     tabsc = QShortcut(QKeySequence("Ctrl+Tab"), parent, self.tab_navigate)
     tabsc.setContext(Qt.WidgetWithChildrenShortcut)
     # Browsing tabs button
     browse_button = create_toolbutton(self,
                                       icon=get_icon("browse_tab.png"),
                                       tip=translate("Tabs", "Browse tabs"))
     self.browse_tabs_menu = QMenu(self)
     browse_button.setMenu(self.browse_tabs_menu)
     browse_button.setPopupMode(browse_button.InstantPopup)
     self.connect(self.browse_tabs_menu, SIGNAL("aboutToShow()"),
                  self.update_browse_tabs_menu)
     self.setCornerWidget(browse_button)
开发者ID:cheesinglee,项目名称:spyder,代码行数:22,代码来源:tabs.py

示例12: setup_model_buttons

def setup_model_buttons(self):
    bhbl = QHBoxLayout()
    bhbl.setSpacing(default_button_spacing)
    for button_item in extra_buttons:
        b = QPushButton(button_item["label"])
        b.setToolTip(_("Change Note Type to {note_name}.").format(
                note_name=button_item["note_name"]))
        l = lambda s=self, nn=button_item["note_name"]: change_model_to(s, nn)
        try:
            s = QShortcut(
                QKeySequence(_(button_item["shortcut"])), self.widget)
        except KeyError:
            pass
        else:
            s.connect(s, SIGNAL("activated()"), l)
        try:
            b.setFixedWidth(button_item["button_width"])
        except KeyError:
            b.setFixedWidth(default_button_width)
        bhbl.addWidget(b)
        self.connect(b, SIGNAL("clicked()"), l)
    self.addLayout(bhbl)
开发者ID:steveaw,项目名称:anki_addons,代码行数:22,代码来源:addcards_quick_change_notes.py

示例13: setup_buttons

def setup_buttons(chooser, buttons, text, do_function):
    bhbl = QHBoxLayout()
    if not isMac:
        bhbl.setSpacing(0)
    for button_item in buttons:
        b = QPushButton(button_item["label"])
        b.setToolTip(
            _("Change {what} to {name}.").format(
                what=text, name=button_item["name"]))
        l = lambda s=chooser, nn=button_item["name"]: do_function(s, nn)
        try:
            s = QShortcut(
                QKeySequence(_(button_item["shortcut"])), chooser.widget)
        except KeyError:
            pass
        else:
            s.connect(s, SIGNAL("activated()"), l)
        if isMac:
            b.setStyleSheet("padding: 5px; padding-right: 7px;")
        bhbl.addWidget(b)
        chooser.connect(b, SIGNAL("clicked()"), l)
    chooser.addLayout(bhbl)
开发者ID:JeffDonovan,项目名称:anki-addons,代码行数:22,代码来源:Quick+note+and+deck+buttons.py

示例14: initShortcuts

    def initShortcuts(self):
        (ctrl, shift) = (self.SCMOD_CTRL << 16, self.SCMOD_SHIFT << 16)

        # Disable some shortcuts
        self.SendScintilla(QsciScintilla.SCI_CLEARCMDKEY, ord('D') + ctrl)
        self.SendScintilla(QsciScintilla.SCI_CLEARCMDKEY, ord('L') + ctrl)
        self.SendScintilla(QsciScintilla.SCI_CLEARCMDKEY, ord('L') + ctrl
                           + shift)
        self.SendScintilla(QsciScintilla.SCI_CLEARCMDKEY, ord('T') + ctrl)

        #self.SendScintilla(QsciScintilla.SCI_CLEARCMDKEY, ord("Z") + ctrl)
        #self.SendScintilla(QsciScintilla.SCI_CLEARCMDKEY, ord("Y") + ctrl)

        # Use Ctrl+Space for autocompletion
        self.shortcutAutocomplete = QShortcut(QKeySequence(Qt.CTRL
                                                           + Qt.Key_Space), self)
        self.shortcutAutocomplete.setContext(Qt.WidgetShortcut)
        self.shortcutAutocomplete.activated.connect(self.autoComplete)
开发者ID:HeatherHillers,项目名称:QGIS,代码行数:18,代码来源:ScriptEdit.py

示例15: __init__

 def __init__(self, parent, mainwin):
     QPlainTextEdit.__init__(self, parent)
     self.mainwin = mainwin
     self.setObjectName("restedit")
     self._formats = {}
     self.textChanged.connect(self._restedit_update)
     self.blockCountChanged.connect(self._blockcount_update)
     shortcut = QShortcut(QKeySequence("Ctrl+T"), self)
     shortcut.activated.connect(self._choose_font)
     shortcut = QShortcut(QKeySequence.ZoomIn, self)
     shortcut.activated.connect(self._zoom_in)
     shortcut.setContext(Qt.WidgetShortcut)
     shortcut = QShortcut(QKeySequence.ZoomOut, self)
     shortcut.activated.connect(self._zoom_out)
     shortcut.setContext(Qt.WidgetShortcut)
     self._doc = QApplication.instance().rest
     self._last_warnings = {} # should be moved to the document
开发者ID:eblot,项目名称:ezsphinx,代码行数:17,代码来源:restedit.py


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