本文整理汇总了Python中qtpy.QtCore.QTimer类的典型用法代码示例。如果您正苦于以下问题:Python QTimer类的具体用法?Python QTimer怎么用?Python QTimer使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了QTimer类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_calltip
def test_calltip(main_window, qtbot):
"""Hide the calltip in the editor when a matching ')' is found."""
# Load test file
text = 'a = [1,2,3]\n(max'
main_window.editor.new(fname="test.py", text=text)
code_editor = main_window.editor.get_focus_widget()
# Set text to start
code_editor.set_text(text)
code_editor.go_to_line(2)
code_editor.move_cursor(5)
calltip = code_editor.calltip_widget
assert not calltip.isVisible()
qtbot.keyPress(code_editor, Qt.Key_ParenLeft, delay=3000)
qtbot.keyPress(code_editor, Qt.Key_A, delay=1000)
qtbot.waitUntil(lambda: calltip.isVisible(), timeout=1000)
qtbot.keyPress(code_editor, Qt.Key_ParenRight, delay=1000)
qtbot.keyPress(code_editor, Qt.Key_Space)
assert not calltip.isVisible()
qtbot.keyPress(code_editor, Qt.Key_ParenRight, delay=1000)
qtbot.keyPress(code_editor, Qt.Key_Enter, delay=1000)
QTimer.singleShot(1000, lambda: close_save_message_box(qtbot))
main_window.editor.close_file()
示例2: free_memory
def free_memory(self):
"""Free memory signal."""
self.main.free_memory()
QTimer.singleShot(self.INITIAL_FREE_MEMORY_TIME_TRIGGER,
lambda: self.main.free_memory())
QTimer.singleShot(self.SECONDARY_FREE_MEMORY_TIME_TRIGGER,
lambda: self.main.free_memory())
示例3: 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
示例4: blink_figure
def blink_figure(self):
"""Blink figure once."""
if self.fig:
self._blink_flag = not self._blink_flag
self.repaint()
if self._blink_flag:
timer = QTimer()
timer.singleShot(40, self.blink_figure)
示例5: start_video
def start_video(self):
timer = QTimer()
self.timer = timer
timer.timeout.connect(self._wait_for_frame)
self.cam.start_live_video(**self.settings)
timer.start(0) # Run full throttle
self.is_live = True
self.needs_resize = True
self.videoStarted.emit()
示例6: set_font_size
def set_font_size(self, old, new):
current_font = self.app.font()
current_font.setPointSizeF(current_font.pointSizeF()/old*new)
QApplication.instance().setFont(current_font)
for w in self.app.allWidgets():
w_c_f = w.font()
w_c_f.setPointSizeF(w_c_f.pointSizeF()/old*new)
w.setFont(w_c_f)
QTimer.singleShot(0, self.resizeForNewDisplayWidget)
示例7: revert
def revert(self):
"""
Takes the data stored in the models and displays them in the widgets.
"""
# make sure it is called from main thread
if (not QThread.currentThread() == QCoreApplication.instance(
).thread()):
QTimer.singleShot(0, self.revert)
return
for key in self._mappings:
self._on_model_notification(key)
示例8: 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
if not self.is_valid():
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)
示例9: test_sort_dataframe_with_category_dtypes
def test_sort_dataframe_with_category_dtypes(qtbot): # cf. issue 5361
df = DataFrame({'A': [1, 2, 3, 4],
'B': ['a', 'b', 'c', 'd']})
df = df.astype(dtype={'B': 'category'})
df_cols = df.dtypes
editor = DataFrameEditor(None)
editor.setup_and_check(df_cols)
dfm = editor.dataModel
QTimer.singleShot(1000, lambda: close_message_box(qtbot))
editor.dataModel.sort(0)
assert data(dfm, 0, 0) == 'int64'
assert data(dfm, 1, 0) == 'category'
示例10: environ_dialog
def environ_dialog(qtbot):
"Setup the Environment variables Dialog taking into account the os."
QTimer.singleShot(1000, lambda: close_message_box(qtbot))
if os.name == 'nt':
from spyder.utils.environ import WinUserEnvDialog
dialog = WinUserEnvDialog()
else:
from spyder.utils.environ import EnvDialog
dialog = EnvDialog()
qtbot.addWidget(dialog)
return dialog
示例11: start
def start(self):
"""
Start this tester.
"""
self.timer = QTimer()
# Connecting self.idle to a QTimer with 0 time delay
# makes it called when there are no events to process
self.timer.timeout.connect(self._idle)
self.timer.start()
# This calls __call__() method
QTimer.singleShot(0, self)
# Start the event loop
self.app.exec_()
示例12: test_sort_dataframe_with_duplicate_column
def test_sort_dataframe_with_duplicate_column(qtbot):
df = DataFrame({'A': [1, 3, 2], 'B': [4, 6, 5]})
df = concat((df, df.A), axis=1)
editor = DataFrameEditor(None)
editor.setup_and_check(df)
dfm = editor.dataModel
QTimer.singleShot(1000, lambda: close_message_box(qtbot))
editor.dataModel.sort(0)
assert [data(dfm, row, 0) for row in range(len(df))] == ['1', '3', '2']
assert [data(dfm, row, 1) for row in range(len(df))] == ['4', '6', '5']
editor.dataModel.sort(1)
assert [data(dfm, row, 0) for row in range(len(df))] == ['1', '2', '3']
assert [data(dfm, row, 1) for row in range(len(df))] == ['4', '5', '6']
示例13: 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)
示例14: set_display_widget
def set_display_widget(self, new_widget):
if new_widget == self._display_widget:
return
self.clear_display_widget()
if not new_widget.layout():
new_widget.setMinimumSize(new_widget.size())
self._new_widget_size = new_widget.size()
self._display_widget = new_widget
self.setCentralWidget(self._display_widget)
self.update_window_title()
# Resizing to the new widget's dimensions needs to be
# done on the event loop for some reason - you can't
# just do it here.
QTimer.singleShot(0, self.resizeForNewDisplayWidget)
示例15: 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)