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


Python QApplication.focusWidget方法代码示例

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


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

示例1: data

# 需要导入模块: from spyderlib.qt.QtGui import QApplication [as 别名]
# 或者: from spyderlib.qt.QtGui.QApplication import focusWidget [as 别名]
    def data(self, index, role=Qt.DisplayRole):
        """Qt Override."""
        row = index.row()
        if not index.isValid() or not (0 <= row < len(self.shortcuts)):
            return to_qvariant()

        shortcut = self.shortcuts[row]
        key = shortcut.key
        column = index.column()

        if role == Qt.DisplayRole:
            if column == CONTEXT:
                return to_qvariant(shortcut.context)
            elif column == NAME:
                color = self.text_color
                if self._parent == QApplication.focusWidget():
                    if self.current_index().row() == row:
                        color = self.text_color_highlight
                    else:
                        color = self.text_color
                text = self.rich_text[row]
                text = '<p style="color:{0}">{1}</p>'.format(color, text)
                return to_qvariant(text)
            elif column == SEQUENCE:
                text = QKeySequence(key).toString(QKeySequence.NativeText)
                return to_qvariant(text)
            elif column == SEARCH_SCORE:
                # Treating search scores as a table column simplifies the
                # sorting once a score for a specific string in the finder
                # has been defined. This column however should always remain
                # hidden.
                return to_qvariant(self.scores[row])
        elif role == Qt.TextAlignmentRole:
            return to_qvariant(int(Qt.AlignHCenter | Qt.AlignVCenter))
        return to_qvariant()
开发者ID:AminJamalzadeh,项目名称:spyder,代码行数:37,代码来源:shortcuts.py

示例2: data

# 需要导入模块: from spyderlib.qt.QtGui import QApplication [as 别名]
# 或者: from spyderlib.qt.QtGui.QApplication import focusWidget [as 别名]
    def data(self, index, role=Qt.DisplayRole):
        """Qt Override"""
        if not index.isValid() or \
           not (0 <= index.row() < len(self.shortcuts)):
            return to_qvariant()

        shortcut = self.shortcuts[index.row()]
        key = shortcut.key
        column = index.column()

        if role == Qt.DisplayRole:
            if column == CONTEXT:
                return to_qvariant(shortcut.context)
            elif column == NAME:
                color = self.text_color
                if self._parent == QApplication.focusWidget():
                    if self.current_index().row() == index.row():
                        color = self.text_color_highlight
                    else:
                        color = self.text_color
                return to_qvariant(self._enrich_text(shortcut.name, color))
            elif column == SEQUENCE:
                text = QKeySequence(key).toString(QKeySequence.NativeText)
                return to_qvariant(text)
        elif role == Qt.TextAlignmentRole:
            return to_qvariant(int(Qt.AlignHCenter | Qt.AlignVCenter))
        return to_qvariant()
开发者ID:ptocca,项目名称:spyder,代码行数:29,代码来源:shortcuts.py

示例3: findinfiles_callback

# 需要导入模块: from spyderlib.qt.QtGui import QApplication [as 别名]
# 或者: from spyderlib.qt.QtGui.QApplication import focusWidget [as 别名]
 def findinfiles_callback(self):
     """Find in files callback"""
     widget = QApplication.focusWidget()
     if not self.ismaximized:
         self.dockwidget.setVisible(True)
         self.dockwidget.raise_()
     text = ''
     from spyderlib.widgets.editor import TextEditBaseWidget
     if isinstance(widget, TextEditBaseWidget):
         if widget.has_selected_text():
             text = widget.get_selected_text()
     self.set_search_text(text)
     if text:
         self.find()
开发者ID:jromang,项目名称:retina-old,代码行数:16,代码来源:findinfiles.py

示例4: findinfiles_callback

# 需要导入模块: from spyderlib.qt.QtGui import QApplication [as 别名]
# 或者: from spyderlib.qt.QtGui.QApplication import focusWidget [as 别名]
 def findinfiles_callback(self):
     """Find in files callback"""
     widget = QApplication.focusWidget()
     if not self.ismaximized:
         self.dockwidget.setVisible(True)
         self.dockwidget.raise_()
     text = ''
     try:
         if widget.has_selected_text():
             text = widget.get_selected_text()
     except AttributeError:
         # This is not a text widget deriving from TextEditBaseWidget
         pass
     self.set_search_text(text)
     if text:
         self.find()
