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


Python QtCore.QTimer类代码示例

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


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

示例1: qapplication

def qapplication(translate=True, test_time=3):
    """
    Return QApplication instance
    Creates it if it doesn't already exist
    
    test_time: Time to maintain open the application when testing. It's given
    in seconds
    """
    if running_in_mac_app():
        SpyderApplication = MacApplication
    else:
        SpyderApplication = QApplication
    
    app = SpyderApplication.instance()
    if app is None:
        # Set Application name for Gnome 3
        # https://groups.google.com/forum/#!topic/pyside/24qxvwfrRDs
        app = SpyderApplication(['Spyder'])

        # Set application name for KDE (See issue 2207)
        app.setApplicationName('Spyder')
    if translate:
        install_translator(app)

    test_travis = os.environ.get('TEST_CI_WIDGETS', None)
    if test_travis is not None:
        timer_shutdown = QTimer(app)
        timer_shutdown.timeout.connect(app.quit)
        timer_shutdown.start(test_time*1000)
    return app
开发者ID:AminJamalzadeh,项目名称:spyder,代码行数:30,代码来源:qthelpers.py

示例2: RequestHandler

class RequestHandler(QObject):

    """Handle introspection request.
    """

    introspection_complete = Signal()

    def __init__(self, code_info, plugins):
        super(RequestHandler, self).__init__()
        self.info = code_info
        self.timer = QTimer()
        self.timer.singleShot(LEAD_TIME_SEC * 1000, self._handle_timeout)
        self.waiting = True
        self.pending = {}
        self.result = None
        self.plugins = plugins
        self._start_time = time.time()
        self._threads = {}
        for plugin in plugins:
            self._make_async_call(plugin, code_info)

    def _handle_timeout(self):
        debug_print('got timeout: %s' % self.plugins)
        if self.pending:
            for plugin in self.plugins:
                if plugin.name in self.pending:
                    self._finalize(plugin.name, self.pending[plugin.name])
                    return
        self.waiting = False

    def _handle_incoming(self, name):
        # coerce to a str in case it is a QString
        name = str(name)
        self._threads[name].wait()
        if self.result:
            return
        result = self._threads[name].result
        if name == self.plugins[0].name or not self.waiting:
            if result:
                self._finalize(name, result)
            else:
                debug_print('No valid responses acquired')
                self.introspection_complete.emit()
        else:
            self.pending[name] = result

    def _make_async_call(self, plugin, info):
        """Trigger an introspection job in a thread"""
        self._threads[str(plugin.name)] = thread = IntrospectionThread(plugin, info)
        thread.request_handled.connect(self._handle_incoming)
        thread.start()

    def _finalize(self, name, result):
        self.result = result
        self.waiting = False
        self.pending = None
        delta = time.time() - self._start_time
        debug_print('%s request from %s finished: "%s" in %.1f sec'
            % (self.info.name, name, str(result)[:100], delta))
        self.introspection_complete.emit()
开发者ID:ImadBouirmane,项目名称:spyder,代码行数:60,代码来源:plugin_manager.py

示例3: focusOutEvent

    def focusOutEvent(self, event):
        """Handle focus out event restoring the last valid selected path."""
        # Calling asynchronously the 'add_current_text' to avoid crash
        # https://groups.google.com/group/spyderlib/browse_thread/thread/2257abf530e210bd
        lineedit = self.lineEdit()
        QTimer.singleShot(50, lambda: lineedit.setText(self.selected_text))

        hide_status = getattr(self.lineEdit(), 'hide_status_icon', None)
        if hide_status:
            hide_status()
        QComboBox.focusOutEvent(self, event)
开发者ID:MerouaneBen,项目名称:spyder,代码行数:11,代码来源:comboboxes.py

示例4: follow_directories_loaded

 def follow_directories_loaded(self, fname):
     """Follow directories loaded during startup"""
     if self._to_be_loaded is None:
         return
     path = osp.normpath(to_text_string(fname))
     if path in self._to_be_loaded:
         self._to_be_loaded.remove(path)
     if self._to_be_loaded is not None and len(self._to_be_loaded) == 0 and not is_pyqt46:
         self.fsmodel.directoryLoaded.disconnect(self.follow_directories_loaded)
         if self._scrollbar_positions is not None:
             # The tree view need some time to render branches:
             QTimer.singleShot(50, self.restore_scrollbar_positions)
开发者ID:sonofeft,项目名称:spyder,代码行数:12,代码来源:explorer.py

