Example #1
0
    def handleKeyboardInput(self, window, event):
        """
        Callback to handle custom keyboard shortcuts.
        
        Arguments:
        - self: The main object pointer
        - window: The GTK Window object where the event happened
        - event: The GDK event containing relevant event data
        """

        if not hasattr(self.ctr, "idm"):
            return

        key = event.string
        alg_inf = pocv.get_idm_inf("color")

        # Right now this only works for the color idm. Maybe
        # all idms should have a standard method to stop and start
        # tracking?

        if alg_inf["name"] == "color":
            if key == "t":
                try:
                    self.ctr.idm.startTracking()
                except ValueError:
                    print "The selection height/width are invalid."
            elif key == "x":
                if not hasattr(self.ctr, "idm"):
                    return

                self.ctr.idm.stopTracking()
            elif key == "m":
                if not hasattr(self.ctr, "idm"):
                    return

                self.ctr.idm.selSizeUp()
            elif key == "n":
                if not hasattr(self.ctr, "idm"):
                    return

                self.ctr.idm.selSizeDown()
            elif key == "w":
                if not hasattr(self.ctr, "idm"):
                    return
                self.ctr.idm.selPositionUp()
            elif key == "a":
                if not hasattr(self.ctr, "idm"):
                    return
                self.ctr.idm.selPositionLeft()
            elif key == "s":
                if not hasattr(self.ctr, "idm"):
                    return
                self.ctr.idm.selPositionDown()
            elif key == "d":
                if not hasattr(self.ctr, "idm"):
                    return
                self.ctr.idm.selPositionRight()
Example #2
0
    def __init__(self):
        Mapper.__init__(self, 200, 160)

        self.point       = None
        self.border_with = 0
        """
        self.threshold = 1 # Threshold for mouse movement.  If any mouse movement is 
                           # smaller than self.threshold pixels (I guess) then the mouse is not moved.
                           # Trying to reduce jitteriness. Not working.
        self.same_location_count = 0 # Yeah this variable name is bad.  It means the number of times
                                     # that the cursor has been in the same location under the threshold.
        """
        self.connect("expose_event", self.expose_event)
        
        self.cfg = settings.load()
    
        algorithm_info = pocv.get_idm_inf("color")
        
        self.scale = self.cfg.get("color", "vscale") 
Example #3
0
    def algorithm_tab( self ):
        """
        The cam module Preff Tab.

        Arguments:
        - self: The main object pointer.
        """

        frame = gtk.Frame()

        algo_box = gtk.VBox( spacing = 6 )

        liststore = gtk.ListStore(bool, str, str, str)

        conf_button = gtk.Button(stock=gtk.STOCK_PREFERENCES)
        conf_button.connect('clicked', self.show_alg_pref, liststore)
        conf_button.set_sensitive(False)

        tree_view = gtk.TreeView(liststore)
        tree_view.connect("cursor-changed", self._tree_view_click, conf_button)

        toggle_cell = gtk.CellRendererToggle()
        toggle_cell.set_radio(True)
        toggle_cell.connect( 'toggled', self._toggle_cell_changed, liststore)
        toggle_cell.set_property('activatable', True)
        #toggle_cell.set_property('background-set' , True)

        name_cell = gtk.CellRendererText()
        desc_cell = gtk.CellRendererText()

        toggle_column = gtk.TreeViewColumn(_('Active Algorithms'), toggle_cell)
        name_column = gtk.TreeViewColumn(_('Installed Algorithms'))
        desc_column = gtk.TreeViewColumn(_('Description'))

        for alg in pocv.get_idms_list():
            alg_inf = pocv.get_idm_inf(alg)
            state = False
            if alg_inf["name"].lower() in self.cfg.get("main", "algorithm").lower():
                state = True
            liststore.append([state, alg_inf["name"], alg_inf["dsc"], alg_inf["stgs"]])
            #liststore.append([False, "%s: %s" % (alg_inf["name"], alg_inf["dsc"]), alg_inf["stgs"]])

        tree_view.append_column(toggle_column)
        tree_view.append_column(name_column)
        tree_view.append_column(desc_column)

        name_column.pack_start(name_cell, True)
        desc_column.pack_start(desc_cell, True)

        toggle_column.add_attribute( toggle_cell, "active", 0 )
        toggle_column.set_max_width(30)
        #toggle_column.set_attributes( toggle_cell, background=2 )
        name_column.set_attributes(name_cell, text=1)
        desc_column.set_attributes(desc_cell, text=2)

        algo_box.pack_start(tree_view)
        algo_box.pack_start(conf_button, False, False)



        algo_box.show_all()

        frame.add( algo_box )
        frame.show()

        self.noteBook.insert_page(frame, gtk.Label( _("Algorithm") ) )