Beispiel #1
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)

        scripts_combo = gtk.combo_box_new_text()
        scripts_combo.append_text(self.cfg.get("scripts", "name"))
        
        for script in get_scripts_list():
            if script.lower() != self.cfg.get("scripts", "name"):
                scripts_combo.append_text(script)

        scripts_combo.connect('changed', self._comboChanged, "scripts", "name")
        scripts_combo.set_active(0)
        
        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)
            
            if not alg_inf:
                continue
            
            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.pack_start(scripts_combo, False, False)

        algo_box.show_all()

        frame.add( algo_box )
        frame.show()

        self.noteBook.insert_page(frame, gtk.Label( _("Algorithm") ) )
Beispiel #2
0
    def algorithm_tab( self ):
        """
        The cam module Preff Tab.

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

        frame = Gtk.Frame()

        algo_box = Gtk.Grid()
        algo_box.set_column_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)

        scripts_combo = Gtk.ComboBoxText()
        scripts_combo.append_text(self.cfg.get("scripts", "name"))

        for script in get_scripts_list():
            if script.lower() != self.cfg.get("scripts", "name"):
                scripts_combo.append_text(script)

        scripts_combo.connect('changed', self._comboChanged, "scripts", "name")
        scripts_combo.set_active(0)

        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)

            if not alg_inf:
                continue

            state = False
            if alg_inf["name"].lower() in self.cfg.get("main", "algorithm").lower():
                state = True
            # FIXME: I don't know what the purpose of this liststore is,
            # but it wants strings, so let's not argue for now. ;)
            liststore.append([state, alg_inf["name"], alg_inf["dsc"], str(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.add(tree_view)
        algo_box.attach_next_to(conf_button, tree_view, Gtk.PositionType.BOTTOM, 1, 1)
        algo_box.attach_next_to(scripts_combo, conf_button, Gtk.PositionType.BOTTOM, 1, 1)

        algo_box.show_all()

        frame.add( algo_box )
        frame.show()

        self.noteBook.insert_page(frame, Gtk.Label(label= _("Algorithm")), -1)