示例5: follow_directories_loaded

 def follow_directories_loaded(self, fname):
     """Follow directories loaded during startup"""
     if self._to_be_loaded is None:
         return
     path = osp.normpath(unicode(fname))
     if path in self._to_be_loaded:
         self._to_be_loaded.pop(self._to_be_loaded.index(path))
     if self._to_be_loaded is not None and len(self._to_be_loaded) == 0:
         self.disconnect(self.fsmodel, SIGNAL('directoryLoaded(QString)'),
                         self.follow_directories_loaded)
         if self._scrollbar_positions is not None:
             # The tree view need some time to render branches:
             QTimer.singleShot(50, self.restore_scrollbar_positions)
开发者ID:jromang,项目名称:retina-old,代码行数:13,代码来源:explorer.py

示例6: setup

    def setup(self, icon_painter, painter, rect):

        if self.parent_widget not in self.info:
            timer = QTimer()
            timer.timeout.connect(lambda: self._update(self.parent_widget))
            self.info[self.parent_widget] = [timer, 0, self.step]
            timer.start(self.interval)
        else:
            timer, angle, self.step = self.info[self.parent_widget]
            x_center = rect.width() * 0.5
            y_center = rect.height() * 0.5
            painter.translate(x_center, y_center)
            painter.rotate(angle)
            painter.translate(-x_center, -y_center)
开发者ID:ImadBouirmane,项目名称:spyder,代码行数:14,代码来源:animation.py

示例7: BaseTimerStatus

class BaseTimerStatus(StatusBarWidget):
    TITLE = None
    TIP = None
    def __init__(self, parent, statusbar):
        StatusBarWidget.__init__(self, parent, statusbar)
        self.setToolTip(self.TIP)
        layout = self.layout()
        layout.addWidget(QLabel(self.TITLE))
        self.label = QLabel()
        self.label.setFont(self.label_font)
        layout.addWidget(self.label)
        layout.addSpacing(20)
        if self.is_supported():
            self.timer = QTimer()
            self.timer.timeout.connect(self.update_label)
            self.timer.start(2000)
        else:
            self.timer = None
            self.hide()
    
    def set_interval(self, interval):
        """Set timer interval (ms)"""
        if self.timer is not None:
            self.timer.setInterval(interval)
    
    def import_test(self):
        """Raise ImportError if feature is not supported"""
        raise NotImplementedError

    def is_supported(self):
        """Return True if feature is supported"""
        try:
            self.import_test()
            return True
        except ImportError:
            return False
    
    def get_value(self):
        """Return value (e.g. CPU or memory usage)"""
        raise NotImplementedError
        
    def update_label(self):
        """Update status label widget, if widget is visible"""
        if self.isVisible():
            self.label.setText('%d %%' % self.get_value())
开发者ID:ImadBouirmane,项目名称:spyder,代码行数:45,代码来源:status.py

示例8: event

    def event(self, event):
        """Qt Override.

        Filter tab keys and process double tab keys.
        """
        if (event.type() == QEvent.KeyPress) and (event.key() == Qt.Key_Tab):
            self.sig_tab_pressed.emit(True)
            self.numpress += 1
            if self.numpress == 1:
                self.presstimer = QTimer.singleShot(400, self.handle_keypress)
            return True
        return QComboBox.event(self, event)
开发者ID:MerouaneBen,项目名称:spyder,代码行数:12,代码来源:comboboxes.py

示例9: __init__

    def __init__(self, parent, history_filename, debug=False, profile=False):
        """
        parent : specifies the parent widget
        """
        ConsoleBaseWidget.__init__(self, parent)
                
        # Prompt position: tuple (line, index)
        self.current_prompt_pos = None
        self.new_input_line = True
        
        # History
        self.histidx = None
        self.hist_wholeline = False
        assert isinstance(history_filename, (str, unicode))
        self.history_filename = history_filename
        self.history = self.load_history()
        
        # Session
        self.historylog_filename = CONF.get('main', 'historylog_filename',
                                            get_conf_path('history.log'))
        
        # Context menu
        self.menu = None
        self.setup_context_menu()

        # Debug mode
        self.debug = debug

        # Simple profiling test
        self.profile = profile
        
        # Buffer to increase performance of write/flush operations
        self.__buffer = []
        self.__timestamp = 0.0
        self.__flushtimer = QTimer(self)
        self.__flushtimer.setSingleShot(True)
        self.connect(self.__flushtimer, SIGNAL('timeout()'), self.flush)

        # Give focus to widget
        self.setFocus()
                
        # Calltips
        calltip_size = CONF.get('shell_appearance', 'calltips/size')
        calltip_font = get_font('shell_appearance', 'calltips')
        self.setup_calltips(calltip_size, calltip_font)
        
        # Completion
        completion_size = CONF.get('shell_appearance', 'completion/size')
        completion_font = get_font('shell_appearance', 'completion')
        self.completion_widget.setup_appearance(completion_size,
                                                completion_font)
        # Cursor width
        self.setCursorWidth( CONF.get('shell_appearance', 'cursor/width') )
