示例#1
0
    def setup_podcasts_treeview(self):
        column = gtk.TreeViewColumn('')
        cell = gtk.CellRendererToggle()
        column.pack_start(cell, False)
        column.add_attribute(cell, 'active', DirectoryPodcastsModel.C_SELECTED)
        cell.connect('toggled',
                     lambda cell, path: self.podcasts_model.toggle(path))
        self.tv_podcasts.append_column(column)

        column = gtk.TreeViewColumn('')
        cell = gtk.CellRendererText()
        cell.set_property('ellipsize', pango.ELLIPSIZE_END)
        column.pack_start(cell)
        column.add_attribute(cell, 'markup', DirectoryPodcastsModel.C_MARKUP)
        self.tv_podcasts.append_column(column)

        self.tv_podcasts.set_model(self.podcasts_model)
        self.podcasts_model.append((False, 'a', 'b', 'c'))
示例#2
0
文件: choose.py 项目: fenildf/wordjoy
    def __set_header_title(self):
        """设置标题行
        """
        choose = gtk.CellRendererToggle()
        choose.connect("toggled", self.__choose_toggled)
        head_title = gtk.TreeViewColumn("选择", choose, active=COLUMN_CHOOSE)
        head_title.set_sort_column_id(COLUMN_CHOOSE)
        self.treeview_word.append_column(head_title)

        head_title = gtk.TreeViewColumn("单词",
                                        gtk.CellRendererText(),
                                        text=COLUMN_WORD)
        self.treeview_word.append_column(head_title)

        head_title = gtk.TreeViewColumn("解释",
                                        gtk.CellRendererText(),
                                        text=COLUMN_MEANING)
        self.treeview_word.append_column(head_title)
示例#3
0
    def __init__(self, model=None):
        gtk.TreeView.__init__(self, model)

        self.get_selection().set_mode(gtk.SELECTION_MULTIPLE)

        # Setup the first column
        cell = gtk.CellRendererToggle()
        cell.set_property('mode', gtk.CELL_RENDERER_MODE_ACTIVATABLE)
        cell.set_activatable(True)
        cell.connect('toggled', self.on_toggle)

        self.append_column(gtk.TreeViewColumn(None, cell, active=0))

        # Setup the second column
        self.append_column(
            gtk.TreeViewColumn(_('Group'), gtk.CellRendererText(), text=1))

        self.connect('key_press_event', self.on_key_press)
示例#4
0
 def create_tree(self):
     """Create our TreeView and populate it with columns."""
     debug("create_tree (self):", 5)
     self.create_model()
     self.tree = gtk.TreeView(self.mod)
     txtr = gtk.CellRendererText()
     togr = gtk.CellRendererToggle()
     togr.set_property('activatable', True)
     togr.connect('toggled', self.toggle_ing_cb)
     #togr.start_editing()
     for n, t in [[1, 'Amount'], [2, 'Unit'], [3, 'Item']]:
         col = gtk.TreeViewColumn(t, txtr, text=n)
         col.set_resizable(True)
         self.tree.append_column(col)
     bcol = gtk.TreeViewColumn('Add to Shopping List', togr, active=4)
     self.tree.append_column(bcol)
     self.vbox.add(self.tree)
     self.tree.show()
示例#5
0
 def build_activities_tree_view(self):
     ''' Build tree view to hold activities that can be selected for import '''
     logging.debug('>>')
     store = gtk.ListStore(gobject.TYPE_STRING, gobject.TYPE_BOOLEAN,
                           gobject.TYPE_STRING, gobject.TYPE_STRING,
                           gobject.TYPE_STRING, gobject.TYPE_STRING,
                           gobject.TYPE_STRING, gobject.TYPE_STRING,
                           gobject.TYPE_BOOLEAN)
     column_names = [
         "id", "",
         _("Start Time"),
         _("Distance"),
         _("Duration"),
         _("Sport"),
         _("Notes"), "file_id", "in_db"
     ]
     for column_index, column_name in enumerate(column_names):
         if column_index == 1:
             #Add checkbox column
             self.renderer1 = gtk.CellRendererToggle()
             self.renderer1.set_property('activatable', True)
             self.renderer1.connect(
                 'toggled', self.treeviewImportEvents_toggled_checkbox,
                 store)
             column = gtk.TreeViewColumn(column_name, self.renderer1)
             column.add_attribute(self.renderer1, "active", column_index)
             column.set_sort_column_id(-1)
             column.connect('clicked',
                            self.treeviewImportEvents_header_checkbox,
                            store)
         else:
             #Add other columns
             column = gtk.TreeViewColumn(column_name,
                                         gtk.CellRendererText(),
                                         text=column_index)
             column.set_sort_column_id(column_index)
         if column_name == "id" or column_name == "file_id" or column_name == "in_db":
             column.set_visible(False)
         column.set_resizable(True)
         self.treeviewImportEvents.append_column(column)
     self.treeviewImportEvents.set_headers_clickable(True)
     self.treeviewImportEvents.set_model(store)
     logging.debug('<<')
     return store
