def resp(box, resp): for iface, dl in downloads: dl.abort() gtk.timeout_remove(self.idle_timeout) self.idle_timeout = None self.destroy() mainwindow.show()
def __state_change(self, sender, oldstate, newstate): if newstate == gstreamer.STATE_PLAYING: if self.__idle: gtk.idle_remove(self.__idle) gtk.timeout_remove(self.__timeout) self.__idle = gtk.idle_add(self.idle, None) self.__timeout = gtk.timeout_add(200, self.time_tick)
def __refresh_hide_camera_button(self): if self.__button_time_id: gtk.timeout_remove(self.__button_time_id) self.__button_time_id = gobject.timeout_add( 30, self.__slide_camera_button_hide) self.__refresh_time_id = None return False
def gps_power_down(self): print "gps_power_down" os.system('echo "\$GPS_STOP" > %s' % GPS_DEV) if self.__gps_off_timeout_handler: gtk.timeout_remove(self.__gps_off_timeout_handler) self.redraw_ui() return True
def __on_camera_leave_notify_cb(self, widget, event): x, y, w, h = widget.allocation if (event.y_root == event.x_root == 0.0) or (x < event.x < x+w and y < event.y < y+h): return if self.__button_time_id: gtk.timeout_remove(self.__button_time_id) self.__button_time_id = gobject.timeout_add(30, self.__slide_camera_button_hide)
def col1_toggled_cb( self, cell, path, model ): if path == "0": gtk.timeout_remove(self.timeoutHandler) model[path][1] = not model[path][1] if model[path][1]: self.loopTime = 10 else: self.loopTime = 5 self.timeoutHandler = gtk.timeout_add(self.loopTime,self.process) for i in range(1,self.size+1): print(i,model[path][1]) model[i][1] = model[path][1] self.framesDisp[model[i][0]] = model[path][1] else: if self.sr: if self.sr.getNCalc() == 0: model[path][1] = not model[path][1] self.framesDisp[model[path][0]] = model[path][1] if model[path][1]: self.sr.addCalc(model[path][0]) else: self.sr.delCalc(model[path][0]) else: model[path][1] = not model[path][1] self.framesDisp[model[path][0]] = model[path][1] #self.framesDisp[] #print "Toggle '%s' to: %s" % (model[path][0], model[path][1]) return
def reset(self): """Stops any polling timers, closes handles and terminates the running process if any and resets values back to default. """ # stop timer if self.timerId != None: gtk.timeout_remove(self.timerId) # terminate the process if still running if self.isRunning(): if platform.system() == 'Windows': # since the bot is running inside a shell we need to # search & terminate all self.process's child processes WMI = win32com.client.GetObject('winmgmts:') processes = WMI.InstancesOf('Win32_Process') for process in processes: parent = process.Properties_('ParentProcessId').Value if parent == self.process.pid: pid = process.Properties_('ProcessID').Value handle = win32api.OpenProcess(1, False, pid) win32api.TerminateProcess(handle, -1) win32api.CloseHandle(handle) self.process.terminate() # reset values self.timerId = None self.process = None self.started = False
def loginReport(self, txt): print 'setting login report', repr(txt) self.logstat.set_text(txt) if not (self._resetTimeout is None): gtk.timeout_remove(self._resetTimeout) self._resetTimeout = gtk.timeout_add(59000, self.loginReset)
def loginReport(self, txt): print 'setting login report',repr(txt) self.logstat.set_text(txt) if not (self._resetTimeout is None): gtk.timeout_remove(self._resetTimeout) self._resetTimeout = gtk.timeout_add(59000, self.loginReset)
def parse_message_collaborators(self, root_element): remote_role = root_element.getAttribute("role") remote_source = root_element.getAttribute("source") # Cancel the broadcast timeout, we are not the master. gtk.timeout_remove(self.broadcast_timeout) # Iterate through the users for element in root_element.childNodes: if (element.tagName == "source"): iterative_source = urllib.unquote(element.getAttribute("source")) iterative_id = int(element.getAttribute("id")) iterative_clock = int(element.getAttribute("clock")) # Set the last_unique id to the highest value if (iterative_source > self.last_unique_id): self.last_unique_id = iterative_source if (iterative_source != self.username): self.succession[iterative_source] = iterative_id self.collaborators[iterative_source] = {'id' : iterative_id, 'clock' : iterative_clock} tag = self.screen_buffer.create_tag("remote-"+str(iterative_id)) tag.set_property("background", COLORS[iterative_id]) else: self.unique_id = iterative_id # If queue is one then you are echoer if (len(self.succession) == 1): self.role = "Echoer" elif (len(self.succession) > 1): pass self.send_command("current") self.widgets.get_widget("text_view").set_property("editable", True)
def update_config(self, event=None): # Kill all timers if self.popup == 1: self.destroy_popup() if self.init == 1: gtk.timeout_remove(self.maintimer) # Run the configuration dialog self.configWindow.show() # Update timeout. Convert seconds to miliseconds (SB) self.maintimer = gtk.timeout_add(self.options["checkinterval"] * 1000, self.mail_check) # Update user/pass self.connection = gmailatom.GmailAtom(self.options["gmailusername"], self.options["gmailpassword"], self.options['proxy']) self.connect() self.mail_check() # Update popup location self.window.resize(POPUP_WIDTH, 1) self.width, self.height = self.window.get_size() self.height += self.options["voffset"] self.width += self.options["hoffset"] self.window.move(gtk.gdk.screen_width() - self.width, gtk.gdk.screen_height() - self.height) # Update language self.lang = self.configWindow.get_lang() # Update popup menu self.popup_menu = GmailPopupMenu.GmailPopupMenu(self) return
def col1_toggled_cb(self, cell, path, model): if path == "0": gtk.timeout_remove(self.timeoutHandler) model[path][1] = not model[path][1] if model[path][1]: self.loopTime = 10 else: self.loopTime = 5 self.timeoutHandler = gtk.timeout_add(self.loopTime, self.process) for i in range(1, self.size + 1): print(i, model[path][1]) model[i][1] = model[path][1] self.framesDisp[model[i][0]] = model[path][1] else: if self.sr: if self.sr.getNCalc() == 0: model[path][1] = not model[path][1] self.framesDisp[model[path][0]] = model[path][1] if model[path][1]: self.sr.addCalc(model[path][0]) else: self.sr.delCalc(model[path][0]) else: model[path][1] = not model[path][1] self.framesDisp[model[path][0]] = model[path][1] #self.framesDisp[] #print "Toggle '%s' to: %s" % (model[path][0], model[path][1]) return
def update_config(self, event=None): # Kill all timers if self.popup==1:self.destroy_popup() if self.init==1:gtk.timeout_remove(self.maintimer) # Run the configuration dialog self.configWindow.show() # Update timeout self.maintimer = gtk.timeout_add(self.options["checkinterval"], self.mail_check ) # Update user/pass self.connection=gmailatom.GmailAtom(self.options["gmailusername"],self.options["gmailpassword"]) self.connect() self.mail_check() # Update popup location self.window.resize(180,1) self.width, self.height = self.window.get_size() self.height +=self.options["voffset"] self.width +=self.options["hoffset"] self.window.move(gtk.gdk.screen_width() - self.width, gtk.gdk.screen_height() - self.height) # Update language self.lang=self.configWindow.get_lang() # Update popup menu self.popup_menu = GmailPopupMenu.GmailPopupMenu(self) return
def onStop(self, widget): lbl = widget.get_label() if lbl == "Stop": gtk.timeout_remove(self.timeoutHandler) widget.set_label("Start") elif lbl == "Start": widget.set_label("Stop") self.timeoutHandler = gtk.timeout_add(self.loopTime, self.process)
def close(self): # Any way to stop the thread? if self.thread.isAlive(): #self.thread.join(0) # Is this correct? self.thread._Thread__stop() gtk.timeout_remove(self.timer_tag) gtk.mainquit()
def pause_clicked_cb(self, button): if self.player.is_paused(): return self.player.pause() if self.update_id != -1: gtk.timeout_remove(self.update_id) self.update_id = -1
def onMouseEnterContextMenu(self, sender, event): """This callback handler is called when mouse cursor enters right-click-context-menu's area. Stops the timeout which closes the context menu automatically. """ if self.closeTimerId != None: gtk.timeout_remove(self.closeTimerId) self.closeTimerId = None
def onStop(self,widget): lbl = widget.get_label() if lbl == "Stop": gtk.timeout_remove(self.timeoutHandler) widget.set_label("Start") elif lbl == "Start": widget.set_label("Stop") self.timeoutHandler = gtk.timeout_add(self.loopTime,self.process)
def destroy(self, widget, data=None): if myself.id == "00": try: servant.quitCommand() except: print "Server is Down!" gtk.timeout_remove(self.timer) gtk.main_quit()
def cleanup_game(self): self.gamewon = False if self.movestep_timer != 0: gtk.timeout_remove(self.movestep_timer) self.movestep_timer = 0 # Remove the root item removes all the others inside it self.rootitem.remove()
def stop_clicked_cb(self, button): if self.player.is_stopped(): return self.player.stop() if self.update_id != -1: gtk.timeout_remove(self.update_id) self.update_id = -1 self.adjustment.set_value(0.0)
def simulate(): """Run simulation loops and reschedule callbacks. """ global _simtag if _simtag is not None: gtk.timeout_remove(_simtag) timeout = main.runUntilCurrent() if timeout is not None: _simtag = gtk.timeout_add(timeout * 1010, simulate) # grumble
def show_tooltip_text(self, text, sec=1500, alpha=0.95): if self.tooltip_hide_hd: gtk.timeout_remove(self.tooltip_hide_hd) self.tooltip_show_check = True self.tooltip_text = text self.tooltip_alpha = alpha # # 启动隐藏的时间. self.tooltip_hide_hd = gtk.timeout_add(sec, self.hide_tooltip_text)
def __on_camera_leave_notify_cb(self, widget, event): x, y, w, h = widget.allocation if (event.y_root == event.x_root == 0.0) or (x < event.x < x + w and y < event.y < y + h): return if self.__button_time_id: gtk.timeout_remove(self.__button_time_id) self.__button_time_id = gobject.timeout_add( 30, self.__slide_camera_button_hide)
def reset_polling(do_immediate_poll=1): global poll_timeout poll_lock.acquire() if poll_timeout: gtk.timeout_remove(poll_timeout) # do the first poll immediately if do_immediate_poll: poll_cb() poll_timeout = gtk.timeout_add(timeout_len, poll_cb) poll_lock.release()
def reset_socks(self): self.close_socks() app_values = self.get_app_values() if self.timeout_id is not None: gtk.timeout_remove(self.timeout_id) self.timeout_id = None if app_values['service_address']: # Service address is available self.socks['req'] = zmq.Socket(self.context, zmq.REQ) self.socks['req'].connect(app_values['service_address'])
def __changed(self, lag=0): if self.__pending_change: gtk.timeout_remove(self.__pending_change) self.__pending_change = 0 if lag <= 0: self.__emit() else: self.__pending_change = gtk.timeout_add(lag, lambda x: x.__emit(), self)
def destroy_popup(self): print "destroying popup" if self.popuptimer>0:gtk.timeout_remove(self.popuptimer) if self.waittimer>0: gtk.timeout_remove(self.waittimer) self.senddown=0 self.hassettimer=0 self.window.hide() self.window.resize(180,1) self.window.move(gtk.gdk.screen_width() - self.width, gtk.gdk.screen_height() - self.height) return
def slide_button_hide(self): self.panel_layout.move(self.button_hbox, 0, 0) self.__button_moving_flag = True if self.__refresh_time_id: gtk.timeout_remove(self.__refresh_time_id) if self.__button_time_id: gtk.timeout_remove(self.__button_time_id) self.__button_time_id = gobject.timeout_add(30, self.__slide_button_hide) self.position = self.POS_OUT self.set_cursor()
def simulate(self): """Run simulation loops and reschedule callbacks. """ global _simtag if _simtag is not None: gtk.timeout_remove(_simtag) self.iterate() timeout = min(self.timeout(), 0.1) if timeout is None: timeout = 0.1 _simtag = gtk.timeout_add((timeout * 1010), self.simulate) # grumble
def setPollInterval(self, interval): """Set the minimum interval between calls to integrate(), in milliseconds. This is the reciprocal of the maximum frame rate. An interval of None will disable calls to integrate(). """ if self.gtkTimeout: gtk.timeout_remove(self.gtkTimeout) if interval is None: self.gtkTimeout = None else: self.gtkTimeout = gobject.timeout_add(interval, self.timerHandler)
def update_animation(self): alloc = self.time.get_allocation() max_width = 100 if alloc.width == max_width and self.step_update == 1: gtk.timeout_remove(self.animation_id) self.step_update = -1 return True if alloc.width < max_width/2 + 2: self.step_update = 1 self.time.set_size_request(alloc.width + self.step_update, alloc.height) return True
def show_tooltip_text(self, text, sec=1500, alpha=0.95): if self.tooltip_hide_hd: gtk.timeout_remove(self.tooltip_hide_hd) self.tooltip_show_check = True self.tooltip_text = text self.tooltip_alpha = alpha # # 启动隐藏的时间. self.tooltip_hide_hd = gtk.timeout_add(sec, self.hide_tooltip_text) # BUG: 没有实时的显示出来,加入这行代码. self.queue_draw_area(0, 0, self.allocation.width, 200)
def destroy_popup(self): print "destroying popup" if self.popuptimer > 0: gtk.timeout_remove(self.popuptimer) if self.waittimer > 0: gtk.timeout_remove(self.waittimer) self.senddown = 0 self.hassettimer = 0 self.window.hide() self.window.resize(POPUP_WIDTH, 1) self.window.move(gtk.gdk.screen_width() - self.width, gtk.gdk.screen_height() - self.height) return
def play(self): self.player.set_state(gst.STATE_PLAYING) length=self.dbfm.get_detail('length') if type(length) is int: self.totalTimeLabel.set_text(self.convert(length)) self.countlength=-1 if self.timer: gtk.timeout_remove(self.timer) self.playProgress.set_fraction(0.0) print self.dbfm.get_detail('length') self.timer = gtk.timeout_add (1000,self.on_timeout,self.dbfm.get_detail('length'))
def cleanup_callback(self, win): if self.load_timeout != 0: gtk.timeout_remove(self.load_timeout) self.load_timeout = 0 if self.pixbuf_loader is not None: self.pixbuf_loader.close() self.pixbuf_loader = None if self.image_stream is not None: self.image_stream.close() self.image_stream = None
def __refresh_camera_button(self): if self.__button_time_id: gtk.timeout_remove(self.__button_time_id) if self.__refresh_time_id: gtk.timeout_remove(self.__refresh_time_id) self.__refresh_time_id = gobject.timeout_add(2000, self.__refresh_hide_camera_button) self.panel_layout.move(self.button_hbox, 0, 0) self.panel.set_size_request(self.AREA_WIDTH, self.button_hbox_height) self.panel.resize_panel(self.AREA_WIDTH, self.button_hbox_height) self.panel.move(self.__win_pos_x+TEXT_WINDOW_LEFT_PADDING, self.__win_pos_y+self.__widget_y+self.AREA_HEIGHT-self.button_hbox_height) self.panel.show_panel()
def simulate(self): """Run simulation loops and reschedule callbacks. """ if self._simtag is not None: gtk.timeout_remove(self._simtag) self.runUntilCurrent() timeout = min(self.timeout(), 0.1) if timeout is None: timeout = 0.1 # Quoth someone other than me, "grumble", yet I know not why. Try to be # more specific in your complaints, guys. -exarkun self._simtag = gtk.timeout_add(int(timeout * 1010), self.simulate)
def simulate(self): """Run simulation loops and reschedule callbacks. """ if self._simtag is not None: gtk.timeout_remove(self._simtag) self.iterate() timeout = min(self.timeout(), 0.1) if timeout is None: timeout = 0.1 # See comment for identical line in GtkReactor.simulate. self._simtag = gtk.timeout_add((timeout * 1010), self.simulate)
def update_config(self, event=None): logging.debug("Updating config") if self.started: gtk.timeout_remove(self.maintimer) self.config.show() self.lang = self.config.get_lang() self.connection = Receiver(self.options["gmailusername"], self.options["gmailpassword"]) if self.started: self.start_update() else: self.mail_check() self.popup_menu = PopupMenu(self)
def ready_cb(dw, p, d, tid): gtk.timeout_remove(tid) d.destroy() if p: red_pendingops.set_action(p, red_pendingops.TO_BE_INSTALLED) else: if not dw.cancelled: dialog = gtk.MessageDialog( None, 0, gtk.MESSAGE_ERROR, gtk.BUTTONS_OK, _("%s is not a valid package") % dw.url) gtk.threads_enter() dialog.run() gtk.threads_leave() dialog.destroy()
def __refresh_camera_button(self): if self.__button_time_id: gtk.timeout_remove(self.__button_time_id) if self.__refresh_time_id: gtk.timeout_remove(self.__refresh_time_id) self.__refresh_time_id = gobject.timeout_add( 2000, self.__refresh_hide_camera_button) self.panel_layout.move(self.button_hbox, 0, 0) self.panel.set_size_request(self.AREA_WIDTH, self.button_hbox_height) self.panel.resize_panel(self.AREA_WIDTH, self.button_hbox_height) self.panel.move( self.__win_pos_x + TEXT_WINDOW_LEFT_PADDING, self.__win_pos_y + self.__widget_y + self.AREA_HEIGHT - self.button_hbox_height) self.panel.show_panel()
def mouse(glarea, event): global angle, delta_angle, move_x, move_y, move_length, timer_id if event.button == 1: angle = angle + delta_angle elif event.button == 3: angle = angle - delta_angle elif event.button == 2: if timer_id: gtk.timeout_remove(timer_id) timer_id = 0 else: timer_id = gtk.idle_add(display) move_x = move_length * cos(angle) move_y = move_length * sin(angle)
def slide_button_show(self, event): self.__button_moving_flag = True if self.__refresh_time_id: gtk.timeout_remove(self.__refresh_time_id) if self.__button_time_id: gtk.timeout_remove(self.__button_time_id) #self.panel_layout.move(self.button_hbox, 0, self.button_hbox_height) x = event.x_root - event.x y = event.y_root - event.y + self.AREA_HEIGHT - self.button_hbox_height self.set_win_pos(event.x_root - event.x - self.allocation.x, event.y_root - event.y - self.allocation.y) self.panel.move(int(x), int(y) + self.button_hbox_height) self.panel.show_panel() self.position = self.POS_OUT self.set_cursor() self.__button_time_id = gobject.timeout_add(30, self.__slide_button_show)
def set_colors(self, enabled): hue = 0.0 if (enabled and self.color_cycle_timeout_id == 0): self.color_cycle_timeout_id = gtk.timeout_add( 200, self.color_cycle_timeout) elif (not enabled and self.color_cycle_timeout_id != 0): gtk.timeout_remove(self.color_cycle_timeout_id) self.color_cycle_timeout_id = 0 for tag in self.color_tags: if enabled: color = apply(TestText.colormap.alloc_color, hue_to_color(hue)) tag.set_property("foreground_gdk", color) else: tag.set_property("foreground_set", False) hue += 1.0 / Buffer.N_COLORS
def couleurs(self, activer): teinte = 0 if (activer and self.marqueur_cycle_couleurs == 0): self.marqueur_cycle_couleurs = gtk.timeout_add( 200, self.cycle_couleurs) elif (not activer and self.marqueur_cycle_couleurs != 0): gtk.timeout_remove(self.marqueur_cycle_couleurs) self.marqueur_cycle_couleurs = 0 for balise in self.balises_couleurs: if activer: couleur = apply(TestTexte.tabledescouleurs.alloc_color, teinte_couleur(teinte)) balise.set_property("foreground_gdk", couleur) else: balise.set_property("foreground_set", False) teinte += 1.0 / Buffer.NBRE_COULEURS
def __on_camera_motion_notify_cb(self, widget, event): if not self.camera_focus_flag: return x, y, w, h = widget.allocation #if not self.panel.get_visible() and \ #y+self.AREA_HEIGHT-self.button_hbox_height<event.y<y+self.AREA_HEIGHT: if not self.panel.get_visible(): if self.__refresh_time_id: gtk.timeout_remove(self.__refresh_time_id) if self.__button_time_id: gtk.timeout_remove(self.__button_time_id) self.__button_time_id = gobject.timeout_add( 30, self.__slide_camera_button_show) #self.panel_layout.move(self.button_hbox, 0, self.button_hbox_height) x = event.x_root - event.x y = event.y_root - event.y - widget.allocation.y + self.AREA_HEIGHT - self.button_hbox_height self.set_win_pos( event.x_root - event.x - self.allocation.x, event.y_root - event.y - widget.allocation.y - self.allocation.y) self.panel.move(int(x), int(y) + self.button_hbox_height) self.panel.show_panel()