def __init__(self, args): TouchApplication.__init__(self, args) self.sigExecFinished.connect(self.execFinished) self.duinos = [] self.act_duino = None self.flashType = 0 self.window = TouchWindow("ftDuinIO") self.window.titlebar.close.clicked.connect(self.end) self.setMainWidget() self.menu = self.window.addMenu() self.menu.setStyleSheet("font-size: 24px;") self.m_cache = self.menu.addAction( QCoreApplication.translate("mmain", "Cache")) self.m_cache.triggered.connect(self.on_menu_cache) #self.menu.addSeparator() self.m_bootloader = self.menu.addAction( QCoreApplication.translate("mmain", "Flash Bootloader")) self.m_bootloader.triggered.connect(self.on_menu_bootloader) self.m_about = self.menu.addAction( QCoreApplication.translate("mmain", "About")) self.m_about.triggered.connect(self.on_menu_about) self.window.setCentralWidget(self.mainWidget) self.window.show() self.ftdscan() self.checker = QTimer() self.checker.timeout.connect(self.checkFtdComm) self.checker.start(250) self.app_process = None self.flashfile = None self.exec_()
def get(self, url=None, script=None, num_retries=1, jquery=False): """Load given url in webkit and return html when loaded script is some javasript to exexute that will change the loaded page (eg form submission) num_retries is how many times to try downloading this URL or executing this script jquery is whether to inject JQuery into the document """ t1 = time() self.base_url = self.base_url or url # set base URL if not set #html = self.cache.get(key, {}).get('value') #if html: # self.debug('Load cache ' + key) # self.setHtml(html, QUrl(self.base_url)) #else: if 1: loop = QEventLoop() timer = QTimer() timer.setSingleShot(True) timer.timeout.connect(loop.quit) self.loadFinished.connect(loop.quit) if url: self.load(QUrl(url)) elif script: self.js(script) timer.start(self.timeout * 1000) loop.exec_() # delay here until download finished or timeout if timer.isActive(): # downloaded successfully timer.stop() parsed_html = self.current_html() #if key: # self.cache[key] = html #self.wait(self.delay - (time() - t1)) self.app.processEvents print 'get' else: # didn't download in time if num_retries > 0: common.logger.debug('Timeout - retrying') parsed_html = self.get(url, script=script, num_retries=num_retries-1, jquery=jquery) else: common.logger.debug('Timed out') parsed_html = '' return parsed_html
def __init__(self): self.server = WebServer(self.handler) self.log = None if API_LOG_PATH is not None: self.log = open(API_LOG_PATH, 'w') try: self.server.listen() self.timer = QTimer() self.timer.timeout.connect(self.advance) self.timer.start(TICK_INTERVAL) except: QMessageBox.critical( self.window(), 'AnkiConnect', 'Failed to listen on port {}.\nMake sure it is available and is not in use.'.format(NET_PORT) )
def App(cls, width, height, timeout=60): """ Return application and created window. """ app = QApplication([]) win = QuickTabs() win.resize(QSize(width, height)) rect = QApplication.desktop().screenGeometry() x = (rect.width() - win.width()) / 2 y = (rect.height() - win.height()) / 2 win.move(QPoint(x, y)) win.show() win.raise_() if timeout: timer = QTimer() timer.start(timeout * 1000) timer.timeout.connect(win.close) win.timer = timer win.timeout = timeout return app, win
def __init__(self, *args, **kwargs): super(MyApplication, self).__init__(*args, **kwargs) self.t = QTime() self.t.start() self.data = deque(maxlen=20) self.win = pg.GraphicsWindow(title="Basic plotting examples") self.win.resize(1000, 600) self.plot = self.win.addPlot( title='Timed data', axisItems={'bottom': TimeAxisItem(orientation='bottom')}) self.curve = self.plot.plot() self.tmr = QTimer() self.tmr.timeout.connect(self.update) self.tmr.start(1000)
def __init__(self, parent=None): QtGui.QSystemTrayIcon.__init__(self, parent) menu = QtGui.QMenu(parent) self.quitAction = QtGui.QAction("&Quit", self, triggered=QtGui.qApp.quit) exitAction = menu.addAction(self.quitAction) self.setContextMenu(menu) self.icons = {} for i in range(0, 3600, 225): self.icons[str(i / 10.0)] = QtGui.QIcon("pics/" + str(i / 10.0) + ".png") self.checkWind() self.timer = QTimer() self.timer.timeout.connect(self.checkWind) self.timer.start(3 * 60 * 1000)
def __init__(self, parent = None): PyGLWidget.__init__(self,parent) self.animTimer = QTimer() self.animTimer.timeout.connect(self.animate) self.animTimer.start(0) self.renderInfo = None self.sim = None self.run = False self.frameNo = 0 self.loadingFromPickle = False self.clPlatformNum=0 self.clDeviceNum=0 # Initial view setup self.set_radius(32) self.rotate([0,0,1],-45) self.translate([0,0,20]) self.rotate([1,0,0],-45)
def __init__(self, rawSource, parent=None): """ rawSource: The original datasource whose data will be normalized """ super(MinMaxSource, self).__init__(parent) self._rawSource = rawSource self._rawSource.isDirty.connect(self.isDirty) self._rawSource.numberOfChannelsChanged.connect( self.numberOfChannelsChanged) self._bounds = [1e9, -1e9] self._delayedDirtySignal = QTimer() self._delayedDirtySignal.setSingleShot(True) self._delayedDirtySignal.setInterval(10) self._delayedDirtySignal.timeout.connect( partial(self.setDirty, sl[:, :, :, :, :])) self._delayedBoundsChange.connect(self._delayedDirtySignal.start)
def __init__(self, parent=None): super(_CameraWidget, self).__init__(parent) self.cameralabel = QLabel() self.cameralabel.setScaledContents(True) self.setLayout(QGridLayout()) self.toolbar = QToolBar() self.swapaction = self.toolbar.addAction("Swap Camera") self.swapaction.triggered.connect(self.swapcamera) self.cameralabel.mouseReleaseEvent = self.takeimage self.layout().setContentsMargins(0, 0, 0, 0) self.layout().addWidget(self.toolbar) self.layout().addWidget(self.cameralabel) self.timer = QTimer() self.timer.setInterval(20) self.timer.timeout.connect(self.showimage) self.cam = None self.pixmap = None self.currentdevice = 1
def _initTextToPreviewSync(self): """Called when constructing the PreviewDoc. It performs item 1 above.""" # Create a timer which will sync the preview with the text cursor a # short time after cursor movement stops. self._cursorMovementTimer = QTimer() self._cursorMovementTimer.setInterval(300) self._cursorMovementTimer.timeout.connect(self.syncTextToPreview) # Restart this timer every time the cursor moves. core.workspace().cursorPositionChanged.connect(self._onCursorPositionChanged) # Set up a variable to tell us when the preview to text sync just fired, # disabling this sync. Otherwise, that sync would trigger this sync, # which is unnecessary. self._previewToTextSyncRunning = False # Run the approximate match in a separate thread. Cancel it if the # document changes. self._runLatest = RunLatest('QThread', self) self._runLatest.ac.defaultPriority = QThread.LowPriority core.workspace().currentDocumentChanged.connect(self._onDocumentChanged)
def __init__(self, # A sequence of tasks to monitor. tasks, # QApplication instance, used as a parent for a Qtimer app): self.tasks = tasks # Current time, in seconds. self.time_sec = 0.0 # Time between prints, in seconds. self.interval_sec = 0.1 # Create a timer to continually print the time. self.qt = QTimer(app) self.qt.timeout.connect(self.printTime) self.qt.start(self.interval_sec*1000)
def __init__(self, *args): QAbstractItemModel.__init__(self, *args) self._tags = [] self._currentTagIndex = QModelIndex() defBaseColor = QApplication.instance().palette().base().color() # yellow or maroon brightBg = QColor('#ffff80') if defBaseColor.lightnessF( ) > 0.5 else QColor('#800000') self._currentTagBrush = QBrush(brightBg) core.workspace().cursorPositionChanged.connect( self._onCursorPositionChanged) self._updateCurrentTagTimer = QTimer() self._updateCurrentTagTimer.setInterval(300) self._updateCurrentTagTimer.timeout.connect( self._updateCurrentTagAndEmitSignal)
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 = {}
def __init__(self, parent=None): super().__init__() self.laberinto = Laberinto(parent=self) self.mutex = QMutex() self.waitWorker = QWaitCondition() self.waitController = QWaitCondition() self.parent = parent self.running = True self.solving = False self.timer = QTimer() self.delay = 20 self.timer.timeout.connect(self.continue_) self.laberintoTerminado.connect(self.handleLaberintoTerminado) self.start()
def wrongVersion(self): timer = QTimer() timer.timeout.connect(self.exit) timer.start(15000) sharedDB.pauseSaving = 1 sharedDB.noSaving = 1 versionError = QtGui.QMessageBox() versionError.setWindowTitle("OUT OF DATE!") versionError.setText( "A New version of Sludge is ready to be implemented, please close Sludge and wait a few minutes to reopen. Sludge will autoclose in 15 seconds." ) #versionError.button().setText("EXIT") versionError.exec_() sharedDB.app.exit()
def __init__(self, parent, commandClasses): QDialog.__init__(self, parent) self._terminated = False self._commandClasses = commandClasses self._createUi() self._loadingTimer = QTimer(self) self._loadingTimer.setSingleShot(True) self._loadingTimer.setInterval(200) self._loadingTimer.timeout.connect(self._applyLoadingCompleter) self._completerLoaderThread = _CompleterLoaderThread(self) self.finished.connect(self._terminate) self._command = None self._updateCurrentCommand()
def __init__(self, ui = ''): super().__init__() # Set up the user interface from Designer. if not ui: self.ui = Ui_ImageViewer() else: self.ui = ui self.ui.setupUi(self) self.isPlay = False self.fid = -1 self.image_group = -1 self.videos_dir = '' #self.videos_dir = r"/Volumes/behavgenom$/GeckoVideo/Results/20150521_1115/" #self.videos_dir = os.path.expanduser("~") + os.sep + 'Downloads' + os.sep + 'wetransfer-cf3818' + os.sep #self.ui.imageCanvas.setFocusPolicy(Qt.ClickFocus) self.h5path = self.ui.comboBox_h5path.itemText(0) self.ui.pushButton_video.clicked.connect(self.getVideoFile) self.ui.playButton.clicked.connect(self.playVideo) self.ui.imageSlider.sliderPressed.connect(self.imSldPressed) self.ui.imageSlider.sliderReleased.connect(self.imSldReleased) self.ui.spinBox_frame.valueChanged.connect(self.updateFrameNumber) self.ui.doubleSpinBox_fps.valueChanged.connect(self.updateFPS) self.ui.spinBox_step.valueChanged.connect(self.updateFrameStep) self.ui.spinBox_step.valueChanged.connect(self.updateFrameStep) self.ui.comboBox_h5path.activated.connect(self.getImGroup) self.ui.pushButton_h5groups.clicked.connect(self.updateGroupNames) self.updateFPS() self.updateFrameStep() # SET UP RECURRING EVENTS self.timer = QTimer() self.timer.timeout.connect(self.getNextImage)
def __init__(self, *args): PluginBase.__init__(self, BrickletIO4, *args) self.setupUi(self) self.io = self.device self.has_monoflop = self.firmware_version >= (1, 1, 1) self.cbe_value = CallbackEmulator(self.io.get_value, self.cb_value, self.increase_error_count) self.port_value = [self.av0, self.av1, self.av2, self.av3] self.port_direction = [self.ad0, self.ad1, self.ad2, self.ad3] self.port_config = [self.ac0, self.ac1, self.ac2, self.ac3] self.port_time = [self.at0, self.at1, self.at2, self.at3] self.monoflop_active = [False, False, False, False] self.monoflop_timebefore = [500, 500, 500, 500] self.init_async_generator = self.init_async() self.init_async_generator.next() self.save_button.clicked.connect(self.save_clicked) self.pin_box.currentIndexChanged.connect(self.pin_changed) self.direction_box.currentIndexChanged.connect(self.direction_changed) self.debounce_save.clicked.connect(self.debounce_save_clicked) self.time_spinbox.valueChanged.connect(self.time_changed) self.go_button.clicked.connect(self.go_clicked) self.qtcb_monoflop.connect(self.cb_monoflop) self.io.register_callback(self.io.CALLBACK_MONOFLOP_DONE, self.qtcb_monoflop.emit) self.update_timer = QTimer() self.update_timer.timeout.connect(self.update) self.update_timer.setInterval(50) if not self.has_monoflop: self.go_button.setText("Go (FW Versiom >= 1.1.1 required)") self.go_button.setEnabled(False) self.pin_changed(0)
def __init__(self, cf, parent=None): super(ParamManager, self).__init__(parent) self.cf = cf self.fw = {} self.setColumnCount(3) self.setHeaderLabels(['Name', 'Type', 'Value']) self.setAlternatingRowColors(True) self.timerCalib = QTimer() self.timerCalib.setSingleShot(True) self.timerCalib.setInterval(500) self.timerCalib.timeout.connect(lambda: self.cf.param.request_param_update("%s.%s" % ('imu_calib','gyroCalib'))) self.cf.connected.add_callback(self.populate) self.cf.disconnected.add_callback(self.uppopulate) self.setEditTriggers(QAbstractItemView.NoEditTriggers) self.itemDoubleClicked.connect(self.userStartEdit)
def __init__(self, parent=None): QtGui.QWidget.__init__(self, parent) self.value = 0 self.minValue = 0 self.maxValue = 100 self.logo = "" self.scaleMajor = 10 self.scaleMijor = 10 self.startAngle = 60 self.endAngle = 60 self.crownColor = Qt.blue self.foreground = Qt.green self.background = Qt.black self.timer = QTimer() self.timer.timeout.connect(self.update) self.timer.start(200) self.resize(200, 200)
def __init__(self): '''GUI's __init__ method ''' super(SensorProcessor, self).__init__() self.setupUi(self) self._init_elems() self._assign_events() self._retrieval_thread = GetSensorsThread() self._actuator_thread = None self._connect_signals() self._init_buffers() self._stop_plot = False self._connection_error = 0 self.graph_timer = QTimer() self.lbl_act_lower.setText(str(self.slider_lower.value())) self.lbl_act_upper.setText(str(self.slider_upper.value())) self.set_lower_limit = 10 self.set_upper_limit = 40 self.show_set_limits()
def __init__(self, parent=None, wdir=None, history_filename=None): QWidget.__init__(self, parent) if wdir is None: wdir = osp.dirname(osp.abspath(self.fname)) self.wdir = wdir if osp.isdir(wdir) else None self.arguments = "" self.shell = self.SHELL_CLASS(parent, get_conf_path(history_filename)) self.connect(self.shell, SIGNAL("execute(QString)"), self.send_to_process) self.connect(self.shell, SIGNAL("keyboard_interrupt()"), self.keyboard_interrupt) # Redirecting some SIGNALs: self.connect(self.shell, SIGNAL('redirect_stdio(bool)'), lambda state: self.emit(SIGNAL('redirect_stdio(bool)'), state)) self.state_label = QLabel() self.time_label = QLabel() hlayout = QHBoxLayout() hlayout.addWidget(self.state_label) hlayout.addStretch(0) hlayout.addWidget(self.time_label) hlayout.addStretch(0) for button in self.get_toolbar_buttons(): hlayout.addWidget(button) vlayout = QVBoxLayout() vlayout.addLayout(hlayout) vlayout.addWidget(self.get_shell_widget()) self.setLayout(vlayout) self.resize(640, 480) if parent is None: self.setWindowIcon(self.get_icon()) self.setWindowTitle(self.tr("Console")) self.t0 = None self.timer = QTimer(self) self.process = None self.is_closing = False
def __init__(self, *args): PluginBase.__init__(self, BrickletDualRelay, *args) self.setupUi(self) self.dr = self.device self.has_monoflop = self.firmware_version >= (1, 1, 1) self.qtcb_monoflop.connect(self.cb_monoflop) self.dr.register_callback(self.dr.CALLBACK_MONOFLOP_DONE, self.qtcb_monoflop.emit) self.dr1_button.clicked.connect(self.dr1_clicked) self.dr2_button.clicked.connect(self.dr2_clicked) self.go1_button.clicked.connect(self.go1_clicked) self.go2_button.clicked.connect(self.go2_clicked) self.r1_monoflop = False self.r2_monoflop = False self.r1_timebefore = 500 self.r2_timebefore = 500 self.a1_pixmap = load_masked_pixmap( 'plugin_system/plugins/dual_relay/relay_a1.bmp') self.a2_pixmap = load_masked_pixmap( 'plugin_system/plugins/dual_relay/relay_a2.bmp') self.b1_pixmap = load_masked_pixmap( 'plugin_system/plugins/dual_relay/relay_b1.bmp') self.b2_pixmap = load_masked_pixmap( 'plugin_system/plugins/dual_relay/relay_b2.bmp') self.update_timer = QTimer() self.update_timer.timeout.connect(self.update) self.update_timer.setInterval(50) if not self.has_monoflop: self.go1_button.setText("Go (FW Versiom >= 1.1.1 required)") self.go2_button.setText("Go (FW Versiom >= 1.1.1 required)") self.go1_button.setEnabled(False) self.go2_button.setEnabled(False)
def __init__(self, parent=None): super(ChooseImageGame, self).__init__(parent) self.main_layout = QGridLayout(self) self.setContentsMargins(0, 0, 0, 0) self.main_layout.setContentsMargins(0, 0, 0, 0) self.main_layout.setAlignment(Qt.AlignCenter) self.image_grid = [] self.image_grid_by_name = {} self.image_grid_by_widget = {} self.win_sign_path = os.path.join(CURRENT_PATH, 'resources/ok_sign.png') self.lose_sign_path = os.path.join(CURRENT_PATH, 'resources/wrong_sign.png') self.WIN_LOSE_DELAY_TIME = 2 * 1000 self.current_winner_image = None self.restart_game_timer = QTimer() self.restart_game_timer.setSingleShot(True) self.restart_game_timer.timeout.connect(self.restart_image_tile) self.image_bank = {}
def __init__(self, timeout=5, buttons=None, **kwargs): if not buttons: buttons = [MBox.Retry, MBox.Abort, MBox.Cancel] self.timer = QTimer() self.timeout = timeout self.timer.timeout.connect(self.tick) self.timer.setInterval(1000) super(TimedMBox, self).__init__(parent=None) if "text" in kwargs: self.setText(kwargs["text"]) if "title" in kwargs: self.setWindowTitle(kwargs["title"]) self.t_btn = self.addButton(buttons.pop(0)) self.t_btn_text = self.t_btn.text() self.setDefaultButton(self.t_btn) for button in buttons: self.addButton(button)
def __init__(self, parent=None): QObject.__init__(self, parent) self.gpio_states = {} self.initReady = False self.__initGPIOs() self.rswitch = RotaryEncoder(PIN_A, PIN_B, None, self.switch_event, parent=self) self.initReady = True self.reset_timer = QTimer() self.reset_timer.setSingleShot(True) self.reset_timer.timeout.connect( lambda: self.assure_gpio_states_are_resetted()) if GPIO_TEMP is not None: self.worker = WorkerThread(self.startup_temperature_sensing) self.worker.start()
def main(): app = QtGui.QApplication(sys.argv) x = design() Data_plot_Q.put(x) timer = QTimer() timer.timeout.connect(update) timer.start(1000) #5000 #3000 #1500 t3 = threading.Thread(target=x.Save_Data_Excel_file) t3.daemon = True t3.start() x.w.show() app.exec_()
def schedule(self, callback, timeout=100): '''Schedule a function to be called repeated time. This method can be used to perform animations. **Example** This is a typical way to perform an animation, just:: from chemlab.graphics import QtViewer from chemlab.graphics.renderers import SphereRenderer v = QtViewer() sr = v.add_renderer(SphereRenderer, centers, radii, colors) def update(): # calculate new_positions sr.update_positions(new_positions) v.widget.repaint() v.schedule(update) v.run() .. note:: remember to call QtViewer.widget.repaint() each once you want to update the display. **Parameters** callback: function() A function that takes no arguments that will be called at intervals. timeout: int Time in milliseconds between calls of the *callback* function. **Returns** a `QTimer`, to stop the animation you can use `Qtimer.stop` ''' timer = QTimer(self) timer.timeout.connect(callback) timer.start(timeout) return timer
def __init__(self, window=None): super(LogSaveSetup, self).__init__() uic.loadUi('windows/log.ui', self) self.setWindowIcon(QtGui.QIcon('windows/icon/favicon.ico')) self.window = window self.timer = QTimer() self.connect(self.timer, QtCore.SIGNAL('timeout()'), self.timerEvent) self.connect(self.startButton, Qt.SIGNAL("clicked()"), self.startEvent) self.startButton.setShortcut('Ctrl+O') self.connect(self.stopButton, Qt.SIGNAL("clicked()"), self.stopEvent) self.stopButton.setShortcut('Ctrl+P') self.connect(self.saveAsButton, Qt.SIGNAL("clicked()"), self.saveAsEvent) self.radioButton.toggled.connect(self.radioEvent) self.start = False self.stop = False self.radioEnabled = False
def __init__(self, parent = None): ''' Constructor ''' #TODO: Remove debug #import sys #sys.stdout = open(r'F:\PROYECTOS_IH\_UNVERSIONED\visorlog.txt', 'w') super(Controller, self).__init__(parent) self.paused = True self.playbackSpeed = 500 self.timer = QTimer() self.timer.timeout.connect(self.onNextFrameRequested) self.createLayerGroupsOnMainThread.connect(self.createLayerGroup) iface.mapCanvas().setParallelRenderingEnabled(True) self.timeDeviationTolerance = None self.timeDeltaPerFrame = None self.initialize()