示例#6
0
    def __init__(self, flickr):
        self.flickr = flickr
        self.model = gtk.ListStore(gobject.TYPE_BOOLEAN,
                                   gobject.TYPE_STRING,
                                   gobject.TYPE_STRING,
                                   gtk.gdk.Pixbuf)
        self.model.connect("row-changed", lambda model, path, iter: self.emit("changed"))
        
        gtk.TreeView.__init__(self, self.model)
        
        # Calculate the size of thumbnails based on the size of the text
        # renderer, but provide a default in case style-set isn't called.
        self.connect("style-set", self.style_set);
        self.thumb_size = 24

        column = gtk.TreeViewColumn('Selected')
        self.append_column(column)
        
        renderer =  gtk.CellRendererToggle()
        def toggled(r, path):
            self.model[path][COL_SELECTED] = not r.get_active()
        renderer.connect("toggled", toggled)
        column.pack_start(renderer, False)
        column.add_attribute(renderer, "active", COL_SELECTED)
        
        column = gtk.TreeViewColumn('Group')
        self.append_column(column)

        renderer =  gtk.CellRendererPixbuf()
        column.pack_start(renderer, False)
        column.add_attribute(renderer, "pixbuf", COL_ICON)
        
        self.text_renderer =  gtk.CellRendererText()
        column.pack_start(self.text_renderer, True)
        column.add_attribute(self.text_renderer, "text", COL_NAME)
        
        self.set_size_request(-1, 24 * 3 + self.style_get_property("vertical-separator") * 6)
        self.set_headers_visible(False)
        self.set_search_column(COL_NAME)
        def search_func(model, column, key, iter):
            s = model.get_value(iter, column)
            # This API is braindead, false=matches
            return key.lower() not in s.lower()
        self.set_search_equal_func(search_func)
示例#7
0
    def __init__(self):
        self.liststore = gtk.ListStore(bool, str)  #keep?, name
        render_keep = gtk.CellRendererToggle()
        render_keep.connect('toggled', self.toggled)
        column_keep = gtk.TreeViewColumn()
        column_keep.pack_start(render_keep, False)
        column_keep.set_cell_data_func(render_keep, self.toggle_data_func)
        render_text = gtk.CellRendererText()
        render_text.set_property('ellipsize', pango.ELLIPSIZE_END)
        column_text = gtk.TreeViewColumn(_('Unused software configuration'))
        column_text.pack_start(render_text, True)
        column_text.set_cell_data_func(render_text, self.text_data_func)
        self.view = view = gtk.TreeView(self.liststore)
        view.append_column(column_keep)
        view.append_column(column_text)
        view.set_rules_hint(True)
        scroll = gtk.ScrolledWindow()
        scroll.set_policy(gtk.POLICY_NEVER, gtk.POLICY_AUTOMATIC)
        scroll.set_shadow_type(gtk.SHADOW_IN)
        scroll.add(view)

        button_refresh = gtk.Button(_('Refresh'))
        button_refresh.connect('clicked', lambda *w: self.refresh())
        self.button_unselect_all = button_unselect_all = gtk.Button(
            _('Select all'))
        button_unselect_all.connect('clicked', lambda *w: self.unselect_all())
        self.button_delete = button_delete = gtk.Button(_('Delete'))
        button_delete.connect('clicked', lambda *w: self.delete_packages())
        button_box = gtk.VBox(False, 5)
        button_box.pack_start(button_refresh, False)
        button_box.pack_start(button_unselect_all, False)
        button_box.pack_start(button_delete, False)
        align = gtk.Alignment(0, 0.5)
        align.add(button_box)

        gtk.HBox.__init__(self, False, 10)
        self.pack_start(scroll)
        self.pack_start(align, False)

        view.set_sensitive(False)
        self.liststore.append([True, _('Please press the "Refresh" button.')])
        button_unselect_all.set_sensitive(False)
        button_delete.set_sensitive(False)
        self.refresh()
