本文整理汇总了Python中qtpy.QtCore.QTimer类的典型用法代码示例。如果您正苦于以下问题:Python QTimer类的具体用法?Python QTimer怎么用?Python QTimer使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了QTimer类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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()
开发者ID:rlaverde,项目名称:spyder,代码行数:26,代码来源:test_mainwindow.py
示例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())
开发者ID:burrbull,项目名称:spyder,代码行数:7,代码来源:plugin.py
示例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
开发者ID:DLlearn,项目名称:spyder,代码行数:30,代码来源:qthelpers.py
示例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)
开发者ID:impact27,项目名称:spyder,代码行数:8,代码来源:figurebrowser.py
示例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()
开发者ID:mabuchilab,项目名称:Instrumental,代码行数:9,代码来源:gui.py
示例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)
开发者ID:slaclab,项目名称:pydm,代码行数:11,代码来源:main_window.py
示例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)
开发者ID:a-stark,项目名称:qudi,代码行数:12,代码来源:mapper.py
示例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)
开发者ID:rlaverde,项目名称:spyder,代码行数:12,代码来源:comboboxes.py
示例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'
开发者ID:burrbull,项目名称:spyder,代码行数:12,代码来源:test_dataframeeditor.py
示例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
开发者ID:cfanpc,项目名称:spyder,代码行数:12,代码来源:test_environ.py
示例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_()
开发者ID:DanNixon,项目名称:mantid,代码行数:13,代码来源:modal_tester.py
示例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']
开发者ID:burrbull,项目名称:spyder,代码行数:13,代码来源:test_dataframeeditor.py
示例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)
开发者ID:Lucast85,项目名称:qtawesome,代码行数:14,代码来源:animation.py
示例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)
开发者ID:slaclab,项目名称:pydm,代码行数:14,代码来源:main_window.py
示例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)
开发者ID:ShenggaoZhu,项目名称:spyder,代码行数:14,代码来源:explorer.py
示例16: ConnectionInspector
class ConnectionInspector(QWidget):
def __init__(self, parent=None):
super(ConnectionInspector, self).__init__(parent, Qt.Window)
connections = self.fetch_data()
self.table_view = ConnectionTableView(connections, self)
self.setLayout(QVBoxLayout(self))
self.layout().addWidget(self.table_view)
button_layout = QHBoxLayout()
self.layout().addItem(button_layout)
self.save_status_label = QLabel(self)
button_layout.addWidget(self.save_status_label)
button_layout.addStretch()
self.save_button = QPushButton(self)
self.save_button.setText("Save list to file...")
self.save_button.clicked.connect(self.save_list_to_file)
button_layout.addWidget(self.save_button)
self.update_timer = QTimer(parent=self)
self.update_timer.setInterval(1500)
self.update_timer.timeout.connect(self.update_data)
self.update_timer.start()
def update_data(self):
self.table_view.model().connections = self.fetch_data()
def fetch_data(self):
plugins = data_plugins.plugin_modules
return [connection
for p in plugins.values()
for connection in p.connections.values()
]
@Slot()
def save_list_to_file(self):
filename, filters = QFileDialog.getSaveFileName(self,
"Save connection list",
"",
"Text Files (*.txt)")
try:
with open(filename, "w") as f:
for conn in self.table_view.model().connections:
f.write(
"{p}://{a}\n".format(p=conn.protocol, a=conn.address))
self.save_status_label.setText("File saved to {}".format(filename))
except Exception as e:
msgBox = QMessageBox()
msgBox.setText("Couldn't save connection list to file.")
msgBox.setInformativeText("Error: {}".format(str(e)))
msgBox.setStandardButtons(QMessageBox.Ok)
msgBox.exec_()
开发者ID:slaclab,项目名称:pydm,代码行数:49,代码来源:connection_inspector.py
示例17: setup
def setup():
qapp = QApplication(sys.argv)
# qapp.setGraphicsSystem('native')
qapp.setWindowIcon(QIcon(os.path.join(ICON_PATH, 'application',
'icon.png')))
#http://stackoverflow.com/questions/4938723/what-is-the-correct-way-to-make-my-pyqt-application-quit-when-killed-from-the-co
timer = QTimer()
timer.start(500) # You may change this if you wish.
timer.timeout.connect(lambda: None) # Let the interpreter run each 500 ms.
app = App(sys.argv)
app.viewer.main_window.show()
return qapp, app
开发者ID:spacetelescope,项目名称:specviz,代码行数:15,代码来源:app.py
示例18: __init__
def __init__(self, connections=[], parent=None):
super(ConnectionTableModel, self).__init__(parent=parent)
self._column_names = ("protocol", "address", "connected")
self.update_timer = QTimer(self)
self.update_timer.setInterval(1000)
self.update_timer.timeout.connect(self.update_values)
self.connections = connections
开发者ID:slaclab,项目名称:pydm,代码行数:7,代码来源:connection_table_model.py
示例19: __init__
def __init__(self, cmd_list, environ=None):
"""
Process worker based on a QProcess for non blocking UI.
Parameters
----------
cmd_list : list of str
Command line arguments to execute.
environ : dict
Process environment,
"""
super(ProcessWorker, self).__init__()
self._result = None
self._cmd_list = cmd_list
self._fired = False
self._communicate_first = False
self._partial_stdout = None
self._started = False
self._timer = QTimer()
self._process = QProcess()
self._set_environment(environ)
self._timer.setInterval(150)
self._timer.timeout.connect(self._communicate)
self._process.readyReadStandardOutput.connect(self._partial)
开发者ID:0xBADCA7,项目名称:spyder,代码行数:26,代码来源:workers.py
示例20: __init__
def __init__(self, channel, pv, protocol=None, parent=None):
"""
Instantiate Pv object and set up the channel access connections.
:param channel: :class:`PyDMChannel` object as the first listener.
:type channel: :class:`PyDMChannel`
:param pv: Name of the pv to connect to.
:type pv: str
:param parent: PyQt widget that this widget is inside of.
:type parent: QWidget
"""
super(Connection, self).__init__(channel, pv, protocol, parent)
self.python_type = None
self.pv = setup_pv(pv,
con_cb=self.connected_cb,
mon_cb=self.monitor_cb,
rwaccess_cb=self.rwaccess_cb)
self.enums = None
self.sevr = None
self.ctrl_llim = None
self.ctrl_hlim = None
self.units = None
self.prec = None
self.count = None
self.epics_type = None
# Auxilliary info to help with throttling
self.scan_pv = setup_pv(pv + ".SCAN", mon_cb=self.scan_pv_cb,
mon_cb_once=True)
self.throttle = QTimer(self)
self.throttle.timeout.connect(self.throttle_cb)
self.add_listener(channel)
开发者ID:slaclab,项目名称:pydm,代码行数:33,代码来源:psp_plugin_component.py
注:本文中的qtpy.QtCore.QTimer类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论