本文整理汇总了Python中spyderlib.qt.QtCore.QTimer类的典型用法代码示例。如果您正苦于以下问题:Python QTimer类的具体用法?Python QTimer怎么用?Python QTimer使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了QTimer类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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
示例16: focusOutEvent
def focusOutEvent(self, event):
"""Handle focus out event"""
# Calling asynchronously the 'add_current_text' to avoid crash
# https://groups.google.com/group/spyderlib/browse_thread/thread/2257abf530e210bd
QTimer.singleShot(50, self.add_current_text_if_valid)
QComboBox.focusOutEvent(self, event)
开发者ID:gyenney,项目名称:Tools,代码行数:6,代码来源:comboboxes.py
示例17: __init__
def __init__(
self,
parent=None,
fname=None,
wdir=None,
history_filename=None,
show_icontext=True,
light_background=True,
menu_actions=None,
show_buttons_inside=True,
show_elapsed_time=True,
):
QWidget.__init__(self, parent)
self.menu_actions = menu_actions
self.run_button = None
self.kill_button = None
self.options_button = None
self.icontext_action = None
self.show_elapsed_time = show_elapsed_time
self.fname = fname
if wdir is None:
wdir = osp.dirname(osp.abspath(fname))
self.wdir = wdir if osp.isdir(wdir) else None
self.arguments = ""
self.shell = self.SHELL_CLASS(parent, get_conf_path(history_filename))
self.shell.set_light_background(light_background)
self.shell.execute.connect(self.send_to_process)
self.shell.sig_keyboard_interrupt.connect(self.keyboard_interrupt)
# Redirecting some SIGNALs:
self.shell.redirect_stdio.connect(lambda state: self.redirect_stdio.emit(state))
self.state_label = None
self.time_label = None
vlayout = QVBoxLayout()
toolbar_buttons = self.get_toolbar_buttons()
if show_buttons_inside:
self.state_label = QLabel()
hlayout = QHBoxLayout()
hlayout.addWidget(self.state_label)
hlayout.addStretch(0)
hlayout.addWidget(self.create_time_label())
hlayout.addStretch(0)
for button in toolbar_buttons:
hlayout.addWidget(button)
vlayout.addLayout(hlayout)
else:
vlayout.setContentsMargins(0, 0, 0, 0)
vlayout.addWidget(self.get_shell_widget())
self.setLayout(vlayout)
self.resize(640, 480)
if parent is None:
self.setWindowIcon(self.get_icon())
self.setWindowTitle(_("Console"))
self.t0 = None
self.timer = QTimer(self)
self.process = None
self.is_closing = False
if show_buttons_inside:
self.update_time_label_visibility()
开发者ID:gyenney,项目名称:Tools,代码行数:69,代码来源:baseshell.py
示例18: ExternalShellBase
class ExternalShellBase(QWidget):
"""External Shell widget: execute Python script in a separate process"""
SHELL_CLASS = None
redirect_stdio = Signal(bool)
sig_finished = Signal()
def __init__(
self,
parent=None,
fname=None,
wdir=None,
history_filename=None,
show_icontext=True,
light_background=True,
menu_actions=None,
show_buttons_inside=True,
show_elapsed_time=True,
):
QWidget.__init__(self, parent)
self.menu_actions = menu_actions
self.run_button = None
self.kill_button = None
self.options_button = None
self.icontext_action = None
self.show_elapsed_time = show_elapsed_time
self.fname = fname
if wdir is None:
wdir = osp.dirname(osp.abspath(fname))
self.wdir = wdir if osp.isdir(wdir) else None
self.arguments = ""
self.shell = self.SHELL_CLASS(parent, get_conf_path(history_filename))
self.shell.set_light_background(light_background)
self.shell.execute.connect(self.send_to_process)
self.shell.sig_keyboard_interrupt.connect(self.keyboard_interrupt)
# Redirecting some SIGNALs:
self.shell.redirect_stdio.connect(lambda state: self.redirect_stdio.emit(state))
self.state_label = None
self.time_label = None
vlayout = QVBoxLayout()
toolbar_buttons = self.get_toolbar_buttons()
if show_buttons_inside:
self.state_label = QLabel()
hlayout = QHBoxLayout()
hlayout.addWidget(self.state_label)
hlayout.addStretch(0)
hlayout.addWidget(self.create_time_label())
hlayout.addStretch(0)
for button in toolbar_buttons:
hlayout.addWidget(button)
vlayout.addLayout(hlayout)
else:
vlayout.setContentsMargins(0, 0, 0, 0)
vlayout.addWidget(self.get_shell_widget())
self.setLayout(vlayout)
self.resize(640, 480)
if parent is None:
self.setWindowIcon(self.get_icon())
self.setWindowTitle(_("Console"))
self.t0 = None
self.timer = QTimer(self)
self.process = None
self.is_closing = False
if show_buttons_inside:
self.update_time_label_visibility()
@Slot(bool)
def set_elapsed_time_visible(self, state):
self.show_elapsed_time = state
if self.time_label is not None:
self.time_label.setVisible(state)
def create_time_label(self):
"""Create elapsed time label widget (if necessary) and return it"""
if self.time_label is None:
self.time_label = QLabel()
return self.time_label
def update_time_label_visibility(self):
self.time_label.setVisible(self.show_elapsed_time)
def is_running(self):
if self.process is not None:
return self.process.state() == QProcess.Running
def get_toolbar_buttons(self):
if self.run_button is None:
self.run_button = create_toolbutton(
self, text=_("Run"), icon=ima.icon("run"), tip=_("Run again this program"), triggered=self.start_shell
#.........这里部分代码省略.........
开发者ID:gyenney,项目名称:Tools,代码行数:101,代码来源:baseshell.py
示例19: ShellBaseWidget
class ShellBaseWidget(ConsoleBaseWidget, SaveHistoryMixin):
"""
Shell base widget
"""
redirect_stdio = Signal(bool)
sig_keyboard_interrupt = Signal()
execute = Signal(str)
append_to_history = Signal(str, str)
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()
# Completion
completion_size = CONF.get('shell_appearance', 'completion/size')
completion_font = get_font('console')
self.completion_widget.setup_appearance(completion_size,
completion_font)
# Cursor width
self.setCursorWidth( CONF.get('shell_appearance', 'cursor/width') )
def toggle_wrap_mode(self, enable):
"""Enable/disable wrap mode"""
self.set_wrap_mode('character' if enable else None)
def set_font(self, font):
"""Set shell styles font"""
self.setFont(font)
self.set_pythonshell_font(font)
cursor = self.textCursor()
cursor.select(QTextCursor.Document)
charformat = QTextCharFormat()
charformat.setFontFamily(font.family())
charformat.setFontPointSize(font.pointSize())
cursor.mergeCharFormat(charformat)
#------ Context menu
def setup_context_menu(self):
"""Setup shell context menu"""
self.menu = QMenu(self)
self.cut_action = create_action(self, _("Cut"),
shortcut=keybinding('Cut'),
icon=ima.icon('editcut'),
triggered=self.cut)
self.copy_action = create_action(self, _("Copy"),
shortcut=keybinding('Copy'),
icon=ima.icon('editcopy'),
triggered=self.copy)
paste_action = create_action(self, _("Paste"),
shortcut=keybinding('Paste'),
icon=ima.icon('editpaste'),
triggered=self.paste)
save_action = create_action(self, _("Save history log..."),
icon=ima.icon('filesave'),
tip=_("Save current history log (i.e. all "
"inputs and outputs) in a text file"),
triggered=self.save_historylog)
self.delete_action = create_action(self, _("Delete"),
shortcut=keybinding('Delete'),
icon=ima.icon('editdelete'),
triggered=self.delete)
selectall_action = create_action(self, _("Select All"),
shortcut=keybinding('SelectAll'),
#.........这里部分代码省略.........
开发者ID:ImadBouirmane,项目名称:spyder,代码行数:101,代码来源:shell.py
示例20: Restarter
class Restarter(QWidget):
"""Widget in charge of displaying the splash information screen and the
error messages.
"""
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)
def _show_message(self, text):
"""Show message on splash screen."""
self.splash.showMessage(text, Qt.AlignBottom | Qt.AlignCenter |
Qt.AlignAbsolute, QColor(Qt.white))
def animate_ellipsis(self):
"""Animate dots at the end of the splash screen message."""
ellipsis = self.ellipsis.pop(0)
text = ' '*len(ellipsis) + self.splash_text + ellipsis
self.ellipsis.append(ellipsis)
self._show_message(text)
def set_splash_message(self, text):
"""Sets the text in the bottom of the Splash screen."""
self.splash_text = text
self._show_message(text)
self.timer_ellipsis.start(500)
def launch_error_message(self, error_type, error=None):
"""Launch a message box with a predefined error message.
Parameters
----------
error_type : int [CLOSE_ERROR, RESET_ERROR, RESTART_ERROR]
Possible error codes when restarting/reseting spyder.
error : Exception
Actual Python exception error caught.
"""
messages = {CLOSE_ERROR: _("It was not possible to close the previous "
"Spyder instance.\nRestart aborted."),
RESET_ERROR: _("Spyder could not reset to factory "
"defaults.\nRestart aborted."),
RESTART_ERROR: _("It was not possible to restart Spyder.\n"
"Operation aborted.")}
titles = {CLOSE_ERROR: _("Spyder exit error"),
RESET_ERROR: _("Spyder reset error"),
RESTART_ERROR: _("Spyder restart error")}
if error:
e = error.__repr__()
message = messages[error_type] + _("\n\n{0}").format(e)
else:
message = messages[error_type]
title = titles[error_type]
self.splash.hide()
QMessageBox.warning(self, title, message, QMessageBox.Ok)
raise RuntimeError(message)
开发者ID:AminJamalzadeh,项目名称:spyder,代码行数:71,代码来源:restart.py
注:本文中的spyderlib.qt.QtCore.QTimer类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论