示例#8
0
 def add_cell_renderer_for_value(self, col, col_title):
     """(Override) Add a cell renderer type based on the column."""
     self._update_available_profiles()
     if col_title in self.OPTION_NL_MAP:
         cell_for_value = gtk.CellRendererCombo()
         listmodel = gtk.ListStore(str)
         values = sorted(self._available_profile_map[col_title])
         for possible_value in values:
             listmodel.append([possible_value])
         cell_for_value.set_property("has-entry", False)
         cell_for_value.set_property("editable", True)
         cell_for_value.set_property("model", listmodel)
         cell_for_value.set_property("text-column", 0)
         try:
             cell_for_value.connect("changed",
                                    self._handle_cell_combo_change,
                                    col_title)
         except TypeError:
             # PyGTK 2.14 - changed signal.
             cell_for_value.connect("edited",
                                    self._handle_cell_combo_change,
                                    col_title)
         col.pack_start(cell_for_value, expand=True)
         col.set_cell_data_func(cell_for_value,
                                self._set_tree_cell_value_combo)
     elif col_title == self.INCLUDED_TITLE:
         cell_for_value = gtk.CellRendererToggle()
         col.pack_start(cell_for_value, expand=False)
         cell_for_value.set_property("activatable", True)
         cell_for_value.connect("toggled",
                                self._handle_cell_toggle_change)
         col.set_cell_data_func(cell_for_value,
                                self._set_tree_cell_value_toggle)
     else:
         cell_for_value = gtk.CellRendererText()
         col.pack_start(cell_for_value, expand=True)
         if (col_title not in [self.SECTION_INDEX_TITLE,
                               self.DESCRIPTION_TITLE]):
             cell_for_value.set_property("editable", True)
             cell_for_value.connect("edited",
                                    self._handle_cell_text_change,
                                    col_title)
         col.set_cell_data_func(cell_for_value,
                                self._set_tree_cell_value)
示例#9
0
 def _psr_start(self, name, attrs):
     if name == 'tree':
         self.title = attrs.get('string', _('Tree'))
         self.toolbar = bool(attrs.get('toolbar', False))
         self.colors = {}
         for color_spec in attrs.get('colors', '').split(';'):
             if color_spec:
                 colour, test = color_spec.split(':')
                 self.colors.setdefault(colour, [])
                 self.colors[colour].append(test)
     elif name == 'field':
         if attrs.get('invisible', False):
             self.invisible_fields.append(str(attrs['name']))
             return True
         type = self.fields[attrs['name']]['type']
         field_name = attrs.get('string',
                                self.fields[attrs['name']]['string'])
         if type != 'boolean':
             column = gtk.TreeViewColumn(field_name)
             if 'icon' in attrs:
                 render_pixbuf = gtk.CellRendererPixbuf()
                 column.pack_start(render_pixbuf, expand=False)
                 column.add_attribute(render_pixbuf, 'pixbuf', self.pos)
                 self.fields_order.append(str(attrs['icon']))
                 self.pixbufs[self.pos] = True
                 self.pos += 1
             cell = gtk.CellRendererText()
             cell.set_fixed_height_from_font(1)
             if type == 'float':
                 cell.set_property('xalign', 1.0)
             column.pack_start(cell, expand=False)
             column.add_attribute(cell, 'text', self.pos)
         else:
             cell = gtk.CellRendererToggle()
             column = gtk.TreeViewColumn(field_name, cell, active=self.pos)
         self.pos += 1
         column.set_resizable(1)
         self.fields_order.append(str(attrs['name']))
         self.tree.append_column(column)
     else:
         import logging
         log = logging.getLogger('view')
         log.error('unknown tag: ' + str(name))
         del log
示例#10
0
    def get_widget(self):
        # create a TreeStore with one string column to use as the model
        self.treestore = gtk.TreeStore(str, bool)

        # we'll add some data now - 4 rows with 3 child rows each
        for parent in range(4):
            piter = self.treestore.append(None, ['parent %i' % parent, True])
            for child in range(3):
                self.treestore.append(
                    piter, ['child %i of parent %i' % (child, parent), False])

        # create the TreeView using treestore
        self.treeview = gtk.TreeView(self.treestore)

        # create the TreeViewColumn to display the data
        self.tvcolumn = gtk.TreeViewColumn('Column 0')

        # add tvcolumn to treeview
        self.treeview.append_column(self.tvcolumn)

        self.toggle = gtk.CellRendererToggle()
        self.tvcolumn.pack_start(self.toggle, False)
        self.tvcolumn.add_attribute(self.toggle, 'active', 1)

        # create a CellRendererText to render the data
        self.cell = gtk.CellRendererText()

        # add the cell to the tvcolumn and allow it to expand
        self.tvcolumn.pack_start(self.cell, True)

        # set the cell "text" attribute to column 0 - retrieve text
        # from that column in treestore
        self.tvcolumn.add_attribute(self.cell, 'text', 0)

        # make it searchable
        self.treeview.set_search_column(0)

        # Allow sorting on the column
        self.tvcolumn.set_sort_column_id(0)

        # Allow drag and drop reordering of rows
        self.treeview.set_reorderable(True)
        return self.treeview
