def plot(self, keys, data, stack_keys=None): """Draw chart with given data""" self.keys, self.data, self.stack_keys = keys, data, stack_keys self.show() if not data: # if there is no data, let's just draw blank self.redraw_canvas() return min, self.max_value = get_limits(data) if not self.current_max: self.current_max = graphics.Integrator(0) self.current_max.target(self.max_value) self._update_targets() if self.animate: if not self.moving: # if we are moving, then there is a timeout somewhere already gobject.timeout_add(1000 / self.framerate, self._interpolate) else: def finish_all(integrators): for i in range(len(integrators)): if type(integrators[i]) == list: finish_all(integrators[i]) else: integrators[i].finish() finish_all(self.integrators) self.current_max.finish() self.redraw_canvas()
def __create_widgets(self): """ """ self.__vbox = BWVBox() self.__cartesian_radio = gtk.RadioButton(None, _("Cartesian")) self.__polar_radio = gtk.RadioButton(self.__cartesian_radio, _("Polar")) self.__cartesian_radio.connect("toggled", self.__change_system, INTERPOLATION_CARTESIAN) self.__polar_radio.connect("toggled", self.__change_system, INTERPOLATION_POLAR) self.__system_box = BWHBox() self.__system_box.bw_pack_start_noexpand_nofill(self.__polar_radio) self.__system_box.bw_pack_start_noexpand_nofill(self.__cartesian_radio) self.__frames_box = BWHBox() self.__frames_label = gtk.Label(_("Frames")) self.__frames_label.set_alignment(0.0, 0.5) self.__frames = gtk.Adjustment(self.radialnet.get_number_of_frames(), 1, 1000, 1) self.__frames.connect("value_changed", self.__change_frames) self.__frames_spin = gtk.SpinButton(self.__frames) self.__frames_box.bw_pack_start_expand_fill(self.__frames_label) self.__frames_box.bw_pack_start_noexpand_nofill(self.__frames_spin) self.__vbox.bw_pack_start_noexpand_nofill(self.__frames_box) self.__vbox.bw_pack_start_noexpand_nofill(self.__system_box) self.bw_add(self.__vbox) gobject.timeout_add(REFRESH_RATE, self.__update_animation)
def update_group_information(self): """ update the information for a conversation with multiple users """ if not self.rotate_started: self.rotate_started = True gobject.timeout_add(5000, self.rotate_picture) #TODO add plus support for nick to the tab label! members_nick = [] i = 0 for account in self.members: i += 1 contact = self.session.contacts.get(account) if contact is None or contact.nick is None: nick = account elif len(contact.nick) > 20 and i != len(self.members): nick = contact.nick[:20] + '...' else: nick = contact.nick members_nick.append(nick) self.header.information = \ ('%d members' % (len(self.members) + 1, ), ", ".join(members_nick)) self.update_tab()
def show(self): """ Builds the splashscreen and connects the splash window to be destroyed via a timeout callback in L{SplashScreen.DELAY}msec time. The splash can also be destroyed manually by the application """ self.wSplash = gtk.Window(gtk.WINDOW_POPUP) self.wSplash.set_type_hint(gtk.gdk.WINDOW_TYPE_HINT_SPLASHSCREEN) self.wSplash.set_decorated(False) wSplashScreen = gtk.Image() wSplashScreen.set_from_file(os.path.join(conduit.SHARED_DATA_DIR,"conduit-splash.png")) # Make a pretty frame wSplashFrame = gtk.Frame() wSplashFrame.set_shadow_type(gtk.SHADOW_OUT) wSplashFrame.add(wSplashScreen) self.wSplash.add(wSplashFrame) # OK throw up the splashscreen self.wSplash.set_position(gtk.WIN_POS_CENTER) #The splash screen is destroyed automatically (via timeout) #or when the application is finished loading self.destroyed = False self.wSplash.show_all() # ensure it is rendered immediately while gtk.events_pending(): gtk.main_iteration() # The idle timeout handler to destroy the splashscreen gobject.timeout_add(SplashScreen.DELAY,self.destroy)
def SystemStateHandler(self,state_name): ## clearing object started flags current_state = self.Get(DBUS_NAME,"current_state") try: for obj_path in System.EXIT_STATE_DEPEND[current_state]: System.EXIT_STATE_DEPEND[current_state][obj_path] = 0 except: pass print "Running System State: "+state_name if (self.system_states.has_key(state_name)): for name in self.system_states[state_name]: self.start_process(name) if (state_name == "BMC_INIT"): ## Add poll for heartbeat gobject.timeout_add(HEARTBEAT_CHECK_INTERVAL, self.heartbeat_check) try: cb = System.ENTER_STATE_CALLBACK[state_name] for methd in cb.keys(): obj = bus.get_object(cb[methd]['bus_name'],cb[methd]['obj_name']) method = obj.get_dbus_method(methd,cb[methd]['interface_name']) method() except: pass self.Set(DBUS_NAME,"current_state",state_name)
def __init__(self, w3af): super(URLsGraph, self).__init__() self.w3af = w3af self.toolbox = gtk.HBox() b = entries.SemiStockButton("", gtk.STOCK_ZOOM_IN, 'Zoom In') b.connect("clicked", self._zoom, "in") self.toolbox.pack_start(b, False, False) b = entries.SemiStockButton("", gtk.STOCK_ZOOM_OUT, 'Zoom Out') b.connect("clicked", self._zoom, "out") self.toolbox.pack_start(b, False, False) b = entries.SemiStockButton("", gtk.STOCK_ZOOM_FIT, 'Zoom Fit') b.connect("clicked", self._zoom, "fit") self.toolbox.pack_start(b, False, False) b = entries.SemiStockButton("", gtk.STOCK_ZOOM_100, 'Zoom 100%') b.connect("clicked", self._zoom, "100") self.toolbox.pack_start(b, False, False) self.pack_start(self.toolbox, False, False) self.toolbox.set_sensitive(False) # no graph yet self.widget = gtk.Label(_("No info yet")) self.widget.set_sensitive(False) self.nodos_code = [] self._somethingnew = False self.pack_start(self.widget) self.show_all() gobject.timeout_add(500, self._draw_start)
def save_file(self, widget): if self.editor.modificado(): self.save_button.set_sensitive(False) self.editor.save_file() filename = self.editor.current_file() self.alert(filename, "Archivo guardado.") gobject.timeout_add(1500, self.check_modified)
def play(self): self.player.set_state(gst.STATE_PLAYING) self.is_playing = True self.play_button.set_stock_id(gtk.STOCK_MEDIA_PAUSE) #Make sure position is updated regularly gobject.timeout_add(500, self._update_position) self.debug("Preview started")
def __init__(self, timer): """ Initiate the interface """ self.timer = timer self.current_status = 0 self.break_count = 0 self.status_icon = gtk.StatusIcon() self.status_icon.set_from_file(WORK_ICON) self.menu = gtk.Menu() self.quit_item = gtk.ImageMenuItem(gtk.STOCK_QUIT) self._create_menu() self.status_icon.set_visible(True) self.dialog = gtk.MessageDialog( parent=None, flags=gtk.DIALOG_MODAL, type=gtk.MESSAGE_WARNING, buttons=gtk.BUTTONS_CLOSE) self.image = gtk.Image() self.image.set_from_file(REST_ICON) self.dialog.set_title('Pomodoro4linux') self.dialog.set_image(self.image) self.dialog.set_keep_above(True) self.start_timer() timeout_add(1000, self.update_timer)
def burn(button, filename): global GBLprocess global GBLline global GBLoutput global GBLtimeStartedBurn print 'burning ' + filename showProgressWindow() # close the 'ready to burn' window parentWindow = button.get_parent_window() parentWindow.destroy() #command = globals.BURNINGPROGRAM, 'dev=' + globals.DEVICE, "gracetime=0", "blank=fast" command = globals.BURNINGPROGRAM, 'dev=' + globals.DEVICE, 'gracetime=0', '-tao', '-v', '-eject', filename GBLprocess = subprocess.Popen(command, 0, "wodim", subprocess.PIPE, subprocess.PIPE, subprocess.STDOUT) flags = fcntl.fcntl(GBLprocess.stdout, fcntl.F_GETFL) fcntl.fcntl(GBLprocess.stdout, fcntl.F_SETFL, flags | os.O_NONBLOCK) GBLline = '' GBLoutput = [] GBLtimeStartedBurn = datetime.datetime.now() # have gtk call updateProgress every second gobject.timeout_add(1000, updateProgress)
def click_button(self, widget, data=None): if self.username.get_text_length() != 0 and self.password.get_text_length() != 0: self.params['username']=self.username.get_text() self.params['password']=self.password.get_text() if self.status=="login": self.doLogout() elif self.status=="logout": self.doLogin() gobject.timeout_add(150000,self.keepalive) elif self.status=="new": self.chkLogin() self.button.set_label('Logout') gobject.timeout_add(150000,self.keepalive) # if self.chkLogin(): # print self.responsedata # else: # msgpop=gtk.MessageDialog(parent=None, flags=gtk.DIALOG_DESTROY_WITH_PARENT, type=gtk.MESSAGE_ERROR, buttons=gtk.BUTTONS_CLOSE, message_format="Some error occured") # msgpop.run() # msgpop.destroy() else: msgpop=gtk.MessageDialog(parent=None, flags=gtk.DIALOG_DESTROY_WITH_PARENT, type=gtk.MESSAGE_ERROR, buttons=gtk.BUTTONS_CLOSE, message_format="Need password and username fields") msgpop.run() msgpop.destroy()
def display_warning(self, text, callback=None): """Displays a warning to the user in the status bar""" if text not in self.current_warnings: item = self.add_item( stock=gtk.STOCK_DIALOG_WARNING, text=text, callback=callback) self.current_warnings.append(text) gobject.timeout_add(3000, self.remove_warning, item)
def btncancel_clicked_cb(self, widget): """Callback used when cancelling the indexing process""" self._dbmanager.stop = True self._pbar.set_text("Indexing process of " + self._path + " cancelled.") gobject.timeout_add(1000, self.hide_progressbar) gobject.timeout_add(2000, self._mainhandler.remove_scan, self)
def print_output(self): """Populates the directory tree treestore. This method is called after the indexing process finishes. First it populates the left treestore with all the dirs from the indexing process. Then does the needed thingies in the GUI to keep it consistent. """ self._is_scanning = False was_scanned = self._dbmanager.create_metadir() self._dbmanager.set_root_node() rootselect = Directory.select(Directory.q.relpath == "/", connection = self._conn) root = rootselect[0] self._root = root self._mainhandler.populate_catalog_list() if self._root is not None: self._mainhandler.root = self._root self._rootiter = self._tsdirtree.append(None, ['drive-harddisk', self._root.name + " (" + self._root.strsize + ")", self._root.__str__()]) #self.append_directories(self._rootiter, self._root) t = threading.Thread(target=self.append_directories, args=(self._rootiter, self._root)) t.start() gobject.timeout_add(2000, self.hide_progressbar) self._mainhandler.set_buttons_sensitivity(True) if was_scanned == 0: notification = pynotify.Notification("Indexing finished", "Indexing of " + root.name + " has finished successfully.") notification.show()
def _turn_on(self): devnull = open('/dev/null', 'w') p = subprocess.Popen(['xscreensaver', '-nosplash'], stdin=subprocess.PIPE, stdout=devnull, stderr=devnull) p.stdin.close() gobject.timeout_add(1000, self.refresh_on_status)
def scrub(self, context, finalTime, finalPriority, steps=10): self.context = context self.time = finalTime self.priority = finalPriority self.count = 0 self.steps = steps gobject.timeout_add(self.delay, self._scrubTimeoutCb)
def _turn_off(self): p = subprocess.Popen(['xscreensaver-command', '-exit'], stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.STDOUT) p.communicate() gobject.timeout_add(500, self.refresh_on_status)
def checkAnswerTextMatchingGame(self, widget=None, target=None, event=None): ''' check to see if the student pressed the correct answer. If so, increment textMatchingScore. Display appropriate face (happy or sad) for 800 ms. ''' if not ready(self, timeouttime=1000): return if target.get_data('sectionNum') == self.currentTextSelection[1] and \ self.currentTextSelection in self.textPromptsRemaining: self.textMatchingScore += 1 self.sectionsAnsweredCorrectlyTextMatchingGame.append(target.get_data('sectionNum')) pic = ExploreActivityResourcesFilepath + 'happyFace.png' self.textPromptsRemaining.remove(self.currentTextSelection) self.timers.append(gobject.timeout_add(810, self.display_level)) else: pic = ExploreActivityResourcesFilepath + 'sadFace.png' if hasattr(self, 'responsePic'): self.responsePic.remove() self.responsePic = goocanvas.Image( parent=self.rootitem, pixbuf=gcompris.utils.load_pixmap(pic), x=200, y=50 ) self.timers.append(gobject.timeout_add(800, self.clearPic))
def __init__(self, w3af, grapher): self.w3af = w3af self.grapher = grapher # simple empty Tree Store self.treestore = gtk.TreeStore(str) gtk.TreeView.__init__(self, self.treestore) self.connect('button-release-event', self.popup_menu) self.connect('button-press-event', self._doubleClick) # the TreeView column tvcolumn = gtk.TreeViewColumn('URLs') tvcolumn.set_sort_column_id(0) cell = gtk.CellRendererText() tvcolumn.pack_start(cell, True) tvcolumn.add_attribute(cell, "text", 0) self.append_column(tvcolumn) # this tree structure will keep the parents where to insert nodes self.treeholder = {} # get the queue and go live self.urls = IteratedURLList() gobject.timeout_add(750, self.add_url().next) self.show()
def checkAnswerSoundMatchingGame(self, widget=None, target=None, event=None): ''' check to see if the location the student chose corresponds to the currently playing sound clip. increment score accordingly ''' if not ready(self, timeouttime=1000): # precents kids from double clicking too quickly return if target.get_data('sectionNum') == self.currentMusicSelection[1] and \ self.currentMusicSelection in self.soundClipsRemaining: self.soundMatchingScore += 1 self.sectionsAnsweredCorrectlySoundMatchingGame.append(target.get_data('sectionNum')) pic = ExploreActivityResourcesFilepath + 'happyFace.png' self.soundClipsRemaining.remove(self.currentMusicSelection) self.timers.append(gobject.timeout_add(810, self.display_level)) else: pic = ExploreActivityResourcesFilepath + 'sadFace.png' if hasattr(self, 'responsePic'): self.responsePic.remove() self.responsePic = goocanvas.Image( parent=self.rootitem, pixbuf=gcompris.utils.load_pixmap(pic), x=200, y=50 ) self.timers.append(gobject.timeout_add(800, self.clearPic))
def __init__(self, control): self.control = control self.menu_items = {} check_interval = 5 * 60 * 1000 """Set-up Menu""" self.menu = gtk.Menu() self.menu.append(gtk.SeparatorMenuItem()) self.about_item = gtk.ImageMenuItem(gtk.STOCK_ABOUT) self.menu.append(self.about_item) self.quit_item = gtk.ImageMenuItem(gtk.STOCK_QUIT) self.menu.append(self.quit_item) self.quit_item.connect('activate', gtk.main_quit) """Set-up Status Icon""" self.status_icon = gtk.status_icon_new_from_file('no_new.ico') self.status_icon.set_visible(True) self.status_icon.connect( 'popup-menu', self.control.on_menu_popup, self.menu) self.status_icon.connect('activate', self.control.go_to_inbox) self.control.check_mail(self.menu, self.menu_items, self.status_icon) gobject.timeout_add(check_interval, self.control.check_mail, self.menu, self.menu_items, self.status_icon)
def on_processlist_refresh_value_change(self, button): value = button.get_value() if self.processlist_timer_running: return self.processlist_timer_running = True self.processlist_timer_interval = value gobject.timeout_add(int(value * 1000), self.on_processlist_refresh_timeout, button)
def sleep_within_loop(duration): main_loop = gobject.MainLoop() gobject.timeout_add(duration * 1000, main_loop.quit) # NOTE: I am not sure why, but I need add this # dumb thing to run _process method of LibLarch gobject.idle_add(lambda: True) main_loop.run()
def start(self): """ Starts the server. Call this after the handlers have been set. """ import utils utils.makedirs(SOCKET_PATH) serversock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) sockfile = os.path.join(SOCKET_PATH, DISPLAY) try: serversock.bind(sockfile) except socket.error: try: os.remove(sockfile) except OSError: log("Couldn't remove dead socket file \"%s\"." % sockfile) sys.exit(1) try: serversock.bind(sockfile) except socket.error: log("Couldn't bind to socket. Aborting.") sys.exit(1) serversock.listen(3) serversock.setblocking(False) atexit.register(self.__shutdown, serversock, sockfile) gobject.timeout_add(100, self.__server_handler, serversock, sockfile)
def __init__(self, name, value, update, increment=1): """ """ gtk.DrawingArea.__init__(self) self.__variable_name = name self.__value = value self.__update = update self.__increment_pass = increment self.__radius = 6 self.__increment_time = 100 self.__pointer_position = 0 self.__active_increment = False self.__last_value = self.__value() self.connect("expose_event", self.expose) self.connect("button_press_event", self.button_press) self.connect("button_release_event", self.button_release) self.connect("motion_notify_event", self.motion_notify) self.add_events( gtk.gdk.BUTTON_PRESS_MASK | gtk.gdk.BUTTON_RELEASE_MASK | gtk.gdk.MOTION_NOTIFY | gtk.gdk.POINTER_MOTION_HINT_MASK | gtk.gdk.POINTER_MOTION_MASK ) gobject.timeout_add(REFRESH_RATE, self.verify_value)
def run(self): """Start Nex""" splash = Splash(self.appath) splash.show_all() gobject.timeout_add(1000, splash.hide) # 5*1000 miliseconds gobject.idle_add(self.setup_app) gtk.main()
def __create_widgets(self): """ """ self.__liststore = gtk.ListStore(gobject.TYPE_BOOLEAN, gobject.TYPE_STRING) self.__liststore.append([None, OPTIONS[0]]) self.__liststore.append([None, OPTIONS[1]]) self.__liststore.append([None, OPTIONS[2]]) self.__liststore.append([None, OPTIONS[3]]) self.__liststore.append([None, OPTIONS[4]]) self.__liststore.append([None, OPTIONS[5]]) self.__liststore.append([None, OPTIONS[6]]) self.__cell_toggle = gtk.CellRendererToggle() self.__cell_toggle.set_property("activatable", True) self.__cell_toggle.connect("toggled", self.__change_option, self.__liststore) self.__column_toggle = gtk.TreeViewColumn("", self.__cell_toggle) self.__column_toggle.add_attribute(self.__cell_toggle, "active", 0) self.__cell_text = gtk.CellRendererText() self.__column_text = gtk.TreeViewColumn(None, self.__cell_text, text=1) self.__treeview = gtk.TreeView(self.__liststore) self.__treeview.set_enable_search(True) self.__treeview.set_search_column(1) self.__treeview.set_headers_visible(False) self.__treeview.append_column(self.__column_toggle) self.__treeview.append_column(self.__column_text) self.add_with_viewport(self.__treeview) gobject.timeout_add(REFRESH_RATE, self.__update_options)
def __fill_treeviews (self): custom_blacklist_model = self.custom_blacklist_treeview.get_model() custom_blacklist_model.clear() custom_whitelist_model = self.custom_whitelist_treeview.get_model() custom_whitelist_model.clear() packaged_blacklist_model = self.packaged_blacklist_treeview.get_model() packaged_blacklist_model.clear() filters = self.dbus_client.list_custom_filters (self.__selected_user_id) for filter_id, filter_name, filter_description, filter_regex, is_black in filters: if is_black: custom_blacklist_model.append ((filter_id, "<b>%s</b>\n %s" % (filter_name, filter_description), filter_name, filter_description, filter_regex)) else: custom_whitelist_model.append ((filter_id, "<b>%s</b>\n %s" % (filter_name, filter_description), filter_name, filter_description, filter_regex)) for filter_id in self.dbus_client.list_pkg_filters () : metadata = self.dbus_client.get_pkg_filter_metadata(filter_id) filter_name = _("Unknown Blacklist Name") if not metadata.has_key("name") else metadata["name"] filter_description = "" if not metadata.has_key("provider") else metadata["provider"] packaged_blacklist_model.append ((filter_id, "<b>%s</b>\n %s" % (filter_name, filter_description))) gobject.timeout_add(1, self.__update_packaged_blacklist_model)
def run(self): # # Main text # text = ('Thank you for reporting your bugs, it helps us improve our' ' scanning engine. If you want to get involved with the project' ' please send an email to our <a href="mailto:%s">mailing list' ' </a>.') text %= 'w3af-dev[email protected]' # All these lines are here to add a label instead of the easy "set_ # markup" in order to avoid a bug where the label text appears selected msg_area = self.get_message_area() [msg_area.remove(c) for c in msg_area.get_children()] label = gtk.Label() label.set_markup(text) label.set_line_wrap(True) label.select_region(0, 0) msg_area.pack_start(label) self.worker = bug_report_worker( self.bug_report_function, self.bugs_to_report) self.worker.start() gobject.timeout_add(200, self.add_result_from_worker) self.status_hbox = gtk.HBox() # # Empty markup for the ticket ids # self.link_label = gtk.Label('') self.link_label.set_line_wrap(True) self.link_label.set_use_markup(True) self.status_hbox.pack_end(self.link_label) # # Throbber, only show while still running. # self.throbber = Throbber() self.throbber.running(True) self.status_hbox.pack_end(self.throbber) # # Check, hidden at the beginning # http://www.pygtk.org/docs/pygtk/gtk-stock-items.html # self.done_icon = gtk.Image() self.done_icon.set_from_stock(gtk.STOCK_YES, gtk.ICON_SIZE_BUTTON) self.status_hbox.pack_end(self.done_icon) self.vbox.pack_start(self.status_hbox, True, True) self.add(self.vbox) self.show_all() self.done_icon.hide() super(report_bug_show_result, self).run() self.destroy() return self.reported_ids
def __recibe_stop_rafaga(self, widget): """ Cuando la camara dejará de fotografiar. """ self.info_label.set_text("") self.info_label.hide() gobject.timeout_add(500, self.__resensitive_foto)