Python PyQt5.QtCore.QTimer.singleShot() Examples
The following are 30
code examples of PyQt5.QtCore.QTimer.singleShot().
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
PyQt5.QtCore.QTimer
, or try the search function
.
Example #1
Source File: webelem.py From qutebrowser with GNU General Public License v3.0 | 8 votes |
def _click_fake_event(self, click_target: usertypes.ClickTarget, button: Qt.MouseButton = Qt.LeftButton) -> None: """Send a fake click event to the element.""" pos = self._mouse_pos() log.webelem.debug("Sending fake click to {!r} at position {} with " "target {}".format(self, pos, click_target)) target_modifiers = { usertypes.ClickTarget.normal: Qt.NoModifier, usertypes.ClickTarget.window: Qt.AltModifier | Qt.ShiftModifier, usertypes.ClickTarget.tab: Qt.ControlModifier, usertypes.ClickTarget.tab_bg: Qt.ControlModifier, } if config.val.tabs.background: target_modifiers[usertypes.ClickTarget.tab] |= Qt.ShiftModifier else: target_modifiers[usertypes.ClickTarget.tab_bg] |= Qt.ShiftModifier modifiers = typing.cast(Qt.KeyboardModifiers, target_modifiers[click_target]) events = [ QMouseEvent(QEvent.MouseMove, pos, Qt.NoButton, Qt.NoButton, Qt.NoModifier), QMouseEvent(QEvent.MouseButtonPress, pos, button, button, modifiers), QMouseEvent(QEvent.MouseButtonRelease, pos, button, Qt.NoButton, modifiers), ] for evt in events: self._tab.send_event(evt) QTimer.singleShot(0, self._move_text_cursor)
Example #2
Source File: test_error.py From qutebrowser with GNU General Public License v3.0 | 7 votes |
def test_err_windows(qtbot, qapp, pre_text, post_text, expected, caplog): def err_window_check(): w = qapp.activeModalWidget() assert w is not None try: qtbot.add_widget(w) if not utils.is_mac: assert w.windowTitle() == 'title' assert w.icon() == QMessageBox.Critical assert w.standardButtons() == QMessageBox.Ok assert w.text() == expected finally: w.close() QTimer.singleShot(10, err_window_check) with caplog.at_level(logging.ERROR): error.handle_fatal_exc(ValueError("exception"), 'title', pre_text=pre_text, post_text=post_text, no_err_windows=False)
Example #3
Source File: savemanager.py From qutebrowser with GNU General Public License v3.0 | 6 votes |
def add_saveable(self, name, save, changed=None, config_opt=None, filename=None, dirty=False): """Add a new saveable. Args: name: The name to use. save: The function to call to save this saveable. changed: The signal emitted when this saveable changed. config_opt: An option deciding whether to auto-save or not. filename: The filename of the underlying file, so we can force saving if it doesn't exist. dirty: Whether the saveable is already dirty. """ if name in self.saveables: raise ValueError("Saveable {} already registered!".format(name)) saveable = Saveable(name, save, changed, config_opt, filename) self.saveables[name] = saveable if dirty: saveable.mark_dirty() QTimer.singleShot(0, saveable.save)
Example #4
Source File: display.py From ftcommunity-TXT with GNU General Public License v3.0 | 6 votes |
def restart_launcher(self, text): old_window = self.mainWindow self.mainWindow = TouchBaseWidget() layout = QVBoxLayout() layout.addStretch() lbl = QLabel(text) lbl.setWordWrap(True); lbl.setAlignment(Qt.AlignCenter) layout.addWidget(lbl) layout.addStretch() self.mainWindow.setLayout(layout) self.mainWindow.show() old_window.close() # the 0 msec timer makes sure that the actual restart does # not happen before the message window has been displayed... QTimer.singleShot(0, self.do_restart_launcher)
Example #5
Source File: dialogs.py From mu with GNU General Public License v3.0 | 6 votes |
def remove_packages(self): """ Work out which packages need to be removed and then kick off their removal. """ dirs = [ os.path.join(self.module_dir, d) for d in os.listdir(self.module_dir) if d.endswith("dist-info") or d.endswith("egg-info") ] self.pkg_dirs = {} for pkg in self.to_remove: for d in dirs: # Assets on the filesystem use a normalised package name. pkg_name = pkg.replace("-", "_").lower() if os.path.basename(d).lower().startswith(pkg_name + "-"): self.pkg_dirs[pkg] = d if self.pkg_dirs: # If there are packages to remove, schedule removal. QTimer.singleShot(2, self.remove_package)
Example #6
Source File: display.py From ftcommunity-TXT with GNU General Public License v3.0 | 6 votes |
def restart_launcher(self, text): old_window = self.mainWindow self.mainWindow = TouchBaseWidget() layout = QVBoxLayout() layout.addStretch() lbl = QLabel(text) lbl.setWordWrap(True); lbl.setAlignment(Qt.AlignCenter) layout.addWidget(lbl) layout.addStretch() self.mainWindow.setLayout(layout) self.mainWindow.show() old_window.close() # the 0 msec timer makes sure that the actual restart does # not happen before the message window has been displayed... QTimer.singleShot(0, self.do_restart_launcher)
Example #7
Source File: email_hacker-GUI.py From email_hack with MIT License | 6 votes |
def Run(self): items = ['From Address', 'To Address', 'Email Subject', 'Thread Num', 'Verbose', 'Crazy Mode', 'Body'] Attrs = self.GetAttrs() for item in items: if item not in Attrs: return InitVars(Attrs) if SMTP_addr: ver = "go" Launcher() else: threads_alive = [0] quit(0, 0) #loop = QEventLoop() #QTimer.singleShot(1000, loop.quit)
Example #8
Source File: networkreply.py From qutebrowser with GNU General Public License v3.0 | 6 votes |
def __init__(self, req, errorstring, error, parent=None): """Constructor. Args: req: The QNetworkRequest associated with this reply. errorstring: The error string to print. error: The numerical error value. parent: The parent to pass to QNetworkReply. """ super().__init__(parent) self.setRequest(req) self.setUrl(req.url()) # We don't actually want to read anything, but we still need to open # the device to avoid getting a warning. self.setOpenMode(QIODevice.ReadOnly) self.setError(error, errorstring) QTimer.singleShot(0, lambda: self.error.emit(error)) # type: ignore[attr-defined] QTimer.singleShot(0, lambda: self.finished.emit()) # type: ignore[attr-defined]
Example #9
Source File: clrapplier.py From IDASkins with MIT License | 6 votes |
def eventFilter(self, obj, event): def is_colors_dialog(): return isinstance( obj, QDialog) and 'IDA Colors' in obj.windowTitle() if isinstance(event, QShowEvent) and is_colors_dialog(): qApp.removeEventFilter(self) # Hide window and find &Import button obj.windowHandle().setOpacity(0) buttons = [widget for widget in obj.children() if isinstance( widget, QDialogButtonBox)][0] button = [widget for widget in buttons.buttons() if widget.text() == '&Import'][0] with NativeHook(ask_file=self.ask_file_handler): button.click() QTimer.singleShot(0, lambda: obj.accept()) return 1 return 0
Example #10
Source File: webkittab.py From qutebrowser with GNU General Public License v3.0 | 6 votes |
def load_items(self, items): if items: self._tab.before_load_started.emit(items[-1].url) stream, _data, user_data = tabhistory.serialize(items) qtutils.deserialize_stream(stream, self._history) for i, data in enumerate(user_data): self._history.itemAt(i).setUserData(data) cur_data = self._history.currentItem().userData() if cur_data is not None: if 'zoom' in cur_data: self._tab.zoom.set_factor(cur_data['zoom']) if ('scroll-pos' in cur_data and self._tab.scroller.pos_px() == QPoint(0, 0)): QTimer.singleShot(0, functools.partial( self._tab.scroller.to_point, cur_data['scroll-pos']))
Example #11
Source File: qtnetworkdownloads.py From qutebrowser with GNU General Public License v3.0 | 6 votes |
def _init_reply(self, reply): """Set a new reply and connect its signals. Args: reply: The QNetworkReply to handle. """ self.done = False self.successful = False self._reply = reply reply.setReadBufferSize(16 * 1024 * 1024) # 16 MB reply.downloadProgress.connect(self.stats.on_download_progress) reply.finished.connect(self._on_reply_finished) reply.error.connect(self._on_reply_error) reply.readyRead.connect(self._on_ready_read) reply.metaDataChanged.connect(self._on_meta_data_changed) self._retry_info = _RetryInfo(request=reply.request(), manager=reply.manager()) if not self.fileobj: self._read_timer.start() # We could have got signals before we connected slots to them. # Here no signals are connected to the DownloadItem yet, so we use a # singleShot QTimer to emit them after they are connected. if reply.error() != QNetworkReply.NoError: QTimer.singleShot(0, lambda: self._die(reply.errorString()))
Example #12
Source File: downloadview.py From qutebrowser with GNU General Public License v3.0 | 6 votes |
def update_geometry(obj): """Weird WORKAROUND for some weird PyQt bug (probably). This actually should be a method of DownloadView, but for some reason the rowsInserted/rowsRemoved signals don't get disconnected from this method when the DownloadView is deleted from Qt (e.g. by closing a window). Here we check if obj ("self") was deleted and just ignore the event if so. Original bug: https://github.com/qutebrowser/qutebrowser/issues/167 Workaround bug: https://github.com/qutebrowser/qutebrowser/issues/171 """ def _update_geometry(): """Actually update the geometry if the object still exists.""" if sip.isdeleted(obj): return obj.updateGeometry() # If we don't use a singleShot QTimer, the geometry isn't updated correctly # and won't include the new item. QTimer.singleShot(0, _update_geometry)
Example #13
Source File: eventfilter.py From qutebrowser with GNU General Public License v3.0 | 6 votes |
def _do_focus_workaround(self): """WORKAROUND for https://bugreports.qt.io/browse/QTBUG-68076.""" if not self._focus_workaround: return assert self._widget is not None pass_modes = [usertypes.KeyMode.command, usertypes.KeyMode.prompt, usertypes.KeyMode.yesno] if modeman.instance(self._win_id).mode in pass_modes: return tabbed_browser = objreg.get('tabbed-browser', scope='window', window=self._win_id) current_index = tabbed_browser.widget.currentIndex() try: widget_index = tabbed_browser.widget.indexOf(self._widget.parent()) except RuntimeError: widget_index = -1 if current_index == widget_index: QTimer.singleShot(0, self._widget.setFocus)
Example #14
Source File: sessions.py From qutebrowser with GNU General Public License v3.0 | 6 votes |
def _load_window(self, win): """Turn yaml data into windows.""" window = mainwindow.MainWindow(geometry=win['geometry'], private=win.get('private', None)) window.show() tabbed_browser = objreg.get('tabbed-browser', scope='window', window=window.win_id) tab_to_focus = None for i, tab in enumerate(win['tabs']): new_tab = tabbed_browser.tabopen(background=False) self._load_tab(new_tab, tab) if tab.get('active', False): tab_to_focus = i if new_tab.data.pinned: tabbed_browser.widget.set_tab_pinned(new_tab, new_tab.data.pinned) if tab_to_focus is not None: tabbed_browser.widget.setCurrentIndex(tab_to_focus) if win.get('active', False): QTimer.singleShot(0, tabbed_browser.widget.activateWindow)
Example #15
Source File: roast_properties.py From artisan with GNU General Public License v3.0 | 5 votes |
def widgetWeight(self,widget): w = self.retrieveWeight() if w is not None: v = self.aw.float2floatWeightVolume(w) # widget.setText("%g" % self.aw.float2float(v)) # updating this widget in a separate thread seems to be important on OS X 10.14 to avoid delayed updates and widget redraw problesm QTimer.singleShot(2,lambda : widget.setText("%g" % self.aw.float2float(v)))
Example #16
Source File: history.py From gridsync with GNU General Public License v3.0 | 5 votes |
def load_thumbnail(self): if self.isVisible() and not self._thumbnail_loaded: self._thumbnail_loaded = True QTimer.singleShot(50, self._do_load_thumbnail)
Example #17
Source File: roast_properties.py From artisan with GNU General Public License v3.0 | 5 votes |
def inWeight(self,_): QTimer.singleShot(1,lambda : self.widgetWeight(self.coffeeinweightEdit)) QTimer.singleShot(10,lambda : self.resetInVolume()) QApplication.processEvents()
Example #18
Source File: qt.py From bazarr with GNU General Public License v3.0 | 5 votes |
def _start_timer(self, wait_seconds): self._stop_timer() if wait_seconds is not None: self._timer = QTimer.singleShot(wait_seconds * 1000, self._process_jobs)
Example #19
Source File: main_window.py From gridsync with GNU General Public License v3.0 | 5 votes |
def showEvent(self, _): if self.pending_news_message: gateway, title, message = self.pending_news_message self.pending_news_message = () QTimer.singleShot( 0, lambda: self.show_news_message(gateway, title, message) )
Example #20
Source File: roast_properties.py From artisan with GNU General Public License v3.0 | 5 votes |
def volumeCalculatorTimer(self,_): QTimer.singleShot(1,lambda : self.volumeCalculator())
Example #21
Source File: controller.py From artisan with GNU General Public License v3.0 | 5 votes |
def start(app_window): config.app_window = app_window QTimer.singleShot(2,lambda : connect()) # toggles between connected and disconnected modes. If connected and not is_synced() uploades current data to server
Example #22
Source File: sync.py From artisan with GNU General Public License v3.0 | 5 votes |
def getUpdate(uuid,file=None): config.logger.info("sync:getUpdate(" + str(uuid) + "," + str(file) + ")") if uuid is not None: aw = config.app_window if aw.editgraphdialog is None and controller.is_connected(): try: aw.editgraphdialog = False # block opening the Roast Properties dialog while syncing from the server aw.updatePlusStatusSignal.emit() # show syncing icon QTimer.singleShot(2,lambda : fetchServerUpdate(uuid,file)) except Exception as e: config.logger.error("sync: Exception in getUpdate() %s",e) #### Sync Action as issued on profile load and turning plus on
Example #23
Source File: HotPlaylist.py From PyQt with GNU General Public License v3.0 | 5 votes |
def load(self): if self.Page == -1: return self._loadStart = True self.loadWidget.setVisible(True) # 延迟一秒后调用目的在于显示进度条 QTimer.singleShot(1000, self._load)
Example #24
Source File: GifSplashScreen.py From PyQt with GNU General Public License v3.0 | 5 votes |
def createWindow(): app.w = QWidget() # 模拟初始5秒后再显示 splash.showMessage('等待界面显示', Qt.AlignHCenter | Qt.AlignBottom, Qt.white) QTimer.singleShot(3000, lambda: ( splash.showMessage('初始化完成', Qt.AlignHCenter | Qt.AlignBottom, Qt.white), app.w.show(), splash.finish(app.w))) # 模拟耗时5秒。但是不能用sleep # 可以使用子线程加载耗时的数据 # 主线程中循环设置UI可以配合QApplication.instance().processEvents()
Example #25
Source File: ScreenShotPage.py From PyQt with GNU General Public License v3.0 | 5 votes |
def onScreenShot1(self): # 截图方式1 page = self.webView.page() oldSize = self.webView.size() self.webView.resize(page.contentsSize().toSize()) def doScreenShot(): rect = self.webView.contentsRect() size = rect.size() image = QImage(size, QImage.Format_ARGB32_Premultiplied) image.fill(Qt.transparent) painter = QPainter() painter.begin(image) painter.setRenderHint(QPainter.Antialiasing, True) painter.setRenderHint(QPainter.TextAntialiasing, True) painter.setRenderHint(QPainter.SmoothPixmapTransform, True) self.webView.render(painter) painter.end() self.webView.resize(oldSize) # 添加到左侧list中 item = QListWidgetItem(self.widgetRight) image = QPixmap.fromImage(image) item.setIcon(QIcon(image)) item.setData(Qt.UserRole + 1, image) # 先等一下再截图吧 QTimer.singleShot(2000, doScreenShot)
Example #26
Source File: QtThreading.py From PyQt with GNU General Public License v3.0 | 5 votes |
def __init__(self, *args, **kwargs): super(Window, self).__init__(*args, **kwargs) self.resize(400, 400) layout = QVBoxLayout(self) self.progressBar = QProgressBar(self) layout.addWidget(self.progressBar) Signals.updateProgress.connect( self.progressBar.setValue, type=Qt.QueuedConnection) QTimer.singleShot(2000, self.doStart)
Example #27
Source File: WindowNotify.py From PyQt with GNU General Public License v3.0 | 5 votes |
def showAnimation(self): print("showAnimation isShow = True") # 显示动画 self.isShow = True self.animation.stop()#先停止之前的动画,重新开始 self.animation.setStartValue(self.pos()) self.animation.setEndValue(self._endPos) self.animation.start() # 弹出5秒后,如果没有焦点则弹回去 self._timer.start(self._timeout) # QTimer.singleShot(self._timeout, self.closeAnimation)
Example #28
Source File: WindowNotify.py From PyQt with GNU General Public License v3.0 | 5 votes |
def onClose(self): #点击关闭按钮时 print("onClose") self.isShow = False QTimer.singleShot(100, self.closeAnimation)#启动弹回动画
Example #29
Source File: FlipWidgetAnimation.py From PyQt with GNU General Public License v3.0 | 5 votes |
def showWidget(self): # 显示主窗口隐藏动画窗口 self.setWindowOpacity(1) QTimer.singleShot(100, self.flipWidget.hide)
Example #30
Source File: HotPlaylist.py From PyQt with GNU General Public License v3.0 | 5 votes |
def load(self): if self.Page == -1: return self.loadStarted.emit(True) # 延迟一秒后调用目的在于显示进度条 QTimer.singleShot(1000, self._load)