示例#11
0
    def __init__(self, svnClient):
        self._svnClient = svnClient

        gladefile = "/home/laz/src/nautilus-svn/src/nautilus-svn.glade"
        windowname = "svn_commit"

        self._wTree = gtk.glade.XML(gladefile, windowname)

        signalDict = {
            "on_svn_commit_destroy": gtk.main_quit,
            "on_cancelButton_clicked": gtk.main_quit,
            "on_okButton_clicked": self._ok_button_clicked
        }
        self._wTree.signal_autoconnect(signalDict)

        self._view = self._wTree.get_widget('commitFileList')
        self._commit_textview = self._wTree.get_widget('commit_comment')

        ## The model columns are:
        ## 0. path of file
        ## 1. Status string (Added, Modified, Not Modified...)
        ## 2. If it CAN be committed (e.g. is changed somehow)
        ## 3. If the user wants it committed
        self._model = gtk.ListStore(gobject.TYPE_STRING, gobject.TYPE_STRING,
                                    gobject.TYPE_BOOLEAN, gobject.TYPE_BOOLEAN)
        self._view.set_model(self._model)

        renderer = gtk.CellRendererToggle()
        column = gtk.TreeViewColumn("Commit",
                                    renderer,
                                    activatable=2,
                                    active=3)
        self._view.append_column(column)
        renderer.connect('toggled', self._view_toggled)

        renderer = gtk.CellRendererText()
        column = gtk.TreeViewColumn("File", renderer, text=0)
        column.set_expand(True)
        self._view.append_column(column)

        renderer = gtk.CellRendererText()
        column = gtk.TreeViewColumn("Status", renderer, text=1)
        self._view.append_column(column)
示例#12
0
    def pack(self):
        label = gtk.Label()
        label.set_markup("<b>The following custom will be exexuted:</b>")
        label.set_alignment(0, 0.5)

        self.treeview_choose = gtk.TreeView()
        cr = gtk.CellRendererToggle()
        cr.connect("toggled", self.toggled, self.treeview_choose)
        column1 = gtk.TreeViewColumn("Order", cr)
        column1.set_cell_data_func(cr, self.celldatafunction_checkbox)
        column2 = gtk.TreeViewColumn("Description", gtk.CellRendererText(), text=1)
        column2.set_sort_column_id(1)
        column2.set_resizable(True)
        self.treeview_choose.append_column(column1)
        self.treeview_choose.append_column(column2)
        operations = ['aaa', 'bbb', 'ccc', 'ddd', 'eee', 'fff']
        model = gtk.TreeStore(str, str)
        for oper in operations:
            iter = model.insert_before(None, None)
            model.set_value(iter, 0, "true")
            model.set_value(iter, 1, oper)
        self.treeview_choose.set_model(model)
        self.treeview_choose.set_headers_clickable(False)
        self.treeview_choose.set_reorderable(False)

        scrolledWindow = gtk.ScrolledWindow()
        scrolledWindow.set_shadow_type(gtk.SHADOW_IN)
        scrolledWindow.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
        scrolledWindow.add(self.treeview_choose)

        hbuttonbox = gtk.HButtonBox()
        hbuttonbox.set_spacing(50)
        hbuttonbox.set_layout(gtk.BUTTONBOX_CENTER)
        btn_accept = gtk.Button("accept")
        btn_accept.connect("clicked", self.btn_accept_clicked, self.treeview_choose)
        btn_cancel = gtk.Button("cancel")
        btn_cancel.connect("clicked", self.btn_cancel_clicked)
        hbuttonbox.pack_start(btn_accept)
        hbuttonbox.pack_end(btn_cancel)

        self.pack_start(label, False, False, 10)
        self.pack_start(scrolledWindow, True, True, 0)
        self.pack_start(hbuttonbox, False, False, 5)
示例#13
0
    def __init__(self):
        gtk.ScrolledWindow.__init__(self)
        self.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)

        self.targets = TargetsList()
        self.sm = gtk.TreeModelSort(self.targets)
        self.tv = gtk.TreeView(self.sm)
        self.tv.set_rules_hint(True)

        colHeads = [
            _('Name'),
            _('RA'),
            _('DEC'),
            _('Altitude'),
            _('Azimuth'),
            _('Enabled')
        ]
        colRenders = [
            None, self.renderRa, self.renderDec, self.renderAlt, self.renderAz,
            None
        ]

        for i in range(0, len(colHeads)):
            col = gtk.TreeViewColumn(colHeads[i])
            col.set_sort_column_id(i)
            col.set_expand(False)
            if i == 5:
                cel = gtk.CellRendererToggle()
                col.pack_start(cel)
                col.set_attributes(cel, active=i)
            else:
                cel = gtk.CellRendererText()
                col.pack_start(cel)
                if colRenders[i] is not None:
                    col.set_cell_data_func(cel, colRenders[i])
                else:
                    col.set_attributes(cel, text=i)

            self.tv.append_column(col)

        self.tv.set_reorderable(True)

        self.add(self.tv)
