本文整理汇总了Python中qtpy.QtCore.QTimer方法的典型用法代码示例。如果您正苦于以下问题:Python QtCore.QTimer方法的具体用法?Python QtCore.QTimer怎么用?Python QtCore.QTimer使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类qtpy.QtCore
的用法示例。
在下文中一共展示了QtCore.QTimer方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from qtpy import QtCore [as 别名]
# 或者: from qtpy.QtCore import QTimer [as 别名]
def __init__(self):
"""初始化事件引擎"""
# 事件队列
self.__queue = Queue()
# 事件引擎开关
self.__active = False
# 事件处理线程
self.__thread = Thread(target = self.__run)
# 计时器,用于触发计时器事件
self.__timer = QTimer()
self.__timer.timeout.connect(self.__onTimer)
# 这里的__handlers是一个字典,用来保存对应的事件调用关系
# 其中每个键对应的值是一个列表,列表中保存了对该事件进行监听的函数功能
self.__handlers = defaultdict(list)
# __generalHandlers是一个列表,用来保存通用回调函数(所有事件均调用)
self.__generalHandlers = []
#----------------------------------------------------------------------
示例2: __init__
# 需要导入模块: from qtpy import QtCore [as 别名]
# 或者: from qtpy.QtCore import QTimer [as 别名]
def __init__(self, slider):
super().__init__()
self.slider = slider
self.dims = slider.dims
self.axis = slider.axis
self.loop_mode = slider.loop_mode
slider.fps_changed.connect(self.set_fps)
slider.mode_changed.connect(self.set_loop_mode)
slider.range_changed.connect(self.set_frame_range)
self.set_fps(self.slider.fps)
self.set_frame_range(slider.frame_range)
# after dims.set_point is called, it will emit a dims.events.axis()
# we use this to update this threads current frame (in case it
# was some other event that updated the axis)
self.dims.events.axis.connect(self._on_axis_changed)
self.current = max(self.dims.point[self.axis], self.min_point)
self.current = min(self.current, self.max_point)
self.timer = QTimer()
示例3: __init__
# 需要导入模块: from qtpy import QtCore [as 别名]
# 或者: from qtpy.QtCore import QTimer [as 别名]
def __init__(self):
super(Restarter, self).__init__()
self.ellipsis = ['', '.', '..', '...', '..', '.']
# Widgets
self.timer_ellipsis = QTimer(self)
self.splash = QSplashScreen(QPixmap(get_image_path(
'Tellurium_splash.png'), 'png'))
# 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)
示例4: init_gui
# 需要导入模块: from qtpy import QtCore [as 别名]
# 或者: from qtpy.QtCore import QTimer [as 别名]
def init_gui(self):
self.init_main_layout(orientation="vertical")
#self.main_layout = QtWidgets.QVBoxLayout()
#self.setLayout(self.main_layout)
self.init_attribute_layout()
input_filter_widget = self.attribute_widgets["inputfilter"]
self.attribute_layout.removeWidget(input_filter_widget)
self.main_layout.addWidget(input_filter_widget)
for prop in ['p', 'i']: #, 'd']:
self.attribute_widgets[prop].widget.set_log_increment()
# can't avoid timer to update ival
# self.timer_ival = QtCore.QTimer()
# self.timer_ival.setInterval(1000)
# self.timer_ival.timeout.connect(self.update_ival)
# self.timer_ival.start()
示例5: __init__
# 需要导入模块: from qtpy import QtCore [as 别名]
# 或者: from qtpy.QtCore import QTimer [as 别名]
def __init__(self, title, parent):
super(MyGraphicsWindow, self).__init__(title)
self.parent = parent
self.setToolTip("IIR transfer function: \n"
"----------------------\n"
"CTRL + Left click: add one more pole. \n"
"SHIFT + Left click: add one more zero\n"
"Left Click: select pole (other possibility: click on the '+j' labels below the graph)\n"
"Left/Right arrows: change imaginary part (frequency) of the current pole or zero\n"
"Up/Down arrows; change the real part (width) of the current pole or zero. \n"
"Poles are represented by 'X', zeros by 'O'")
self.doubleclicked = False
#APP.setDoubleClickInterval(300) # default value (550) is fine
self.mouse_clicked_timer = QtCore.QTimer()
self.mouse_clicked_timer.setSingleShot(True)
self.mouse_clicked_timer.setInterval(APP.doubleClickInterval())
self.mouse_clicked_timer.timeout.connect(self.mouse_clicked)
# see https://wiki.python.org/moin/PyQt/Distinguishing%20between%20click%20and%20double%20click
# "The trick is to realise that Qt delivers MousePress, MouseRelease,
# MouseDoubleClick and MouseRelease events in that order to the widget."
示例6: event
# 需要导入模块: from qtpy import QtCore [as 别名]
# 或者: from qtpy.QtCore import QTimer [as 别名]
def event(self, event):
event_type = event.type()
if event.type() == 176: # QEvent::NonClientAreaMouseButtonDblClick
if self.isFloating():
if self.isMaximized():
fn = lambda: self.showNormal()
else:
fn = lambda: self.showMaximized()
# strange bug: always goes back to normal
# self.showMaximized()
# dirty workaround: make a timer
self.timer = QtCore.QTimer()
self.timer.timeout.connect(fn)
self.timer.setSingleShot(True)
self.timer.setInterval(1.0)
self.timer.start()
event.accept()
return True
else:
#return super(MyDockWidget, self).event(event)
return QtWidgets.QDockWidget.event(self, event)
示例7: __init__
# 需要导入模块: from qtpy import QtCore [as 别名]
# 或者: from qtpy.QtCore import QTimer [as 别名]
def __init__(self, filename=None, source=None, _loadsavedeadtime=3.0):
# never reload or save more frequently than _loadsavedeadtime because
# this is the principal cause of slowing down the code (typ. 30-200 ms)
# for immediate saving, call _save_now, for immediate loading _load_now
self._loadsavedeadtime = _loadsavedeadtime
# first, make sure filename exists
self._filename = get_config_file(filename, source)
if filename is None:
# to simulate a config file, only store data in memory
self._filename = filename
self._data = OrderedDict()
self._lastsave = time()
# create a timer to postpone to frequent savings
self._savetimer = QtCore.QTimer()
self._savetimer.setInterval(self._loadsavedeadtime*1000)
self._savetimer.setSingleShot(True)
self._savetimer.timeout.connect(self._write_to_file)
self._load()
self._save_counter = 0 # cntr for unittest and debug purposes
self._write_to_file_counter = 0 # cntr for unittest and debug purposes
# root of the tree is also a MemoryBranch with parent self and
# branch name ""
super(MemoryTree, self).__init__(self, "")
示例8: __init__
# 需要导入模块: from qtpy import QtCore [as 别名]
# 或者: from qtpy.QtCore import QTimer [as 别名]
def __init__(self, parent=None):
"""Conda API to connect to conda in a non blocking way via QProcess."""
super(_CondaAPI, self).__init__()
self._parent = parent
self._queue = deque()
self._timer = QTimer()
self._current_worker = None
self._workers = []
self._timer.setInterval(1000)
self._timer.timeout.connect(self._clean)
self.ROOT_PREFIX = None
self.set_root_prefix()
# Set config files path
self.user_rc_path = abspath(expanduser('~/.condarc'))
self.sys_rc_path = join(self.ROOT_PREFIX, '.condarc')
示例9: __init__
# 需要导入模块: from qtpy import QtCore [as 别名]
# 或者: from qtpy.QtCore import QTimer [as 别名]
def __init__(self, chunk_size=1024, load_rc_func=None):
"""Download API based on QNetworkAccessManager."""
super(_DownloadAPI, self).__init__()
self._chunk_size = chunk_size
self._head_requests = {}
self._get_requests = {}
self._paths = {}
self._workers = {}
self._load_rc_func = load_rc_func
self._manager = QNetworkAccessManager(self)
self._proxy_factory = NetworkProxyFactory(load_rc_func=load_rc_func)
self._timer = QTimer()
# Setup
self._manager.setProxyFactory(self._proxy_factory)
self._timer.setInterval(1000)
self._timer.timeout.connect(self._clean)
# Signals
self._manager.finished.connect(self._request_finished)
self._manager.sslErrors.connect(self._handle_ssl_errors)
self._manager.proxyAuthenticationRequired.connect(
self._handle_proxy_auth)
示例10: __init__
# 需要导入模块: from qtpy import QtCore [as 别名]
# 或者: from qtpy.QtCore import QTimer [as 别名]
def __init__(self, parent=None):
QtWidgets.QWidget.__init__(self, parent)
# 定时器(for 鼠标双击)
self.timer = QtCore.QTimer()
self.timer.setInterval(300)
self.timer.setSingleShot(True)
self.timer.timeout.connect(self.timeout)
self.click_count = 0 # 鼠标点击次数
self.pos = None # 鼠标点击的位置
# 激活鼠标跟踪功能
self.setMouseTracking(True)
示例11: __init__
# 需要导入模块: from qtpy import QtCore [as 别名]
# 或者: from qtpy.QtCore import QTimer [as 别名]
def __init__(self, layers):
super().__init__()
self.layers = layers
self.setWidgetResizable(True)
self.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff)
scrollWidget = QWidget()
self.setWidget(scrollWidget)
self.vbox_layout = QVBoxLayout(scrollWidget)
self.vbox_layout.addWidget(QtDivider())
self.vbox_layout.addStretch(1)
self.vbox_layout.setContentsMargins(0, 0, 0, 0)
self.vbox_layout.setSpacing(2)
self.centers = []
# Create a timer to be used for autoscrolling the layers list up and
# down when dragging a layer near the end of the displayed area
self._drag_timer = QTimer()
self._drag_timer.setSingleShot(False)
self._drag_timer.setInterval(20)
self._drag_timer.timeout.connect(self._force_scroll)
self._scroll_up = True
self._min_scroll_region = 24
self.setAcceptDrops(True)
self.setToolTip('Layer list')
self.setSizePolicy(QSizePolicy.Fixed, QSizePolicy.Expanding)
self.layers.events.added.connect(self._add)
self.layers.events.removed.connect(self._remove)
self.layers.events.reordered.connect(self._reorder)
self._drag_start_position = np.zeros(2)
self._drag_name = None
示例12: setup
# 需要导入模块: from qtpy import QtCore [as 别名]
# 或者: from qtpy.QtCore import QTimer [as 别名]
def setup(self, icon_painter, painter, rect):
if self.parent_widget not in self.info:
timer = QTimer()
timer.timeout.connect(self._update)
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)
示例13: test_browser_init
# 需要导入模块: from qtpy import QtCore [as 别名]
# 或者: from qtpy.QtCore import QTimer [as 别名]
def test_browser_init(browser):
"""
Ensure the browser opens without error
"""
def close():
browser.close()
timer = QtCore.QTimer()
timer.timeout.connect(close)
timer.setSingleShot(2000)
timer.start()
示例14: __init__
# 需要导入模块: from qtpy import QtCore [as 别名]
# 或者: from qtpy.QtCore import QTimer [as 别名]
def __init__(self, parent: QWidget):
super(FPSLabel, self).__init__(parent)
self.__t0 = process_time()
self.__frame_timer = QTimer()
self.__frame_timer.timeout.connect(self.__update_text)
self.__frame_timer.start(1000)
示例15: __change_index
# 需要导入模块: from qtpy import QtCore [as 别名]
# 或者: from qtpy.QtCore import QTimer [as 别名]
def __change_index(self) -> None:
"""QTimer change index."""
index = self.dial.value()
speed = self.variable_speed.value()
extreme_rebound = (
self.conflict.isVisible()
and self.extremeRebound.isChecked()
)
if extreme_rebound:
speed = -speed
self.variable_speed.setValue(speed)
index += speed * 0.06 * (3 if extreme_rebound else 1)
self.dial.set_value(index)