开发者ID:jromang,项目名称:spyderlib,代码行数:18,代码来源:findinfiles.py

示例5: run_c2pwp

# 需要导入模块: from spyderlib.qt.QtGui import QApplication [as 别名]
# 或者: from spyderlib.qt.QtGui.QApplication import focusWidget [as 别名]
    def run_c2pwp(self):
        """Prompt the user to load a combine archive, translate to Python, and display in a new window"""
        editorwindow = None #Used in editor.load
        processevents=True  #Used in editor.load
        editor = self.main.editor
        basedir = getcwd()
        if CONF.get('workingdir', 'editor/open/browse_scriptdir'):
            c_fname = editor.get_current_filename()
            if c_fname is not None and c_fname != editor.TEMPFILE_PATH:
                basedir = os.path.dirname(c_fname)
        editor.emit(SIGNAL('redirect_stdio(bool)'), False)
        parent_widget = editor.get_current_editorstack()
        selectedfilter = ''
        filters = 'Combine archives (*.zip *.omex);;All files (*.*)'
        filenames, _selfilter = getopenfilenames(parent_widget,
                                     _("Open combine archive"), basedir, filters,
                                     selectedfilter=selectedfilter)
        editor.emit(SIGNAL('redirect_stdio(bool)'), True)
        if filenames:
            filenames = [os.path.normpath(fname) for fname in filenames]
            if CONF.get('workingdir', 'editor/open/auto_set_to_basedir'):
                directory = os.path.dirname(filenames[0])
                editor.emit(SIGNAL("open_dir(QString)"), directory)
        else:
            #The file dialog box was closed without selecting a file.
            return
        focus_widget = QApplication.focusWidget()
        if editor.dockwidget and not editor.ismaximized and\
           (not editor.dockwidget.isAncestorOf(focus_widget)\
            and not isinstance(focus_widget, CodeEditor)):
            editor.dockwidget.setVisible(True)
            editor.dockwidget.setFocus()
            editor.dockwidget.raise_()
        
        def _convert(fname):
            fname = os.path.abspath(encoding.to_unicode_from_fs(fname))
            if os.name == 'nt' and len(fname) >= 2 and fname[1] == ':':
                fname = fname[0].upper()+fname[1:]
            return fname

        if hasattr(filenames, 'replaceInStrings'):
            # This is a QStringList instance (PyQt API #1), converting to list:
            filenames = list(filenames)
        if not isinstance(filenames, list):
            filenames = [_convert(filenames)]
        else:
            filenames = [_convert(fname) for fname in list(filenames)]
        
        for index, filename in enumerate(filenames):
            p = re.compile( '(.zip$|.omex$)')
            pythonfile = p.sub( '.py', filename)
            if (pythonfile == filename):
                pythonfile = filename + ".py"
            current_editor = editor.set_current_filename(pythonfile, editorwindow)
            if current_editor is not None:
                # -- TODO:  Do not open an already opened file
                pass
            else:
                # -- Not an existing opened file:
                if not os.path.isfile(filename):
                    continue
                # --
                current_es = editor.get_current_editorstack(editorwindow)

                # Creating the editor widget in the first editorstack (the one
                # that can't be destroyed), then cloning this editor widget in
                # all other editorstacks:
                finfo, newname = self.load_and_translate(filename, pythonfile, editor)
                finfo.path = editor.main.get_spyder_pythonpath()
                editor._clone_file_everywhere(finfo)
                current_editor = current_es.set_current_filename(newname)
                #if (current_editor is not None):
                #    editor.register_widget_shortcuts("Editor", current_editor)
                
                current_es.analyze_script()

            if (current_editor is not None):
                current_editor.clearFocus()
                current_editor.setFocus()
                current_editor.window().raise_()
            if processevents:
                QApplication.processEvents()
开发者ID:kirichoi,项目名称:spyderplugins,代码行数:84,代码来源:p_import_combine_phrasedml.py

示例6: get_focus_client

# 需要导入模块: from spyderlib.qt.QtGui import QApplication [as 别名]
# 或者: from spyderlib.qt.QtGui.QApplication import focusWidget [as 别名]
 def get_focus_client(self):
     """Return current client with focus, if any"""
     widget = QApplication.focusWidget()
     for client in self.get_clients():
         if widget is client or widget is client.get_control():
             return client
开发者ID:Poneyo,项目名称:spyderlib,代码行数:8,代码来源:ipythonconsole.py


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