示例#14
0
    def __prepare_treeview__(self):
        self.treemodel = gtk.TreeStore(gobject.TYPE_STRING,
                                       gobject.TYPE_STRING,
                                       gobject.TYPE_STRING,
                                       gobject.TYPE_STRING,
                                       gobject.TYPE_BOOLEAN)
        self.treeview.set_model(self.treemodel)

        renderer = gtk.CellRendererText()
        renderer2 = gtk.CellRendererToggle()
        renderer2.set_property("activatable", True)
        renderer2.connect('toggled', self.__visible_toggled__, self.treemodel)
        column = gtk.TreeViewColumn("Item", renderer, text=0)
        column2 = gtk.TreeViewColumn("Visible", renderer2, active=4)
        column.set_resizable(True)
        self.treeview.append_column(column)
        self.treeview.append_column(column2)
        self.treeview.set_expander_column(column)
        return
示例#15
0
 def setupTreeView (self):
     self.FIELD_COL = 1
     self.VALUE_COL = 2
     self.COUNT_COL = 3
     self.REC_COL = 4
     self.NUT_COL = 5
     for n,head in [[self.FIELD_COL,_('Field')],
                    [self.VALUE_COL,_('Value')],
                    [self.COUNT_COL,_('Count')],
                    [self.REC_COL, _('Recipes')],
                    #[self.NUT_COL, _('Nutritional Info')],
                    ]:
         if n == self.NUT_COL:
             renderer = gtk.CellRendererToggle()
         else:
             renderer = gtk.CellRendererText()
         # If we have gtk > 2.8, set up text-wrapping
         try:
             renderer.get_property('wrap-width')
         except TypeError:
             pass
         else:
             renderer.set_property('wrap-mode',gtk.WRAP_WORD)
             if n == self.FIELD_COL:
                 renderer.set_property('wrap-width',60)
             elif n in [self.VALUE_COL,self.REC_COL]: renderer.set_property('wrap-width',250)
             else: renderer.set_property('wrap-width',100)
         if n==self.VALUE_COL:
             renderer.set_property('editable',True)
             renderer.connect('edited',self.tree_edited,n,head)
         if n == self.NUT_COL:
             col = gtk.TreeViewColumn(head, renderer, active=n, visible=n)
         else:
             col = gtk.TreeViewColumn(head, renderer, text=n)
         if n == self.VALUE_COL:
             col.set_property('expand',True)
         col.set_resizable(True)
         self.treeview.append_column(col)
     plugin_manager = keyEditorPluggable.get_key_editor_plugin_manager()
     for tvc in plugin_manager.get_treeview_columns(None,
                                                    key_col=2,
                                                    instant_apply=True):
         self.treeview.append_column(tvc)
示例#16
0
    def __init__(self):
        gtk.TreeView.__init__(self)
        self.list = gtk.ListStore(str, str, int, int, bool)

        type_col = gtk.TreeViewColumn("Type")
        name_col = gtk.TreeViewColumn("Name")
        name_col.set_expand(True)
        quantity_col = gtk.TreeViewColumn("Quantity")
        delay_col = gtk.TreeViewColumn("Delay")
        unhook_col = gtk.TreeViewColumn("Unhook")

        self.append_column(type_col)
        self.append_column(name_col)
        self.append_column(quantity_col)
        self.append_column(delay_col)
        self.append_column(unhook_col)

        type_cell = gtk.CellRendererText()
        type_col.pack_start(type_cell, False)
        type_col.add_attribute(type_cell, "text", 0)

        name_cell = gtk.CellRendererText()
        name_col.pack_start(name_cell, False)
        name_col.add_attribute(name_cell, "text", 1)

        quantity_cell = gtk.CellRendererText()
        quantity_col.pack_start(quantity_cell, False)
        quantity_col.add_attribute(quantity_cell, "text", 2)

        delay_cell = gtk.CellRendererText()
        delay_col.pack_start(delay_cell, False)
        delay_col.add_attribute(delay_cell, "text", 3)

        unhook_cell = gtk.CellRendererToggle()
        unhook_col.pack_start(unhook_cell, False)
        unhook_col.add_attribute(unhook_cell, "active", 4)

        self.set_search_column(1)
        self.set_reorderable(True)
        self.set_model(self.list)

        self.filename = None
        self.changed = False
