Example #1
0
 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)
    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 %= '*****@*****.**'
        # 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
Example #3
0
    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)
Example #4
0
    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()
Example #5
0
    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()
Example #6
0
    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)
Example #7
0
    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)
Example #8
0
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()
Example #9
0
	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)
Example #10
0
    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)
Example #11
0
File: UI.py Project: nzjrs/conduit
    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)
Example #12
0
    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()
Example #13
0
 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)
Example #14
0
 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)
Example #15
0
    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)
Example #16
0
    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)
Example #17
0
 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)
Example #18
0
    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)
Example #19
0
 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()
Example #20
0
    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))
Example #21
0
 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 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)
Example #23
0
 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 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)
Example #25
0
	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()
Example #26
0
 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)
Example #27
0
 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)
Example #28
0
    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)
Example #29
0
 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()
Example #30
0
    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))
Example #31
0
 def __init__ (self, file_name, timeout=2000, model_imol=None) :
   self.file_name = file_name
   self.model_imol = model_imol
   self.last_mtime = 0
   import gobject
   gobject.timeout_add(timeout, self.check_file)
Example #32
0
 def __do_realize(self, widget):
     gobject.timeout_add(500, self.__descargar)
Example #33
0
 def __init__(self, fetch):
     gtk.DrawingArea.__init__(self)
     self.timer = gobject.timeout_add(100, progress_timeout, self)
     self.data = fetch
     self.nodes = {}
     self.update = gobject.timeout_add(1000, self.updateNodes, self)
Example #34
0
 def __init__(self):
     gtk.Widget.__init__(self)
     self.draw_gc = None
     self.layout = self.create_pango_layout(TEXT)
     self.layout.set_font_description(pango.FontDescription("sans serif 8"))
     self.timer = gobject.timeout_add(1000, progress_timeout, self)
Example #35
0
 def __start_idle_flash(self):
     self.__idle_flash_count = 4
     if self.__idle_flash_id == 0:
         self.__idle_flash_id = gobject.timeout_add(250, self.__idle_flash)
Example #36
0
            warn_dialog.run()
            warn_dialog.destroy()
            return

        log.debug("Running command: %s" % command_execution.command)
        self.jobs.append(command_execution)

        i = self.scans_store.add_running_scan(command_execution)
        self.scan_result.scan_result_notebook.nmap_output.set_active_iter(i)

        # When scan starts, change to nmap output view tab and refresh output
        self.scan_result.change_to_nmap_output_tab()
        self.scan_result.refresh_nmap_output()

        # Add a timeout function
        self.verify_thread_timeout_id = gobject.timeout_add(
            NMAP_OUTPUT_REFRESH_INTERVAL, self.verify_execution)

    def verify_execution(self):
        """This is a callback that is called periodically to refresh the output
        check whether any running scans have finished. The timer that schedules
        the callback is started in execute_command. When there are no more
        running scans, this function returns True so that it won't be scheduled
        again."""
        self.scan_result.refresh_nmap_output()

        finished_jobs = []
        for scan in self.jobs:
            try:
                alive = scan.scan_state()
                if alive:
                    continue
Example #37
0
 def set_timer(self):
     gobject.threads_init()
     gobject.timeout_add(100, self.update)
Example #38
0
 def set_timer(self):
     gobject.timeout_add(100, self.update)
Example #39
0
 def run(self):
     def _return():
         self.return_cb()
         return False
     self.source_id = gobject.timeout_add(int(self.seconds * 1000), _return)
Example #40
0
 def update_start(self, timeout=100):
     if GPin.UPDATE:
         return
     GPin.UPDATE = True
     gobject.timeout_add(timeout, self.update_all)
Example #41
0
    label = dtk.ui.label.Label("Slider Demo")
    label_align = gtk.Alignment(0.5, 0.5, 0, 0)
    label_align.add(label)
    slider.to_page_now(label_align)

    widget1 = gtk.Alignment(0.5, 0.5, 0, 0)
    button1 = dtk.ui.button.Button()
    button1.set_size_request(200, 22)
    widget1.add(button1)

    widget2 = gtk.Alignment(0.5, 0.5, 0, 0)
    button2 = gtk.Button("Button2")
    widget2.add(button2)

    widget3 = gtk.Alignment(0.5, 0.5, 0, 0)
    text_entry = dtk.ui.entry.InputEntry()
    text_entry.set_size(100, 22)
    widget3.add(text_entry)

    widget_list = [label_align, widget1, widget2, widget3]

    global i
    i = 1
    gobject.timeout_add(3000, slider_loop, slider, widget_list)

    #win.add(slider)
    #win.show_all()
    #gtk.main()
    app.main_box.pack_start(slider)
    app.run()
