本文整理汇总了Python中qtpy.QtCore.QTimer.singleShot方法的典型用法代码示例。如果您正苦于以下问题:Python QTimer.singleShot方法的具体用法?Python QTimer.singleShot怎么用?Python QTimer.singleShot使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类qtpy.QtCore.QTimer
的用法示例。
在下文中一共展示了QTimer.singleShot方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: free_memory
# 需要导入模块: from qtpy.QtCore import QTimer [as 别名]
# 或者: from qtpy.QtCore.QTimer import singleShot [as 别名]
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())
示例2: test_calltip
# 需要导入模块: from qtpy.QtCore import QTimer [as 别名]
# 或者: from qtpy.QtCore.QTimer import singleShot [as 别名]
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()
示例3: blink_figure
# 需要导入模块: from qtpy.QtCore import QTimer [as 别名]
# 或者: from qtpy.QtCore.QTimer import singleShot [as 别名]
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)
示例4: set_font_size
# 需要导入模块: from qtpy.QtCore import QTimer [as 别名]
# 或者: from qtpy.QtCore.QTimer import singleShot [as 别名]
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)
示例5: focusOutEvent
# 需要导入模块: from qtpy.QtCore import QTimer [as 别名]
# 或者: from qtpy.QtCore.QTimer import singleShot [as 别名]
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)
示例6: environ_dialog
# 需要导入模块: from qtpy.QtCore import QTimer [as 别名]
# 或者: from qtpy.QtCore.QTimer import singleShot [as 别名]
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
示例7: revert
# 需要导入模块: from qtpy.QtCore import QTimer [as 别名]
# 或者: from qtpy.QtCore.QTimer import singleShot [as 别名]
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: test_sort_dataframe_with_category_dtypes
# 需要导入模块: from qtpy.QtCore import QTimer [as 别名]
# 或者: from qtpy.QtCore.QTimer import singleShot [as 别名]
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'
示例9: test_sort_dataframe_with_duplicate_column
# 需要导入模块: from qtpy.QtCore import QTimer [as 别名]
# 或者: from qtpy.QtCore.QTimer import singleShot [as 别名]
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']
示例10: start
# 需要导入模块: from qtpy.QtCore import QTimer [as 别名]
# 或者: from qtpy.QtCore.QTimer import singleShot [as 别名]
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_()
示例11: set_display_widget
# 需要导入模块: from qtpy.QtCore import QTimer [as 别名]
# 或者: from qtpy.QtCore.QTimer import singleShot [as 别名]
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)
示例12: follow_directories_loaded
# 需要导入模块: from qtpy.QtCore import QTimer [as 别名]
# 或者: from qtpy.QtCore.QTimer import singleShot [as 别名]
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)
示例13: submit
# 需要导入模块: from qtpy.QtCore import QTimer [as 别名]
# 或者: from qtpy.QtCore.QTimer import singleShot [as 别名]
def submit(self):
"""
Submits the current values stored in the widgets to the models.
"""
# make sure it is called from main thread
if (not QThread.currentThread() == QCoreApplication.instance(
).thread()):
QTimer.singleShot(0, self.submit)
return
submit_policy = self._submit_policy
self.submit_policy = SUBMIT_POLICY_AUTO
try:
for key in self._mappings:
self._on_widget_property_notification(key)
finally:
self.submit_policy = submit_policy
示例14: test_load_kernel_file_from_id
# 需要导入模块: from qtpy.QtCore import QTimer [as 别名]
# 或者: from qtpy.QtCore.QTimer import singleShot [as 别名]
def test_load_kernel_file_from_id(ipyconsole, qtbot):
"""
Test that a new client is created using its id
"""
shell = ipyconsole.get_current_shellwidget()
client = ipyconsole.get_current_client()
qtbot.waitUntil(lambda: shell._prompt_html is not None, timeout=SHELL_TIMEOUT)
connection_file = osp.basename(client.connection_file)
id_ = connection_file.split('kernel-')[-1].split('.json')[0]
QTimer.singleShot(2000, lambda: open_client_from_connection_info(
id_, qtbot))
ipyconsole.create_client_for_kernel()
qtbot.wait(1000)
new_client = ipyconsole.get_clients()[1]
assert new_client.id_ == dict(int_id='1', str_id='B')
示例15: test_restart_kernel
# 需要导入模块: from qtpy.QtCore import QTimer [as 别名]
# 或者: from qtpy.QtCore.QTimer import singleShot [as 别名]
def test_restart_kernel(ipyconsole, qtbot):
"""
Test that kernel is restarted correctly
"""
shell = ipyconsole.get_current_shellwidget()
client = ipyconsole.get_current_client()
qtbot.waitUntil(lambda: shell._prompt_html is not None, timeout=SHELL_TIMEOUT)
# Do an assigment to verify that it's not there after restarting
with qtbot.waitSignal(shell.executed):
shell.execute('a = 10')
# Restart kernel and wait until it's up again
shell._prompt_html = None
QTimer.singleShot(1000, lambda: close_message_box(qtbot))
client.restart_kernel()
qtbot.waitUntil(lambda: shell._prompt_html is not None, timeout=SHELL_TIMEOUT)
assert not shell.is_defined('a')