示例#17
0
    def create_subscription_columns(self, subscriptions_treeview):
        renderertoggle = gtk.CellRendererToggle()
        column = gtk.TreeViewColumn("Active",
                                    renderertoggle,
                                    activatable=1,
                                    active=1)
        column.set_sort_column_id(1)
        subscriptions_treeview.append_column(column)

        renderertext = gtk.CellRendererText()
        column = gtk.TreeViewColumn("Name", renderertext, text=2)
        column.set_sort_column_id(2)
        subscriptions_treeview.append_column(column)

        renderertext = gtk.CellRendererText()
        column = gtk.TreeViewColumn("Feed name", renderertext, text=3)
        column.set_sort_column_id(3)
        subscriptions_treeview.append_column(column)

        renderertext = gtk.CellRendererText()
        column = gtk.TreeViewColumn("Site", renderertext, text=4)
        column.set_sort_column_id(4)
        subscriptions_treeview.append_column(column)

        renderertext = gtk.CellRendererText()
        column = gtk.TreeViewColumn("Last Matched", renderertext, text=5)
        column.set_sort_column_id(5)
        subscriptions_treeview.append_column(column)

        renderertext = gtk.CellRendererText()
        column = gtk.TreeViewColumn("Move Completed", renderertext, text=6)
        column.set_sort_column_id(6)
        subscriptions_treeview.append_column(column)

        self.subscription_popup_menu = gtk.Menu()

        menuitem = gtk.MenuItem("Run this subscription")
        self.subscription_popup_menu.append(menuitem)
        menuitem.connect("activate", self.on_button_run_subscription_clicked)

        menuitem = gtk.MenuItem("Reset last matched timestamp")
        self.subscription_popup_menu.append(menuitem)
        menuitem.connect("activate", self.on_button_reset_last_matched)
示例#18
0
    def _createRepoStore(self, tree):
        self.repoStore = gtk.ListStore(gobject.TYPE_PYOBJECT,
                                       gobject.TYPE_BOOLEAN,
                                       gobject.TYPE_STRING)

        col = gtk.TreeViewColumn(None, None)
        cbr = gtk.CellRendererToggle()
        col.pack_start(cbr, False)
        col.add_attribute(cbr, 'active', REPO_ENABLED_COLUMN)
        cbr.connect("toggled", self._repoToggled)
        tree.append_column(col)

        col = gtk.TreeViewColumn(None, None)
        txt = gtk.CellRendererText()
        col.pack_start(txt, False)
        col.add_attribute(txt, 'markup', REPO_TEXT_COLUMN)
        tree.append_column(col)

        tree.set_model(self.repoStore)
示例#19
0
    def __add_column(self):
        renderer = gtk.CellRendererToggle()
        renderer.connect('toggled', self.on_package_toggled)
        column = gtk.TreeViewColumn(' ', renderer, active=COLUMN_CHECK)
        column.set_sort_column_id(COLUMN_CHECK)
        self.append_column(column)

        self.__column = gtk.TreeViewColumn(_('Package'))
        self.__column.set_sort_column_id(COLUMN_NAME)
        self.__column.set_spacing(5)
        renderer = gtk.CellRendererPixbuf()
        self.__column.pack_start(renderer, False)
        self.__column.set_attributes(renderer, pixbuf=COLUMN_ICON)

        renderer = gtk.CellRendererText()
        self.__column.pack_start(renderer, True)
        self.__column.set_attributes(renderer, markup=COLUMN_DISPLAY)

        self.append_column(self.__column)
示例#20
0
文件: winpref.py 项目: peircej/jbrout
    def init(self, plugins, liste):
        self.notebook1.set_current_page(1)
        self.liste = liste[:]
        #
        model = gtk.TreeStore(str, int, int, object)
        self.tvPlugins.set_model(model)

        def mkRacine(nom, typ):
            it = model.append(None, [nom, 0, 0, ""])
            for instance, callback, props in plugins.request(typ, all=True):
                isChecked = "%s.%s" % (instance.id, props["method"]) \
                    in self.liste
                model.append(it, [
                    props["label"], isChecked, 1, (instance, callback, props)
                ])

            self.tvPlugins.expand_row(model.get_path(it), False)
            return it

        mkRacine(_("Photos"), "PhotosProcess")
        mkRacine(_("Albums"), "AlbumProcess")

        renderer = gtk.CellRendererToggle()
        renderer.set_data("column", 1)  # data on col 1
        renderer.connect("toggled", self.on_item_toggled, model)
        column = gtk.TreeViewColumn(
            "chk",
            renderer,
            active=1,  # active on col 1
            visible=2,  # visibl on col 2
        )
        column.set_sizing(gtk.TREE_VIEW_COLUMN_AUTOSIZE)
        # ~ column.set_fixed_width(50)
        column.set_clickable(True)
        self.tvPlugins.append_column(column)

        #
        cell_renderer = gtk.CellRendererText()
        column = gtk.TreeViewColumn("name", cell_renderer, text=0)
        self.tvPlugins.append_column(column)
        #

        self.main_widget.show_all()
