Python qtpy.QtCore.QTimer() Examples
The following are 30
code examples of qtpy.QtCore.QTimer().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
qtpy.QtCore
, or try the search function
.
Example #1
Source File: eventEngine.py From vnpy_crypto with MIT License | 6 votes |
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 = [] #----------------------------------------------------------------------
Example #2
Source File: qt_dims_slider.py From napari with BSD 3-Clause "New" or "Revised" License | 6 votes |
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()
Example #3
Source File: download_api.py From conda-manager with MIT License | 6 votes |
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)
Example #4
Source File: conda_api.py From conda-manager with MIT License | 6 votes |
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')
Example #5
Source File: pid_widget.py From pyrpl with GNU General Public License v3.0 | 6 votes |
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()
Example #6
Source File: iir_widget.py From pyrpl with GNU General Public License v3.0 | 6 votes |
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."
Example #7
Source File: restart.py From tellurium with Apache License 2.0 | 6 votes |
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)
Example #8
Source File: restart.py From tellurium with Apache License 2.0 | 6 votes |
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)
Example #9
Source File: pyrpl_widget.py From pyrpl with GNU General Public License v3.0 | 6 votes |
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)
Example #10
Source File: memory.py From pyrpl with GNU General Public License v3.0 | 6 votes |
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, "")
Example #11
Source File: spinbox.py From pyrpl with GNU General Public License v3.0 | 5 votes |
def __init__(self, label="", min=-1, max=1, increment=2.**(-13), log_increment=False, halflife_seconds=0.5, per_second=0.2): """ :param label: label of the button :param min: min value :param max: max value :param increment: increment of the underlying register :param log_increment: boolean: when buttons up/down are pressed, should the value change linearly or log :param halflife_seconds: when button is in log, how long to change the value by a factor 2. :param per_second: when button is in lin, how long to change the value by 1 unit. """ super(NumberSpinBox, self).__init__(None) self._val = 0 # internal storage for value with best-possible accuracy self.labeltext = label self.log_increment = log_increment self.minimum = min # imitates original QSpinBox API self.maximum = max # imitates original QSpinBox API self.halflife_seconds = halflife_seconds self.per_second = per_second self.singleStep = increment self.change_timer = QtCore.QTimer() self.change_timer.setSingleShot(True) self.change_timer.setInterval(int(np.ceil(self.change_interval*1000))) self.change_timer.timeout.connect(self.continue_step) self.make_layout() self.update_tooltip() self.set_min_size() self.val = 0
Example #12
Source File: manager.py From qtconsole with BSD 3-Clause "New" or "Revised" License | 5 votes |
def start(self): if self._timer is None: self._timer = QtCore.QTimer() self._timer.timeout.connect(self.poll) self._timer.start(round(self.time_to_dead * 1000))
Example #13
Source File: test_na.py From pyrpl with GNU General Public License v3.0 | 5 votes |
def test_stupid_timer(self): self.timer = QtCore.QTimer() self.timer.setInterval(2) # formerly 1 ms self.timer.setSingleShot(True) self.count = 0 self.timer.timeout.connect(self.coucou) async_sleep(0.5) tic = time.time() self.total = 1000 self.timer.start() while self.count < self.total: async_sleep(0.05) duration = time.time() - tic assert(duration < 3.0), duration
Example #14
Source File: debug_timer.py From pyrpl with GNU General Public License v3.0 | 5 votes |
def test_stupid_timer(self): self.timer = QtCore.QTimer() self.timer.setInterval(1) # 1 ms self.timer.setSingleShot(True) self.count = 0 self.timer.timeout.connect(self.coucou) tic = time.time() self.timer.start() while self.count<10: async_sleep(0.01) duration = time.time() - tic assert(duration<1), duration # should this not be >1 ???
Example #15
Source File: test_pyqtgraph_benchmark.py From pyrpl with GNU General Public License v3.0 | 5 votes |
def setup(self): self.t0 = np.linspace(0, self.duration, self.N) self.plotWidget = pg.plot(title="Realtime plotting benchmark") self.cycle = 0 self.starttime = time.time() # not yet the actual starttime, but needed for timeout if self.REDPITAYA: self.r.scope.setup(trigger_source='immediately', duration=self.duration) self.timer = QtCore.QTimer() self.timer.setInterval(1000*self.dt) self.timer.timeout.connect(self.update_plot) self.timer.start()
Example #16
Source File: client_api.py From conda-manager with MIT License | 5 votes |
def __init__(self): """Anaconda Client API wrapper.""" super(QObject, self).__init__() self._anaconda_client_api = binstar_client.utils.get_server_api( log_level=logging.NOTSET) self._queue = deque() self._threads = [] self._workers = [] self._timer = QTimer() self._conda_api = CondaAPI() self._timer.setInterval(1000) self._timer.timeout.connect(self._clean)
Example #17
Source File: conda_api.py From conda-manager with MIT License | 5 votes |
def __init__(self, cmd_list, parse=False, pip=False, callback=None, extra_kwargs=None): """Conda worker based on a QProcess for non blocking UI. Parameters ---------- cmd_list : list of str Command line arguments to execute. parse : bool (optional) Parse json from output. pip : bool (optional) Define as a pip command. callback : func (optional) If the process has a callback to process output from comd_list. extra_kwargs : dict Arguments for the callback. """ super(ProcessWorker, self).__init__() self._result = None self._cmd_list = cmd_list self._parse = parse self._pip = pip self._conda = not pip self._callback = callback self._fired = False self._communicate_first = False self._partial_stdout = None self._extra_kwargs = extra_kwargs if extra_kwargs else {} self._timer = QTimer() self._process = QProcess() self._timer.setInterval(150) self._timer.timeout.connect(self._communicate) # self._process.finished.connect(self._communicate) self._process.readyReadStandardOutput.connect(self._partial)
Example #18
Source File: download_api.py From conda-manager with MIT License | 5 votes |
def __init__(self, load_rc_func=None): """Download API based on requests.""" super(QObject, self).__init__() self._conda_api = CondaAPI() self._queue = deque() self._threads = [] self._workers = [] self._timer = QTimer() self._load_rc_func = load_rc_func self._chunk_size = 1024 self._timer.setInterval(1000) self._timer.timeout.connect(self._clean)
Example #19
Source File: pid.py From pyrpl with GNU General Public License v3.0 | 5 votes |
def __init__(self, module): super(SignalLauncherPid, self).__init__(module) self.timer_ival = QtCore.QTimer() self.timer_ival.setInterval(1000) # max. refresh rate: 1 Hz self.timer_ival.timeout.connect(self.update_ival) self.timer_ival.setSingleShot(False) self.timer_ival.start()
Example #20
Source File: uiKLine.py From vnpy_crypto with MIT License | 5 votes |
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)
Example #21
Source File: qtconsoleapp.py From qtconsole with BSD 3-Clause "New" or "Revised" License | 5 votes |
def init_signal(self): """allow clean shutdown on sigint""" signal.signal(signal.SIGINT, lambda sig, frame: self.exit(-2)) # need a timer, so that QApplication doesn't block until a real # Qt event fires (can require mouse movement) # timer trick from http://stackoverflow.com/q/4938723/938949 timer = QtCore.QTimer() # Let the interpreter run each 200 ms: timer.timeout.connect(lambda: None) timer.start(200) # hold onto ref, so the timer doesn't get cleaned up self._sigint_timer = timer
Example #22
Source File: _gevent.py From pyqtconsole with MIT License | 5 votes |
def __init__(self, idle_period=0.010): # Limit the IDLE handler's frequency while still allow for gevent # to trigger a microthread anytime self._idle_period = idle_period # IDLE timer: on_idle is called whenever no Qt events left for # processing self._timer = QTimer() self._timer.timeout.connect(self.process_events) self._timer.start(0)
Example #23
Source File: __init__.py From Pyslvs-UI with GNU Affero General Public License v3.0 | 5 votes |
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)
Example #24
Source File: tables.py From Pyslvs-UI with GNU Affero General Public License v3.0 | 5 votes |
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)
Example #25
Source File: test_icon_browser.py From qtawesome with MIT License | 5 votes |
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()
Example #26
Source File: animation.py From qtawesome with MIT License | 5 votes |
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)
Example #27
Source File: qt_layerlist.py From napari with BSD 3-Clause "New" or "Revised" License | 5 votes |
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
Example #28
Source File: __init__.py From Pyslvs-UI with GNU Affero General Public License v3.0 | 4 votes |
def __init__(self, parent: MainWindowBase): super(InputsWidget, self).__init__(parent) self.setupUi(self) # parent's function pointer self.free_move_button = parent.free_move_button self.entities_point = parent.entities_point self.entities_link = parent.entities_link self.vpoints = parent.vpoint_list self.vlinks = parent.vlink_list self.main_canvas = parent.main_canvas self.solve = parent.solve self.reload_canvas = parent.reload_canvas self.output_to = parent.output_to self.conflict = parent.conflict self.dof = parent.dof self.right_input = parent.right_input self.command_stack = parent.command_stack self.set_coords_as_current = parent.set_coords_as_current self.get_back_position = parent.get_back_position # Angle panel self.dial = QRotatableView(self) self.dial.setStatusTip("Input widget of rotatable joint.") self.dial.setEnabled(False) self.dial.value_changed.connect(self.__update_var) self.dial_spinbox.valueChanged.connect(self.__set_var) self.inputs_dial_layout.insertWidget(0, self.dial) # Play button self.variable_stop.clicked.connect(self.variable_value_reset) # Timer for play button self.inputs_play_shaft = QTimer() self.inputs_play_shaft.setInterval(10) self.inputs_play_shaft.timeout.connect(self.__change_index) # Change the point coordinates with current position self.update_pos.clicked.connect(self.set_coords_as_current) # Record list self.record_list.blockSignals(True) self.record_list.addItem(_AUTO_PATH) self.record_list.setCurrentRow(0) self.record_list.blockSignals(False) self.__paths = {_AUTO_PATH: self.main_canvas.path_preview} self.__slider_paths = {_AUTO_PATH: self.main_canvas.slider_path_preview} def slot(widget: QCheckBox) -> Callable[[int], None]: @Slot(int) def func(ind: int) -> None: widget.setEnabled(ind >= 0 and self.vpoints[ind].type != VJoint.R) return func # Slot option self.plot_joint.currentIndexChanged.connect(slot(self.plot_joint_slot)) self.wrt_joint.currentIndexChanged.connect(slot(self.wrt_joint_slot))
Example #29
Source File: preview.py From Pyslvs-UI with GNU Affero General Public License v3.0 | 4 votes |
def __init__( self, mechanism: Dict[str, Any], path: Sequence[Sequence[_Coord]], vpoints: List[VPoint] = None, vlinks: List[VLink] = None, parent: QWidget = None ): """Input link and path data.""" super(_DynamicCanvas, self).__init__(parent) self.mechanism = mechanism self.vpoints = vpoints or [] self.vlinks = vlinks or [] self.no_mechanism = not self.vpoints or not self.vlinks use_norm = self.no_mechanism and ( self.mechanism.get('shape_only', False) or self.mechanism.get('wavelet_mode', False)) # Target path same: Dict[int, int] = self.mechanism['same'] target_path: _TargetPath = self.mechanism['target'] for i, p in target_path.items(): for j in range(i): if j in same: i -= 1 self.target_path[i] = norm_path(p) if use_norm else p self.path.path = [] for i, p in enumerate(path): if i in self.target_path and use_norm: self.path.path.append(norm_path(efd_fitting(p))) else: self.path.path.append(p) self.__index = 0 self.__interval = 1 self.__path_count = max(len(path) for path in self.path.path) - 1 self.pos = [] # Error self.error = False self.__no_error = 0 if self.no_mechanism: return # Ranges ranges: Dict[int, _Range] = self.mechanism['placement'] self.ranges.update({f"P{i}": QRectF( QPointF(values[0] - values[2], values[1] + values[2]), QSizeF(values[2] * 2, values[2] * 2) ) for i, values in ranges.items()}) # Timer self.__timer = QTimer() self.__timer.timeout.connect(self.__change_index) self.__timer.start(18)
Example #30
Source File: progress.py From Pyslvs-UI with GNU Affero General Public License v3.0 | 4 votes |
def __init__( self, algorithm: AlgorithmType, mech: Dict[str, Any], setting: Dict[str, Any], parent ): super(ProgressDialog, self).__init__(parent) self.setupUi(self) self.setWindowFlags(self.windowFlags() & ~Qt.WindowContextHelpButtonHint) self.rejected.connect(self.__close_work) self.mechanisms = [] # Batch label if 'max_gen' in setting: self.limit = setting['max_gen'] if self.limit > 0: self.batch_label.setText(f"{self.limit} generation(s)") else: self.batch_label.setText('∞') self.limit_mode = 'max_gen' elif 'min_fit' in setting: self.limit = setting['min_fit'] self.batch_label.setText(f"fitness less then {self.limit}") self.limit_mode = 'min_fit' elif 'max_time' in setting: self.limit = setting['max_time'] self.batch_label.setText( f"{self.limit // 3600:02d}:" f"{self.limit % 3600 // 60:02d}:" f"{self.limit % 3600 % 60:02d}" ) self.limit_mode = 'max_time' else: self.limit = 0 self.batch_label.setText('∞') self.limit_mode = 'max_gen' self.loopTime.setEnabled(self.limit > 0) # Timer self.time = 0 self.timer = QTimer() self.timer.setInterval(1000) self.timer.timeout.connect(self.__set_time) self.time_spend = 0. # Worker thread self.work = DimensionalThread(algorithm, mech, setting, self) self.stop_signal.connect(self.work.stop) if self.work.is_two_kernel(): self.fast_kernel_label.hide() else: self.full_kernel_label.hide() self.work.progress_update.connect(self.__set_progress) self.work.result.connect(self.__get_result) self.work.finished.connect(self.__finish)