Example #42
0
    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 %= '*****@*****.**'
        # 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
Example #43
0
 def _schedule_cmds_update(self, *unused):
     if not self.cmds_update_scheduled:
         gobject.timeout_add(100, self._do_repopulate)
     return True
Example #44
0
 def _timer_start(self):
     # Need to stop it, otherwise we potentially leak a timer id that will
     # never be stopped.
     self._timer_stop()
     self._timer = gobject.timeout_add(self._interval, self._on_timer)
Example #45
0
 def __init__(self, stat=None):
     gobject.GObject.__init__(self)
     self.stat = stat or linuxcnc.stat()
     self.old = {}
     gobject.timeout_add(100, self.update)
Example #46
0
    def __init__ (self, lc):
        self.lc = lc
        self.cmds_update_scheduled = False
        self.config_filename = None
        self.script_done_action = None

        # deputy spawned by the sheriff
        self.spawned_deputy = None

        # create sheriff and subscribe to events
        self.sheriff = sheriff.Sheriff (self.lc)
        self.sheriff.command_added.connect(self._schedule_cmds_update)
        self.sheriff.command_removed.connect(self._schedule_cmds_update)
        self.sheriff.command_status_changed.connect(self._schedule_cmds_update)
        self.sheriff.command_group_changed.connect(self._schedule_cmds_update)
        self.sheriff.script_started.connect(self._on_script_started)
        self.sheriff.script_action_executing.connect(self._on_script_action_executing)
        self.sheriff.script_finished.connect(self._on_script_finished)
        self.sheriff.script_added.connect(self._on_script_added)
        self.sheriff.script_removed.connect(self._on_script_removed)

        # update very soon
        gobject.timeout_add(100, lambda *s: self.hosts_ts.update() and False)
        gobject.timeout_add(100, lambda *s: self._schedule_cmds_update() and False)

        # and then periodically
        gobject.timeout_add (1000, self._maybe_send_orders)
        gobject.timeout_add (1000,
                lambda *s: self._schedule_cmds_update () or True)

        self.lc.subscribe ("PMD_ORDERS", self.on_procman_orders)

        # setup GUI

        self.builder = gtk.Builder()
        self.builder.add_from_file(find_bot_procman_glade())
        self.builder.connect_signals(self)

        self.window = self.builder.get_object("main_window")

        self.cmds_ts = cm.SheriffCommandModel(self.sheriff)
        self.cmds_tv = ctv.SheriffCommandTreeView(self.sheriff, self.cmds_ts)

        # load save menu
        self.load_cfg_mi = self.builder.get_object("load_cfg_mi")
        self.save_cfg_mi = self.builder.get_object("save_cfg_mi")
        self.load_dlg = None
        self.save_dlg = None
        self.load_save_dir = None
        if BUILD_PREFIX and os.path.exists("%s/data/procman" % BUILD_PREFIX):
            self.load_save_dir = "%s/data/procman" % BUILD_PREFIX

        # options menu
        self.is_observer_cmi = self.builder.get_object("is_observer_cmi")
        self.spawn_deputy_mi = self.builder.get_object("spawn_deputy_mi")
        self.terminate_spawned_deputy_mi = self.builder.get_object("terminate_spawned_deputy_mi")

        self.bot_procman_deputy_cmd = find_bot_procman_deputy_cmd()
        if not self.bot_procman_deputy_cmd:
            sys.stderr.write("Can't find bot-procman-deputy.  Spawn Deputy disabled")
            self.spawn_deputy_mi.set_sensitive(False)

        # commands menu
        self.start_cmd_mi = self.builder.get_object("start_cmd_mi")
        self.stop_cmd_mi = self.builder.get_object("stop_cmd_mi")
        self.restart_cmd_mi = self.builder.get_object("restart_cmd_mi")
        self.remove_cmd_mi = self.builder.get_object("remove_cmd_mi")
        self.edit_cmd_mi = self.builder.get_object("edit_cmd_mi")
        self.new_cmd_mi = self.builder.get_object("new_cmd_mi")

        # scripts menu
        self.abort_script_mi = self.builder.get_object("abort_script_mi")
        self.edit_script_mi = self.builder.get_object("edit_script_mi")
        self.remove_script_mi = self.builder.get_object("remove_script_mi")
        self.scripts_menu = self.builder.get_object("scripts_menu")
        self.edit_scripts_menu = self.builder.get_object("edit_scripts_menu")
        self.remove_scripts_menu = self.builder.get_object("remove_scripts_menu")

        vpane = self.builder.get_object("vpaned")

        sw = gtk.ScrolledWindow()
        sw.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
        hpane = self.builder.get_object("hpaned")
        hpane.pack1(sw, resize = True)
        sw.add(self.cmds_tv)

        cmds_sel = self.cmds_tv.get_selection()
        cmds_sel.connect ("changed", self._on_cmds_selection_changed)

        # create a checkable item in the View menu for each column to toggle
        # its visibility in the treeview
        view_menu = self.builder.get_object("view_menu")
        for col in self.cmds_tv.get_columns():
            name = col.get_title ()
            col_cmi = gtk.CheckMenuItem(name)
            col_cmi.set_active(col.get_visible())
            def on_activate(cmi, col_):
                should_be_visible = cmi.get_active()
                if col_.get_visible() != should_be_visible:
                    col_.set_visible(should_be_visible)
                    if col_ == self.cmds_tv.columns[0]:
                        self.cmds_ts.set_populate_exec_with_group_name(not should_be_visible)
                        self.cmds_ts.repopulate()
            def on_visibility_changed(col_, param, cmi_):
                is_visible = col_.get_visible()
                if is_visible != cmi_.get_active():
                    cmi_.set_active(is_visible)
            col_cmi.connect("activate", on_activate, col)
            col.connect("notify::visible", on_visibility_changed, col_cmi)
            view_menu.append(col_cmi)

        # setup the hosts treeview
        self.hosts_ts = ht.SheriffHostModel(self.sheriff)
        self.hosts_tv = ht.SheriffHostTreeView(self.sheriff, self.hosts_ts)
        sw = gtk.ScrolledWindow ()
        sw.set_policy (gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
        hpane.pack2 (sw, resize = False)
        sw.add (self.hosts_tv)

        gobject.timeout_add (1000, lambda *s: self.hosts_ts.update() or True)

        # stdout textview
        self.cmd_console = cc.SheriffCommandConsole(self.sheriff, self.lc)
        vpane.add2(self.cmd_console)

        # status bar
        self.statusbar = self.builder.get_object("statusbar")
        self.statusbar_context_script = self.statusbar.get_context_id("script")
        self.statusbar_context_main = self.statusbar.get_context_id("main")
        self.statusbar_context_script_msg = None

        config_dir = os.path.join(glib.get_user_config_dir(), "procman-sheriff")
        if not os.path.exists(config_dir):
            os.makedirs(config_dir)
        self.config_fname = os.path.join(config_dir, "config")
        self.load_settings()

        self.window.show_all()
Example #47
0
    def __call__(self):
        # Execute our line of the gui log, *if* the previous line has
        # completed.  Figuring out if the previous line has completed
        # is non-trivial, because the previous line may have emitted a
        # gtk signal that caused a modal dialog box to open, in which
        # case its "emit" call won't return until the box has closed!
        # *This* line contains the commands that operate the dialog
        # box, and must be issued even though the previous command
        # hasn't returned.  If the previous line hasn't returned it
        # must have called Dialog.run or started up a new gtk main
        # loop, so by keeping track of gtk.main_level() and the number
        # of open dialogs, we can tell when it's time to execute our
        # line.  (This is why we must redefine the Dialog class.)
        if self.logrunner.aborted:
            # The previous line raised an exception, so don't run this
            # line, even though it's already been installed as an idle
            # callback.
            self.status = "aborted"
            return False

        # Run this line, but only if there are no postponed lines
        # ready to go, and if this line is also ready.
        if not self.run_postponed() and self.ready():
            assert self.status in ("repeating", "installed")
            # Add the idle callback for the next line *before*
            # executing our line, because we might not return
            # until after the next line is done!  This is why we
            # need a separate idle callback for each line.
            if self.status != "repeating" and self.nextLine() is not None:
                self.nextLine().start()

            if _threaded:
                gtk.gdk.threads_enter()
            try:
                if self.status == "installed":
                    self.status = "running"
                    self.report()
                self.runLevel = logutils.run_level()
                # self.playback performs some suitable action and
                # returns True if the idle callback should be
                # repeated, and False if it shouldn't.  It can also
                # reinstall the callback, and should set self.status
                # to "done" if the task is finished.
                try:
                    result = self.playback()
                    if self.nextLine() is None:
                        self.logrunner.stop()
                    return result
                except logutils.GtkLoggerTopFailure:
                    # It's possible that the previous log line tried
                    # to open a window, but the window hasn't actually
                    # appeared yet.  In that case, our line will have
                    # failed with a GtkLoggerTopFailure exception.  We
                    # just want to keep trying (within reason) until
                    # the window appears.  Using checkpoints to wait
                    # until the window is mapped makes this problem
                    # less frequent, but doesn't make it go away
                    # entirely.
                    self.status = "repeating"
                    self.ntries += 1
                    if self.ntries == maxtries:
                        if logutils.debugLevel() >= 1:
                            print >> sys.stderr, \
                                  "Failed to find top-level widget after", \
                                  self.ntries, "attempts."
                        raise
                    # Keep trying.  By reinstalling ourself in the
                    # idle callback table and returning False
                    # (meaning, "don't repeat this callback") we move
                    # to the back of the queue.  This allows the
                    # widget we are waiting for to appear, we hope.
                    gobject.timeout_add(retrydelay,
                                        self,
                                        priority=gobject.PRIORITY_LOW)
                    return False

                except logutils.exceptions(), exc:
                    # Any type of exception other than GtkLoggerTopFailure
                    # is fatal.
                    self.status = "aborted"
                    self.logrunner.abort()
                    if self.logrunner.exceptHook:
                        if not self.logrunner.exceptHook(exc, self.srcline):
                            raise exc
            finally:
                gtk.gdk.flush()
                if _threaded:
                    gtk.gdk.threads_leave()
        # We're still waiting for the previous line to execute. We put
        # ourself at the back of the execution queue (by reinstalling
        # and returning False) so that the previous line will run
        # first.
        if logutils.debugLevel() >= 4:
            print >> sys.stderr, "Reinstalling", self.srcline
        gobject.timeout_add(retrydelay, self, priority=gobject.PRIORITY_LOW)
        return False
Example #48
0
            gui.load_config(cfg)
            gui.load_save_dir = os.path.dirname(args[0])

        if script_name:
            script = gui.sheriff.get_script(script_name)
            if not script:
                print "No such script: %s" % script_name
                gui._terminate_spawned_deputy()
                sys.exit(1)
            errors = gui.sheriff.check_script_for_errors(script)
            if errors:
                print "Unable to run script.  Errors were detected:\n\n"
                print "\n    ".join(errors)
                gui._terminate_spawned_deputy()
                sys.exit(1)
            gobject.timeout_add(200, lambda *s: gui.run_script(None, script, script_done_action))

        signal.signal(signal.SIGINT, lambda *s: gtk.main_quit())
        signal.signal(signal.SIGTERM, lambda *s: gtk.main_quit())
        signal.signal(signal.SIGHUP, lambda *s: gtk.main_quit())
        try:
            gtk.main ()
        except KeyboardInterrupt:
            print("Exiting")
        gui.cleanup()
    else:
        if not script_name:
            print("No script specified and running in headless mode.  Exiting")
            sys.exit(1)
        SheriffHeadless(lc, cfg, spawn_deputy, script_name, script_done_action).run()
Example #49
0
    def __init__(self, source):
        gtk.Statusbar.__init__(self)

        hb = gtk.HBox()

        #connected indicator
        self._c = indicators.ColorLabelBox("C:",
                                red_message="Communication not connected",
                                yellow_message="Communication connected, not receiving data",
                                green_message="Communication connected, receiving data")
        hb.pack_start(self._c)
        #status indicator
        #self._s = indicators.ColorLabelBox("S:",
        #                        red_message="UAV Error",
        #                        yellow_message="UAV Warning",
        #                        green_message="UAV OK")
        #hb.pack_start(self._s)
        #autopilot indicator
        self._a = indicators.ColorLabelBox("A:",
                                red_message="Autopilot disabled",
                                green_message="Autopilot enabled")
        hb.pack_start(self._a)
        #manual indicator
        self._m = indicators.ColorLabelBox("M:",
                                red_message="Manual control disabled",
                                green_message="Manual control enabled")
        hb.pack_start(self._m)

        #msgs/second        
        self._ms = gs.ui.make_label("MSG/S: ?", 10)
        hb.pack_start(self._ms, False, False)
        #ping time
        self._pt = gs.ui.make_label("PING: ?", 12)
        hb.pack_start(self._pt, False, False)
        #GPS LL
        self._gps_coords = gs.ui.make_label("GPS: +???.???? N, +???.???? E")
        hb.pack_start(self._gps_coords, False, False)
        #Altitude
        self._alt = gs.ui.make_label("ALT: ?????.? m")
        hb.pack_start(self._alt, False, False)
        #Distance from home
        self._dist = gs.ui.make_label("DIST: ?????.? m")
        hb.pack_start(self._dist, False, False)
        self._home_lat = None
        self._home_lon = None
        #debug
        self._debug = indicators.ColorLabelBox(text="", fade=True)
        self._debug.set_blank()

        hb.pack_start(self._debug, True, True)
       
        self.pack_start(hb, False, False)
        self.reorder_child(hb, 0)

        source.connect("source-connected", self._connected_update_icon)
        source.connect("source-link-status-change", self._connected_update_icon)

        source.register_interest(self._on_gps, 0, "GPS_LLH")
        source.register_interest(self._on_debug, 0, *wasp.DEBUG_MESSAGES.keys())

        gobject.timeout_add(1000, self._check_messages_per_second, source)
Example #50
0
	def register_change_callback(self, fn):
		self.callback_fn = fn
		# Could not find a callback signal for Banshee, so just calling after some time interval
		if self.__timeout:
			gobject.source_remove(self.__timeout)
		self.__timeout = gobject.timeout_add(self.__interval * 1000, self.info_changed)
Example #51
0
 def __do_realize(self, widget):
     gobject.timeout_add(2000, self.__destroy)
	def __init__(self):
		SystemCalcDelegate.__init__(self)
		gobject.idle_add(exit_on_error, lambda: not self._write_vebus_soc())
		gobject.timeout_add(10000, exit_on_error, self._write_vebus_soc)
Example #53
0
 def geomap_failed(self):
     gtk.gdk.threads_enter()
     gobject.timeout_add(0, self.failed_init)
     gtk.gdk.threads_leave()
def main():
    logging.basicConfig(level=logging.INFO)

    DBusGMainLoop(set_as_default=True)
    conn = dbus.SystemBus()

    generators = smart_dict()
    consumers = smart_dict()
    stats = smart_dict()

    # Set the user timezone
    if 'TZ' not in os.environ:
        tz = query(conn, "com.victronenergy.settings", "/Settings/System/TimeZone")
        if tz is not None:
            os.environ['TZ'] = tz

    # Find solarcharger services
    solarchargers = find_services(conn, 'solarcharger')
    logger.info("Found solarchargers at %s", ', '.join(solarchargers))

    # Find grid meters
    meters = find_services(conn, 'grid')
    logger.info("Found grid meters at %s", ', '.join(meters))

    # Find vebus service
    vebus = str(query(conn, "com.victronenergy.system", "/VebusService"))
    logger.info("Found vebus at %s", vebus)

    # Track solarcharger yield
    for charger in solarchargers:
        track(conn, generators, charger, "/Yield/User", charger)

    # Track grid consumption
    for meter in meters:
        track(conn, consumers, meter, "/Ac/L1/Energy/Forward", meter)

    # Track vebus consumption, from battery to input and output
    track(conn, consumers, vebus, "/Energy/InverterToAcOut", "c1")
    track(conn, consumers, vebus, "/Energy/InverterToAcIn1", "c2")
 
    # Track power values
    track(conn, stats, "com.victronenergy.system", "/Ac/Consumption/L1/Power", "pc")
    track(conn, stats, "com.victronenergy.system", "/Dc/Pv/Power", "pg")
    # Track battery volts, from battery to input and output
    track(conn, stats, "com.victronenergy.system", "/Dc/Battery/Voltage", "v6")

    # Periodic work
    def _upload():
        energy_generated = sum(filter(None, generators.itervalues()))
        energy_consumed = sum(filter(None, consumers.itervalues()))

        logger.info("EG: %.2f, EC: %.2f, PG: %.2f, PC: %.2f", energy_generated,
            energy_consumed, stats.pg, stats.pc)

        # Post the values to pvoutput
        now = datetime.now()
        payload = {
            "d": now.strftime("%Y%m%d"),
            "t": now.strftime("%H:%M"),
            "v1": int(energy_generated*1000),
            "v2": int(stats.pg),
            "v3": int(energy_consumed*1000),
            "v4": int(stats.pc),
	        "v6": int(stats.v6),
            "c1": 1
        }
        try:
            requests.post(PVOUTPUT,
                headers={
                    "X-Pvoutput-Apikey": APIKEY,
                    "X-Pvoutput-SystemId": SYSTEMID
                }, data=payload)
        except:
            pass

        return True

    _upload()
    gobject.timeout_add(INTERVAL, _upload)

    gobject.MainLoop().run()
Example #55
0
 def start(self, sender=None):
     if self.timer is None:
         self.timer = gobject.timeout_add(self.delay, self.onTimeout)
Example #56
0
def InspectionTeam(main_screen):
    global everytime_keydown, last_brt, passout_time_stage, gobject_flash_led1

    cur_time = time.time()
    time_1 = config.PowerLevels[config.PowerLevel][0]
    time_2 = config.PowerLevels[config.PowerLevel][1]
    time_3 = config.PowerLevels[config.PowerLevel][2]

    if cur_time - everytime_keydown > time_1 and passout_time_stage == 0:
        print("timeout, dim screen %d" % int(cur_time - everytime_keydown))

        try:
            f = open(config.BackLight, "r+")
        except IOError:
            pass
        else:
            with f:
                content = f.readlines()
                content = [x.strip() for x in content]
                brt = int(content[0])
                if brt > 0:
                    if last_brt < 0:
                        last_brt = brt  ## remember brt for restore

                    brt = 1
                    f.seek(0)
                    f.write(str(brt))
                    f.truncate()
                    f.close()

        main_screen._TitleBar._InLowBackLight = 0

        if time_2 != 0:
            passout_time_stage = 1  # next
        everytime_keydown = cur_time

    elif cur_time - everytime_keydown > time_2 and passout_time_stage == 1:
        print("timeout, close screen %d" % int(cur_time - everytime_keydown))

        try:
            f = open(config.BackLight, "r+")
        except IOError:
            pass
        else:
            with f:
                brt = 0
                f.seek(0)
                f.write(str(brt))
                f.truncate()
                f.close()

        main_screen._TitleBar._InLowBackLight = 0
        main_screen._Closed = True
        if time_3 != 0:
            passout_time_stage = 2  # next

        gobject_flash_led1 = gobject.timeout_add(200, GobjectFlashLed1,
                                                 main_screen)

        everytime_keydown = cur_time

    elif cur_time - everytime_keydown > time_3 and passout_time_stage == 2:
        print("Power Off counting down")

        main_screen._CounterScreen.Draw()
        main_screen._CounterScreen.SwapAndShow()
        main_screen._CounterScreen.StartCounter()

        try:
            f = open(config.BackLight, "r+")
        except IOError:
            pass
        else:
            with f:
                brt = last_brt
                f.seek(0)
                f.write(str(brt))
                f.truncate()
                f.close()

        main_screen._TitleBar._InLowBackLight = 0

        passout_time_stage = 4

    return True
Example #57
0
    def _enable_autoscroll(self):

        if not self._scroll_timeout:
            self._scroll_timeout = gobject.timeout_add(self.AUTOSCROLL_TIMEOUT,
                                                       self._do_autoscroll)
Example #58
0
 def geomap_ready(self):
     gtk.gdk.threads_enter()
     gobject.timeout_add(0, self.finish_init)
     gtk.gdk.threads_leave()
Example #59
0
    global n

    #######################################################################################
    # Open file, read the content, and update data on the graph
    d = loadtxt(filename(n))
    curve1[0].set_ydata(d[:, 1])
    curve2[0].set_ydata(d[:, 2])
    fig.canvas.draw()

    #######################################################################################
    # Update n
    playbutton.on_clicked(play_pause)
    if (run): n += step
    else:
        val = int(progress.val)
        n = val - val % 10
    if (n <= nsteps):
        progress.set_val(n)
        return True
    else:
        return False


#########################################################################################
# Do the animation
n = 0
run = True
if (run): gobject.timeout_add(30, updatefig)
show()

######### End of script #################################################################
Example #60
0
    def _enable_autoexpand(self):

        if not self._expand_timeout:
            self._expand_timeout = gobject.timeout_add(self.AUTOEXPAND_TIMEOUT,
                                                       self._do_autoexpand)