示例#21
0
    def __create_services_treeview(self):
        liststore = gtk.ListStore(str, 'gboolean', str, str)
        toggle_renderer = gtk.CellRendererToggle()
        column = gtk.TreeViewColumn('services_selected',
                                    toggle_renderer,
                                    active=1)
        self.services_treeview.append_column(column)
        column = gtk.TreeViewColumn('services_name',
                                    gtk.CellRendererText(),
                                    text=2,
                                    foreground=3)
        self.services_treeview.append_column(column)

        self.services_treeview.set_model(liststore)

        treeselection = self.services_treeview.get_selection()
        treeselection.set_mode(gtk.SELECTION_SINGLE)
        treeselection.connect('changed',
                              self.__on_services_treeview_selection_changed)
示例#22
0
    def build_list(self):

        store = gtk.ListStore(bool, str)
        self.view = self.tree.get_widget("packageList")
        self.view.set_model(store)

        cell = gtk.CellRendererText()
        tCell = gtk.CellRendererToggle()
        tCell.set_property("activatable", True)
        tCell.connect(
            "toggled",
            self.cb_check_toggled)  # emulate the normal toggle behavior ...

        self.view.append_column(
            gtk.TreeViewColumn(_("Enabled"), tCell, active=0))
        self.view.append_column(gtk.TreeViewColumn(_("Package"), cell, text=1))

        for p in self.packages:
            store.append([False, p])
示例#23
0
 def show(self):
     count = len(self.entry.categories)
     service = self.service
     self.lbInfo.set_text(self.info % locals())
     self.model = gtk.ListStore(bool, str, gobject.TYPE_PYOBJECT)
     cell0 = gtk.CellRendererToggle()
     cell0.set_property('radio', False)
     cell0.set_property('activatable', True)
     cell0.connect('toggled', self.on_lvCategories_toggle, self.model)
     cells = (cell0, gtk.CellRendererText())
     columns = (
         gtk.TreeViewColumn(_('Select'), cells[0], active=0),
         gtk.TreeViewColumn(_('Category name'), cells[1], text=1),
     )
     for column in columns:
         self.lvCategories.append_column(column)
     self.lvCategories.set_model(self.model)
     self._fillList()
     self.window.present()
示例#24
0
    def __set_sel_box(self):
        hbox = gtk.HBox(False)
        sb = gtk.ScrolledWindow()
        grid = gtk.TreeView(self.__set_model())
        grid.set_grid_lines(gtk.TREE_VIEW_GRID_LINES_BOTH)
        grid.connect('row-activated', self.__on_row_activated)

        renderText = gtk.CellRendererText()
        column = gtk.TreeViewColumn('#', renderText, text=0)
        grid.append_column(column)
        column = gtk.TreeViewColumn('Наименование', renderText, text=1)
        column.set_resizable(True)
        grid.append_column(column)
        column = gtk.TreeViewColumn('IP', renderText, text=2)
        grid.append_column(column)
        cellBoll = gtk.CellRendererToggle()
        #renderText=gtk.CellRendererText()
        cellBoll.set_property('activatable', True)
        #column=gtk.TreeViewColumn('Исп.',renderText,text=3,editable=2)
        column = gtk.TreeViewColumn('Исп.', cellBoll, active=3)

        grid.append_column(column)

        sb.add(grid)
        sb.show_all()
        hbox.pack_start(sb, True, True, 4)
        vbutton = gtk.VButtonBox()
        runbutton = gtk.Button('Передача')
        runbutton.connect('clicked', self.__on_click, 'run')
        selall = gtk.Button('Выбрать все')
        selall.connect('clicked', self.__on_click, 'sellall')
        if self.select_multi_mode == 1:
            selall.set_sensitive(False)
        deselectall = gtk.Button('Сбросить все')
        deselectall.connect('clicked', self.__on_click, 'delsall')
        if self.select_multi_mode == 1:
            deselectall.set_sensitive(False)
        vbutton.add(runbutton)
        vbutton.add(selall)
        vbutton.add(deselectall)
        hbox.pack_start(vbutton, False, True, 4)
        return hbox
示例#25
0
文件: ui.py 项目: gdelpierre/tonic
    def __create_pkg_list(self):
        # Create the data container
        self.liststore = gtk.TreeStore(bool, str, str, str)

        # Create the view
        self.treeview = gtk.TreeView(self.liststore)
        self.treeview.set_rules_hint(True)
        self.treeview.set_headers_clickable(False)
        self.treeview.set_enable_search(False)

        # Create the scrollbar container
        self.scrollwin = gtk.ScrolledWindow()
        self.scrollwin.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
        # Add the treeview into the scrollbar container
        self.scrollwin.add(self.treeview)

        # Create selection column
        renderer_toggle = gtk.CellRendererToggle()
        renderer_toggle.connect("toggled", self.__on_cell_sel_toggled)
        self.column_toggle = gtk.TreeViewColumn(None, renderer_toggle, active=0)
        self.treeview.append_column(self.column_toggle)

        # Create pkg name column
        renderer_text = gtk.CellRendererText()
        self.column_name = gtk.TreeViewColumn("Name", renderer_text, text=1)
        self.column_name.set_resizable(True)
        self.column_name.set_min_width(50)
        self.column_name.set_sort_column_id(1)
        self.treeview.append_column(self.column_name)

        # Create pkg desc column
        self.column_desc = gtk.TreeViewColumn("Description", renderer_text, text=2)
        self.column_desc.set_resizable(True)
        self.treeview.append_column(self.column_desc)

        # Create pkg version column
        self.column_version = gtk.TreeViewColumn("Version", renderer_text, text=3)
        self.column_version.set_resizable(True)
        self.treeview.append_column(self.column_version)

        # Add the pkg list in the window
        return self.scrollwin