开发者ID:jromang,项目名称:retina-old,代码行数:53,代码来源:shell.py

示例10: __init__

 def __init__(self, code_info, plugins):
     super(RequestHandler, self).__init__()
     self.info = code_info
     self.timer = QTimer()
     self.timer.singleShot(LEAD_TIME_SEC * 1000, self._handle_timeout)
     self.waiting = True
     self.pending = {}
     self.result = None
     self.plugins = plugins
     self._start_time = time.time()
     self._threads = {}
     for plugin in plugins:
         self._make_async_call(plugin, code_info)
开发者ID:rachelqhuang,项目名称:spyder,代码行数:13,代码来源:plugin_manager.py

示例11: __init__

 def __init__(self, parent, statusbar):
     StatusBarWidget.__init__(self, parent, statusbar)
     self.setToolTip(self.TIP)
     layout = self.layout()
     layout.addWidget(QLabel(self.TITLE))
     self.label = QLabel()
     self.label.setFont(self.label_font)
     layout.addWidget(self.label)
     layout.addSpacing(20)
     if self.is_supported():
         self.timer = QTimer()
         self.timer.timeout.connect(self.update_label)
         self.timer.start(2000)
     else:
         self.timer = None
         self.hide()
开发者ID:ImadBouirmane,项目名称:spyder,代码行数:16,代码来源:status.py

示例12: __init__

    def __init__(self):
        super(Restarter, self).__init__()
        self.ellipsis = ['', '.', '..', '...', '..', '.']

        # Widgets
        self.timer_ellipsis = QTimer(self)
        self.splash = QSplashScreen(QPixmap(get_image_path('splash.svg'),
                                    'svg'))

        # Widget setup
        self.setVisible(False)

        font = self.splash.font()
        font.setPixelSize(10)
        self.splash.setFont(font)
        self.splash.show()

        self.timer_ellipsis.timeout.connect(self.animate_ellipsis)
开发者ID:AminJamalzadeh,项目名称:spyder,代码行数:18,代码来源:restart.py

示例13: __init__

    def __init__(self, target, executable=None, name=None,
                 extra_args=None, libs=None, cwd=None, env=None):
        super(AsyncClient, self).__init__()
        self.executable = executable or sys.executable
        self.extra_args = extra_args
        self.target = target
        self.name = name or self
        self.libs = libs
        self.cwd = cwd
        self.env = env
        self.is_initialized = False
        self.closing = False
        self.context = zmq.Context()
        QApplication.instance().aboutToQuit.connect(self.close)

        # Set up the heartbeat timer.
        self.timer = QTimer(self)
        self.timer.timeout.connect(self._heartbeat)
        self.timer.start(HEARTBEAT)
开发者ID:AminJamalzadeh,项目名称:spyder,代码行数:19,代码来源:plugin_client.py

示例14: __init__

    def __init__(self, parent, history_filename, profile=False):
        """
        parent : specifies the parent widget
        """
        ConsoleBaseWidget.__init__(self, parent)
        SaveHistoryMixin.__init__(self)
                
        # Prompt position: tuple (line, index)
        self.current_prompt_pos = None
        self.new_input_line = True
        
        # History
        self.histidx = None
        self.hist_wholeline = False
        assert is_text_string(history_filename)
        self.history_filename = history_filename
        self.history = self.load_history()
        
        # Session
        self.historylog_filename = CONF.get('main', 'historylog_filename',
                                            get_conf_path('history.log'))
        
        # Context menu
        self.menu = None
        self.setup_context_menu()

        # Simple profiling test
        self.profile = profile
        
        # Buffer to increase performance of write/flush operations
        self.__buffer = []
        self.__timestamp = 0.0
        self.__flushtimer = QTimer(self)
        self.__flushtimer.setSingleShot(True)
        self.__flushtimer.timeout.connect(self.flush)

        # Give focus to widget
        self.setFocus()

        # Cursor width
        self.setCursorWidth( CONF.get('main', 'cursor/width') )
开发者ID:AminJamalzadeh,项目名称:spyder,代码行数:41,代码来源:shell.py

示例15: __init__

 def __init__(self, executable):
     super(PluginManager, self).__init__()
     plugins = OrderedDict()
     for name in PLUGINS:
         try:
             plugin = PluginClient(name, executable)
         except Exception as e:
             debug_print('Introspection Plugin Failed: %s' % name)
             debug_print(str(e))
             continue
         debug_print('Introspection Plugin Loaded: %s' % name)
         plugins[name] = plugin
         plugin.request_handled.connect(self.handle_response)
     self.plugins = plugins
     self.timer = QTimer()
     self.desired = []
     self.info = None
     self.request = None
     self.pending = None
     self.pending_request = None
     self.waiting = False
开发者ID:BruceYang2046,项目名称:spyder,代码行数:21,代码来源:manager.py


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