示例#26
0
    def __add_column(self):
        renderer = gtk.CellRendererToggle()
        renderer.connect('toggled', self.on_enable_toggled)
        column = gtk.TreeViewColumn(' ', renderer, active=self.COLUMN_ENABLED)
        column.set_sort_column_id(self.COLUMN_ENABLED)
        self.append_column(column)

        column = gtk.TreeViewColumn(_('Third-Party Sources'))
        column.set_sort_column_id(self.COLUMN_NAME)
        column.set_spacing(5)
        renderer = gtk.CellRendererPixbuf()
        column.pack_start(renderer, False)
        column.set_attributes(renderer, pixbuf=self.COLUMN_LOGO)

        renderer = gtk.CellRendererText()
        renderer.set_property('ellipsize', pango.ELLIPSIZE_END)
        column.pack_start(renderer, True)
        column.set_attributes(renderer, markup=self.COLUMN_DISPLAY)

        self.append_column(column)
示例#27
0
 def __init__(self):
     gtk.VBox.__init__(self)
     ##plugin name, plugin long name, version, enabled, can be disabled
     self.model = gtk.ListStore(gobject.TYPE_STRING, gobject.TYPE_STRING,
                                gobject.TYPE_STRING, gobject.TYPE_BOOLEAN,
                                gobject.TYPE_BOOLEAN)
     self.get_plugins()
     view = gtk.TreeView(self.model)
     self.pack_start(view)
     name = gtk.CellRendererText()
     view.append_column(gtk.TreeViewColumn('Name', name, text=1))
     version = gtk.CellRendererText()
     view.append_column(gtk.TreeViewColumn('Version', version, text=2))
     enable_toggle = gtk.CellRendererToggle()
     enable_toggle.connect('toggled', self.enable_toggle_signal)
     view.append_column(
         gtk.TreeViewColumn('Enabled',
                            enable_toggle,
                            active=3,
                            activatable=4))
示例#28
0
    def create_columns(self, treeView):
        rendererToggle = gtk.CellRendererToggle()
        column = gtk.TreeViewColumn("On",
                                    rendererToggle,
                                    activatable=True,
                                    active=1)
        column.set_sort_column_id(1)
        treeView.append_column(column)
        tt = gtk.Tooltip()
        tt.set_text('Double-click to toggle')
        treeView.set_tooltip_cell(tt, None, None, rendererToggle)

        rendererText = gtk.CellRendererText()
        column = gtk.TreeViewColumn("Path", rendererText, text=2)
        column.set_sort_column_id(2)
        treeView.append_column(column)
        tt2 = gtk.Tooltip()
        tt2.set_text('Double-click to edit')
        #treeView.set_tooltip_cell(tt2, None, column, None)
        treeView.set_has_tooltip(True)
示例#29
0
 def add_bool_column(self,
                     header,
                     col_type=bool,
                     hidden=False,
                     position=None,
                     status_field=None,
                     sortid=0,
                     column_type="bool",
                     default=True):
     """Add a bool column to the listview"""
     render = gtk.CellRendererToggle()
     self.add_column(header,
                     render,
                     col_type,
                     hidden,
                     position,
                     status_field,
                     sortid,
                     column_type=column_type,
                     default=default)
示例#30
0
    def __create_columns(self):
        column = gtk.TreeViewColumn()
        self.treeview.append_column(column)

        cell = gtk.CellRendererToggle()
        cell.connect("toggled", self.__on_toggled)
        column.pack_start(cell, False)
        column.set_attributes(cell, active=self.COLUMN_DISABLED)

        column = gtk.TreeViewColumn()
        column.set_spacing(6)
        self.treeview.append_column(column)

        cell = gtk.CellRendererPixbuf()
        column.pack_start(cell, False)
        column.set_attributes(cell, icon_name=self.COLUMN_ICON_NAME)

        cell = gtk.CellRendererText()
        column.pack_start(cell, True)
        column.set_attributes(cell, text=self.COLUMN_NAME)