Python gtk 模块,CellRendererText() 实例源码

我们从Python开源项目中,提取了以下47个代码示例,用于说明如何使用gtk.CellRendererText()

项目:hostapd-mana    作者:adde88    | 项目源码 | 文件源码
def __init__(self, o=None):
        self.xml = x = gtk.glade.XML(sibpath(__file__, "inspectro.glade"))
        self.tree_view = x.get_widget("treeview")
        colnames = ["Name", "Value"]
        for i in range(len(colnames)):
            self.tree_view.append_column(
                gtk.TreeViewColumn(
                colnames[i], gtk.CellRendererText(), text=i))
        d = {}
        for m in reflect.prefixedMethods(self, "on_"):
            d[m.im_func.__name__] = m
        self.xml.signal_autoconnect(d)
        if o is not None:
            self.inspect(o)
        self.ns = {'inspect': self.inspect}
        iwidget = x.get_widget('input')
        self.input = ConsoleInput(iwidget)
        self.input.toplevel = self
        iwidget.connect("key_press_event", self.input._on_key_press_event)
        self.output = ConsoleOutput(x.get_widget('output'))
项目:ns3-rdma    作者:bobzhuyb    | 项目源码 | 文件源码
def __init__(self):
            super(ShowLastPackets.PacketList, self).__init__()
            self.set_properties(hscrollbar_policy=gtk.POLICY_AUTOMATIC,
                                vscrollbar_policy=gtk.POLICY_AUTOMATIC)
            self.table_model = gtk.ListStore(*([str]*4))
            treeview = gtk.TreeView(self.table_model)
            treeview.show()
            self.add(treeview)

            def add_column(descr, colid):
                column = gtk.TreeViewColumn(descr, gtk.CellRendererText(), text=colid)
                treeview.append_column(column)

            add_column("Time", self.COLUMN_TIME)
            add_column("Interface", self.COLUMN_INTERFACE)
            add_column("Size", self.COLUMN_SIZE)
            add_column("Contents", self.COLUMN_CONTENTS)
项目:Taigabot    作者:FrozenPigs    | 项目源码 | 文件源码
def create_list_view(col_label,):
    # create list widget
    list_ = gtk.ListStore(str)
    list_view = gtk.TreeView(model=list_)

    list_view.set_rules_hint(True)
    list_view.get_selection().set_mode(gtk.SELECTION_SINGLE)
    # Add Colums
    renderer = gtk.CellRendererText()
    renderer.set_data("column", COLUMN_SUGGESTION)
    column = gtk.TreeViewColumn(col_label, renderer,text=COLUMN_SUGGESTION)
    list_view.append_column(column)
    return list_view
项目:zim-icontags-plugin    作者:Pl-M    | 项目源码 | 文件源码
def __init__(self, index, ui):
        self.index = index
        self.ui = ui
        self.current_tag = None

        self.model = gtk.ListStore(str, int, str) # PAGE_COL, TAGS_COL
        SingleClickTreeView.__init__(self, self.model)

        cells = (('Page', self.PAGE_COL, True),
                 ('N', self.TAGS_N_COL, False),
                 ('Tags', self.TAGS_COL, True))
        for name, col_id, expand in (cells):
            cell = gtk.CellRendererText()
            cell.set_property('ellipsize', pango.ELLIPSIZE_END)
            cell.set_property('cell-background', 'white')
            col = gtk.TreeViewColumn(name, cell)
            col.set_attributes(cell, text = col_id)
            col.set_resizable(expand)
        col.set_expand(expand)
        col.set_sort_column_id(col_id)
            self.append_column(col)

        self.connect('row-activated', lambda treeview, path, column:
                              self.row_activated(path, column))
        self.refill_model()
项目:zim-icontags-plugin    作者:Pl-M    | 项目源码 | 文件源码
def __init__(self, index, ui):
        self.tagview = TagsView.new_from_index(index)
        self.ui = ui
        self.current_tag = None

        self.model = gtk.ListStore(str, int, str) # PAGE_COL, TAGS_COL
        SingleClickTreeView.__init__(self, self.model)

        cells = (('Page', self.PAGE_COL, True),
                 ('N', self.TAGS_N_COL, False),
                 ('Tags', self.TAGS_COL, True))
        for name, col_id, expand in cells:
            cell = gtk.CellRendererText()
            cell.set_property('ellipsize', pango.ELLIPSIZE_END)
            cell.set_property('cell-background', 'white')
            col = gtk.TreeViewColumn(name, cell)
            col.set_attributes(cell, text = col_id)
            col.set_resizable(expand)
            col.set_expand(expand)
            col.set_sort_column_id(col_id)
            self.append_column(col)

        self.connect('row-activated', lambda treeview, path, column:
                              self.row_activated(path, column))
        self.refill_model()
项目:barbieri-playground    作者:barbieri    | 项目源码 | 文件源码
def setup_gui_url_chooser(self):
        self.media_model = gtk.ListStore(str)
        self.media_type = gtk.ComboBox(self.media_model)
        cell = gtk.CellRendererText()
        self.media_type.pack_start(cell, True)
        self.media_type.add_attribute(cell, "text", 0)

        for t in ("file", "dvd", "tv", "dvb", "vcd", "radio", "cdda", "tivo"):
            self.media_model.append((t,))

        self.media_location = gtk.Entry()
        self.media_server = gtk.Label()
        self.media_server.set_alignment(0, 0.5)

        d = catota.ui.Dialog("Choose Location", self.parent_win,
                             extra_buttons=(gtk.STOCK_PREFERENCES, 1))

        t = catota.ui.new_table((("Server:", self.media_server),
                                 ("Type:", self.media_type),
                                 ("Location:", self.media_location)))
        d.vbox.pack_start(t, True, True)

        self.gui_url_chooser = d
    # setup_gui_url_chooser()
项目:sslstrip-hsts-openwrt    作者:adde88    | 项目源码 | 文件源码
def __init__(self, o=None):
        self.xml = x = gtk.glade.XML(sibpath(__file__, "inspectro.glade"))
        self.tree_view = x.get_widget("treeview")
        colnames = ["Name", "Value"]
        for i in range(len(colnames)):
            self.tree_view.append_column(
                gtk.TreeViewColumn(
                colnames[i], gtk.CellRendererText(), text=i))
        d = {}
        for m in reflect.prefixedMethods(self, "on_"):
            d[m.im_func.__name__] = m
        self.xml.signal_autoconnect(d)
        if o is not None:
            self.inspect(o)
        self.ns = {'inspect': self.inspect}
        iwidget = x.get_widget('input')
        self.input = ConsoleInput(iwidget)
        self.input.toplevel = self
        iwidget.connect("key_press_event", self.input._on_key_press_event)
        self.output = ConsoleOutput(x.get_widget('output'))
项目:lfde    作者:mv-code    | 项目源码 | 文件源码
def load_page(self):
        self.frontend.builder.connect_signals({"on_btn_unmount_clicked" : self.on_btn_unmount_clicked})
        self.trv_mounted = self.frontend.builder.get_object("trv_mounted")

        self.trv_mounted_model = gtk.ListStore(str, str)
        self.trv_mounted.set_model(self.trv_mounted_model)

        column_0 = gtk.TreeViewColumn('Device')

        cell_renderer_0 = gtk.CellRendererText()
        column_0.pack_start(cell_renderer_0, True)
        column_0.add_attribute(cell_renderer_0, 'text', 0)
        self.trv_mounted.append_column(column_0)

        column_1 = gtk.TreeViewColumn('Mountpoint')

        cell_renderer_1 = gtk.CellRendererText()
        column_1.pack_start(cell_renderer_1, True)
        column_1.add_attribute(cell_renderer_1, 'text', 1)
        self.trv_mounted.append_column(column_1)

        self.trv_mounted_tree_selection = self.trv_mounted.get_selection()
项目:lfde    作者:mv-code    | 项目源码 | 文件源码
def load_page(self):
        self.trv_drives = self.frontend.builder.get_object("trv_drives")
        self.frontend.builder.connect_signals({"on_trv_drives_cursor_changed" : self.on_trv_drives_cursor_changed})


        self.trv_drives_model = gtk.ListStore(str, str)
        self.trv_drives.set_model(self.trv_drives_model)

        column_0 = gtk.TreeViewColumn('Device')

        cell_renderer_0 = gtk.CellRendererText()
        column_0.pack_start(cell_renderer_0, True)
        column_0.add_attribute(cell_renderer_0, 'text', 0)
        self.trv_drives.append_column(column_0)

        column_1 = gtk.TreeViewColumn('Size (GB)')

        cell_renderer_1 = gtk.CellRendererText()
        column_1.pack_start(cell_renderer_1, True)
        column_1.add_attribute(cell_renderer_1, 'text', 1)
        self.trv_drives.append_column(column_1)

        self.trv_drives_tree_selection = self.trv_drives.get_selection()
项目:NativeCAM    作者:FernV    | 项目源码 | 文件源码
def __init__(self, treeview) :
        gtk.CellRendererText.__init__(self)
        self.set_property('xpad', 2)
        self.set_property("wrap-mode", 2)
        self.set_property("editable", True)

        self.max_value = 999999.9
        self.min_value = -999999.9
        self.data_type = 'string'
        self.tv = treeview
        self.options = ''
        self.param_value = ''
        self.combo_values = []
        self.tooltip = ''
        self.preedit = None
        self.edited = None
        self.refresh_fn = None
        self.inputKey = ''
        self.tool_list = []
        self.not_allowed = None
        self.convertible_units = False
        self.convert_units = False
        self.save_edit = ''
        self.opened_paren = 0
项目:griffith    作者:Strit    | 项目源码 | 文件源码
def loans_treeview(self):
    self.loans_treemodel = gtk.TreeStore(str, str, str)  # move to self.widgets
    self.widgets['movie']['loan_history'].set_model(self.loans_treemodel)
    self.widgets['movie']['loan_history'].set_headers_visible(True)
    # loan date
    renderer = gtk.CellRendererText()
    self.date_column = gtk.TreeViewColumn(_('Loan Date'), renderer, text=0)
    self.date_column.set_resizable(True)
    self.widgets['movie']['loan_history'].append_column(self.date_column)
    self.date_column.set_sort_column_id(0)
    # return date
    renderer = gtk.CellRendererText()
    self.return_column = gtk.TreeViewColumn(_('Return Date'), renderer, text=1)
    self.return_column.set_resizable(True)
    self.widgets['movie']['loan_history'].append_column(self.return_column)
    # loan to
    renderer = gtk.CellRendererText()
    self.loaner_column = gtk.TreeViewColumn(_('Loaned To'), renderer, text=2)
    self.loaner_column.set_resizable(True)
    self.widgets['movie']['loan_history'].append_column(self.loaner_column)
项目:pyttrss    作者:balanceofcowards    | 项目源码 | 文件源码
def show(self, articles):
        treestore = gtk.TreeStore(str, str, str, int)
        for article in articles:
            entry = [article['title'], article['link'], article['id'], 700]
            treestore.append(None, entry)
        treeview = gtk.TreeView(treestore)
        tvcolumn = gtk.TreeViewColumn('Articles: {}'.format(len(articles)))
        treeview.append_column(tvcolumn)
        cell = gtk.CellRendererText()
        tvcolumn.pack_start(cell, True)
        tvcolumn.add_attribute(cell, 'text', 0)
        tvcolumn.add_attribute(cell, 'weight', 3)
        self.window.add(treeview)
        self.window.set_position(gtk.WIN_POS_CENTER_ON_PARENT)
        treeview.connect("row-activated", self.open_article, treestore)
        treeview.connect("cursor-changed", self.skip_article, treestore)
        self.window.show_all()
项目:gnome-connection-manager    作者:mjun    | 项目源码 | 文件源码
def __init__(self, path="gnome-connection-manager.glade",
                 root="wHost",
                 domain=domain_name, **kwargs):
        path = os.path.join(glade_dir, path)
        SimpleGladeApp.__init__(self, path, root, domain, **kwargs)

        self.treeModel = gtk.ListStore(gobject.TYPE_STRING, gobject.TYPE_STRING, gobject.TYPE_STRING, gobject.TYPE_STRING)
        self.treeTunel.set_model(self.treeModel)
        column = gtk.TreeViewColumn(_("Local"), gtk.CellRendererText(), text=0)
        self.treeTunel.append_column( column )        
        column = gtk.TreeViewColumn(_("Host"), gtk.CellRendererText(), text=1)
        self.treeTunel.append_column( column )        
        column = gtk.TreeViewColumn(_("Remoto"), gtk.CellRendererText(), text=2)
        self.treeTunel.append_column( column )        


    #-- Whost.new {
项目:wahcade    作者:sairuk    | 项目源码 | 文件源码
def setup_combo_box(self, cbo, items, initial_item=None):
        """initialise a given ComboBox"""
        #create items list
        cbo.clear()
        ls = gtk.ListStore(gobject.TYPE_STRING)
        cbo.set_model(ls)
        cell = gtk.CellRendererText()
        cbo.pack_start(cell, True)
        cbo.add_attribute(cell, 'text', 0)
        #populate items
        if items:
            for item in items:
                cbo.append_text(item)
            #set initial item?
            if initial_item:
                cbo.set_active(initial_item)
项目:chirp_fork    作者:mach327    | 项目源码 | 文件源码
def make_pixbuf_choice(options, default=None):
    store = gtk.ListStore(gtk.gdk.Pixbuf, gobject.TYPE_STRING)
    box = gtk.ComboBox(store)

    cell = gtk.CellRendererPixbuf()
    box.pack_start(cell, True)
    box.add_attribute(cell, "pixbuf", 0)

    cell = gtk.CellRendererText()
    box.pack_start(cell, True)
    box.add_attribute(cell, "text", 1)

    _default = None
    for pic, value in options:
        iter = store.append()
        store.set(iter, 0, pic, 1, value)
        if default == value:
            _default = options.index((pic, value))

    if _default:
        box.set_active(_default)

    return box
项目:otRebuilder    作者:Pal3love    | 项目源码 | 文件源码
def __init__(self, fontfile):

        self.window = gtk.Window(gtk.WINDOW_TOPLEVEL)
        self.window.set_title("%s - pyftinspect" % fontfile)
        self.window.connect("delete_event", self._delete_event)
        self.window.set_size_request(400, 600)

        self.scrolled_window = gtk.ScrolledWindow()
        self.window.add(self.scrolled_window)

        self.font = ttLib.TTFont(fontfile, lazy=True)
        self.treemodel = FontTreeModel(self.font)
        self.treeview = gtk.TreeView(self.treemodel)
        #self.treeview.set_reorderable(True)

        for i in range(2):
            col_name = ('Key', 'Value')[i]
            col = gtk.TreeViewColumn(col_name)
            col.set_sort_column_id(-1)
            self.treeview.append_column(col)

            cell = gtk.CellRendererText()
            col.pack_start(cell, True)
            col.add_attribute(cell, 'text', i)

        self.treeview.set_search_column(1)
        self.scrolled_window.add(self.treeview)
        self.window.show_all()
项目:hostapd-mana    作者:adde88    | 项目源码 | 文件源码
def __init__(self, p):
        self.p = p
        vals = [time.time()]
        if p.inLog:
            vals.append(p.inLog[0][0])
        if p.outLog:
            vals.append(p.outLog[0][0])
        self.startTime = min(vals)
        p.logViewer = self
        self.xml = x = gtk.glade.XML(sibpath(__file__, "logview.glade"))
        self.xml.signal_autoconnect(self)
        self.loglist = self.xml.get_widget("loglist")
        # setup model, connect it to my treeview
        self.model = gtk.ListStore(str, str, str)
        self.loglist.set_model(self.model)
        self.loglist.set_reorderable(1)
        self.loglist.set_headers_clickable(1)
        # self.servers.set_headers_draggable(1)
        # add a column
        for col in [
            gtk.TreeViewColumn('Time',
                               gtk.CellRendererText(),
                               text=0),
            gtk.TreeViewColumn('D',
                               gtk.CellRendererText(),
                               text=1),
            gtk.TreeViewColumn('Data',
                               gtk.CellRendererText(),
                               text=2)]:
            self.loglist.append_column(col)
            col.set_resizable(1)
        r = []
        for t, data in p.inLog:
            r.append(((str(t - self.startTime), "R", repr(data)[1:-1])))
        for t, data in p.outLog:
            r.append(((str(t - self.startTime), "S", repr(data)[1:-1])))
        r.sort()
        for i in r:
            self.model.append(i)
项目:hostapd-mana    作者:adde88    | 项目源码 | 文件源码
def __init__(self):
        self.xml = gtk.glade.XML(util.sibpath(__file__,"gladereactor.glade"))
        d = {}
        for m in reflect.prefixedMethods(self, "on_"):
            d[m.im_func.__name__] = m
        self.xml.signal_autoconnect(d)
        self.xml.get_widget('window1').connect('destroy',
                                               lambda w: self.stop())
        self.servers = self.xml.get_widget("servertree")
        sel = self.servers.get_selection()
        sel.set_mode(gtk.SELECTION_SINGLE)
        sel.connect("changed",
                    self.servers_selection_changed)
        ## argh coredump: self.servers_selection_changed(sel)
        self.xml.get_widget('suspend').set_sensitive(0)
        self.xml.get_widget('disconnect').set_sensitive(0)
        # setup model, connect it to my treeview
        self.model = gtk.ListStore(str, object, gobject.TYPE_BOOLEAN,
                                   gobject.TYPE_BOOLEAN)
        self.servers.set_model(self.model)
        self.servers.set_reorderable(1)
        self.servers.set_headers_clickable(1)
        # self.servers.set_headers_draggable(1)
        # add a column
        for col in [
            gtk.TreeViewColumn('Server',
                               gtk.CellRendererText(),
                               text=0),
            gtk.TreeViewColumn('Reading',
                               gtk.CellRendererToggle(),
                               active=2),
            gtk.TreeViewColumn('Writing',
                               gtk.CellRendererToggle(),
                               active=3)]:

            self.servers.append_column(col)
            col.set_resizable(1)
        sup.__init__(self)
项目:ns3-rdma    作者:bobzhuyb    | 项目源码 | 文件源码
def __init__(self, visualizer, node_index, statistics_collector):
        InformationWindow.__init__(self)
        self.win = gtk.Dialog(parent=visualizer.window,
                              flags=gtk.DIALOG_DESTROY_WITH_PARENT|gtk.DIALOG_NO_SEPARATOR,
                              buttons=(gtk.STOCK_CLOSE, gtk.RESPONSE_CLOSE))
        self.win.connect("response", self._response_cb)
        self.win.set_title("Statistics for node %i" % node_index) 
        self.visualizer = visualizer
        self.statistics_collector = statistics_collector
        self.node_index = node_index
        self.viz_node = visualizer.get_node(node_index)

        self.table_model = gtk.ListStore(*([str]*13))

        treeview = gtk.TreeView(self.table_model)
        treeview.show()
        self.win.vbox.add(treeview)

        def add_column(descr, colid):
            column = gtk.TreeViewColumn(descr, gtk.CellRendererText(), text=colid)
            treeview.append_column(column)

        add_column("Interface", self.COLUMN_INTERFACE)

        add_column("Tx Packets", self.COLUMN_TX_PACKETS)
        add_column("Tx Bytes", self.COLUMN_TX_BYTES)
        add_column("Tx pkt/1s", self.COLUMN_TX_PACKET_RATE)
        add_column("Tx bit/1s", self.COLUMN_TX_BIT_RATE)

        add_column("Rx Packets", self.COLUMN_RX_PACKETS)
        add_column("Rx Bytes", self.COLUMN_RX_BYTES)
        add_column("Rx pkt/1s", self.COLUMN_RX_PACKET_RATE)
        add_column("Rx bit/1s", self.COLUMN_RX_BIT_RATE)

        self.visualizer.add_information_window(self)
        self.win.show()
项目:zim-icontags-plugin    作者:Pl-M    | 项目源码 | 文件源码
def __init__(self, index, preferences):
        self.index = index
        # Icons corresponding to tags, prevent unnecessary changing.
        self.icons_for_tags = preferences.copy()

        self.model = gtk.ListStore(str, gtk.gdk.Pixbuf, str, int) # TAG_COL, ICON_COL, ICON_NAME, N_PAGES_COL
        SingleClickTreeView.__init__(self, self.model)

        cells = (('Tags', self.TAG_COL, True),
                 ('Pages', self.N_PAGES_COL, False))
        for name, col_id, expand in (cells):
            cell = gtk.CellRendererText()
            cell.set_property('ellipsize', pango.ELLIPSIZE_END)
            cell.set_property('cell-background', 'white')
            col = gtk.TreeViewColumn(name, cell)
            col.set_attributes(cell, text = col_id)
            col.set_resizable(expand)
            col.set_expand(expand)
            col.set_sort_column_id(col_id)
            self.append_column(col)

        cell = gtk.CellRendererPixbuf()
        cell.set_property('cell-background', 'white')
        col = gtk.TreeViewColumn('Icon', cell)
        col.set_attributes(cell, pixbuf = self.ICON_COL)
        col.set_resizable(False)
        col.set_expand(False)
        col.set_sort_column_id(self.ICON_NAME)
        self.append_column(col)

        self.refill_model()
项目:zim-icontags-plugin    作者:Pl-M    | 项目源码 | 文件源码
def __init__(self, index, preferences):
        self.index = index
        # Icons corresponding to tags, prevent unnecessary changing.
        self.icons_for_tags = preferences.copy()

        self.model = gtk.ListStore(str, gtk.gdk.Pixbuf, str, int) # TAG_COL, ICON_COL, ICON_NAME, N_PAGES_COL
        SingleClickTreeView.__init__(self, self.model)

        cells = (('Tags', self.TAG_COL, True),
                 ('Pages', self.N_PAGES_COL, False))
        for name, col_id, expand in cells:
            cell = gtk.CellRendererText()
            cell.set_property('ellipsize', pango.ELLIPSIZE_END)
            cell.set_property('cell-background', 'white')
            col = gtk.TreeViewColumn(name, cell)
            col.set_attributes(cell, text = col_id)
            col.set_resizable(expand)
            col.set_expand(expand)
            col.set_sort_column_id(col_id)
            self.append_column(col)

        cell = gtk.CellRendererPixbuf()
        cell.set_property('cell-background', 'white')
        col = gtk.TreeViewColumn('Icon', cell)
        col.set_attributes(cell, pixbuf = self.ICON_COL)
        col.set_resizable(False)
        col.set_expand(False)
        col.set_sort_column_id(self.ICON_NAME)
        self.append_column(col)

        self.refill_model()
项目:sslstrip-hsts-openwrt    作者:adde88    | 项目源码 | 文件源码
def __init__(self, p):
        self.p = p
        vals = [time.time()]
        if p.inLog:
            vals.append(p.inLog[0][0])
        if p.outLog:
            vals.append(p.outLog[0][0])
        self.startTime = min(vals)
        p.logViewer = self
        self.xml = x = gtk.glade.XML(sibpath(__file__, "logview.glade"))
        self.xml.signal_autoconnect(self)
        self.loglist = self.xml.get_widget("loglist")
        # setup model, connect it to my treeview
        self.model = gtk.ListStore(str, str, str)
        self.loglist.set_model(self.model)
        self.loglist.set_reorderable(1)
        self.loglist.set_headers_clickable(1)
        # self.servers.set_headers_draggable(1)
        # add a column
        for col in [
            gtk.TreeViewColumn('Time',
                               gtk.CellRendererText(),
                               text=0),
            gtk.TreeViewColumn('D',
                               gtk.CellRendererText(),
                               text=1),
            gtk.TreeViewColumn('Data',
                               gtk.CellRendererText(),
                               text=2)]:
            self.loglist.append_column(col)
            col.set_resizable(1)
        r = []
        for t, data in p.inLog:
            r.append(((str(t - self.startTime), "R", repr(data)[1:-1])))
        for t, data in p.outLog:
            r.append(((str(t - self.startTime), "S", repr(data)[1:-1])))
        r.sort()
        for i in r:
            self.model.append(i)
项目:sslstrip-hsts-openwrt    作者:adde88    | 项目源码 | 文件源码
def __init__(self):
        self.xml = gtk.glade.XML(util.sibpath(__file__,"gladereactor.glade"))
        d = {}
        for m in reflect.prefixedMethods(self, "on_"):
            d[m.im_func.__name__] = m
        self.xml.signal_autoconnect(d)
        self.xml.get_widget('window1').connect('destroy',
                                               lambda w: self.stop())
        self.servers = self.xml.get_widget("servertree")
        sel = self.servers.get_selection()
        sel.set_mode(gtk.SELECTION_SINGLE)
        sel.connect("changed",
                    self.servers_selection_changed)
        ## argh coredump: self.servers_selection_changed(sel)
        self.xml.get_widget('suspend').set_sensitive(0)
        self.xml.get_widget('disconnect').set_sensitive(0)
        # setup model, connect it to my treeview
        self.model = gtk.ListStore(str, object, gobject.TYPE_BOOLEAN,
                                   gobject.TYPE_BOOLEAN)
        self.servers.set_model(self.model)
        self.servers.set_reorderable(1)
        self.servers.set_headers_clickable(1)
        # self.servers.set_headers_draggable(1)
        # add a column
        for col in [
            gtk.TreeViewColumn('Server',
                               gtk.CellRendererText(),
                               text=0),
            gtk.TreeViewColumn('Reading',
                               gtk.CellRendererToggle(),
                               active=2),
            gtk.TreeViewColumn('Writing',
                               gtk.CellRendererToggle(),
                               active=3)]:

            self.servers.append_column(col)
            col.set_resizable(1)
        sup.__init__(self)
项目:lfde    作者:mv-code    | 项目源码 | 文件源码
def load_page(self):

        self.frontend.builder.connect_signals({"on_txt_password_changed" : self.on_txt_password_changed, \
                "on_txt_password_confirm_changed" : self.on_txt_password_confirm_changed, \
                "on_chk_disable_password_toggled" : self.on_chk_disable_password_toggled,
                "on_cal_key_expiry_month_changed" : self.on_cal_key_expiry_month_changed,
                "on_cal_key_expiry_day_selected" : self.on_cal_key_expiry_day_selected})


        self.cmb_key_type = self.frontend.builder.get_object("cmb_key_type")
        self.spn_key_length = self.frontend.builder.get_object("spn_key_length")
        self.txt_password = self.frontend.builder.get_object("txt_password")
        self.txt_password_confirm = self.frontend.builder.get_object("txt_password_confirm")
        self.txt_email = self.frontend.builder.get_object("txt_email")
        self.txt_name = self.frontend.builder.get_object("txt_name")
        self.txt_comment = self.frontend.builder.get_object("txt_comment")
        self.chk_use_entropy_generator = self.frontend.builder.get_object("chk_use_entropy_generator")
        self.chk_disable_password = self.frontend.builder.get_object("chk_disable_password")
        self.cal_key_expiry = self.frontend.builder.get_object("cal_key_expiry")

        self.spn_key_length.set_value(1024)

        self.cmb_key_type_model = gtk.ListStore(str)
        self.cmb_key_type.set_model(self.cmb_key_type_model)
        cell = gtk.CellRendererText()
        self.cmb_key_type.pack_start(cell, True)
        self.cmb_key_type.add_attribute(cell, 'text', 0)

        # add in the filesystems
        self.cmb_key_type_model.append(["RSA and RSA"])
        self.cmb_key_type_model.append(["DSA and Elgamal"])
        self.cmb_key_type.set_active(0)

        self.txt_email.set_text(self.frontend.choices.email)
        self.txt_name.set_text(self.frontend.choices.gpg_name)

        # set calendar to expiry date
        key_expiry = self.frontend.choices.gpg_key_expiry_date
        self.cal_key_expiry.select_month(key_expiry.month, key_expiry.year)
        self.cal_key_expiry.select_day(key_expiry.day)
项目:lfde    作者:mv-code    | 项目源码 | 文件源码
def load_page(self):

        self.cmb_filesystems = self.frontend.builder.get_object("cmb_filesystems")
        self.prg_format = self.frontend.builder.get_object("prg_format")

        self.cmb_filesystems_model = gtk.ListStore(str)
        self.cmb_filesystems.set_model(self.cmb_filesystems_model)
        cell = gtk.CellRendererText()
        self.cmb_filesystems.pack_start(cell, True)
        self.cmb_filesystems.add_attribute(cell, 'text', 0)

        # add in the filesystems
        self.cmb_filesystems_model.append(["ext3"])
        self.cmb_filesystems_model.append(["ext4"])
        self.cmb_filesystems.set_active(1)
项目:NativeCAM    作者:FernV    | 项目源码 | 文件源码
def do_get_size(self, widget, cell_area):
        return (gtk.CellRendererText.do_get_size(self, widget, cell_area))
项目:NativeCAM    作者:FernV    | 项目源码 | 文件源码
def do_render(self, win, widget, background_area, cell_area,
                  expose_area, flags):
        if self.data_type in ['bool', 'boolean'] :
            cell_area.width = 30
            chk = gtk.CellRendererToggle()
            chk.set_active(self.param_value == '1')
            chk.render(win, widget, background_area, cell_area,
                       expose_area, flags)
        else :
            gtk.CellRendererText.do_render(self, win, widget,
                                           background_area,
                                           cell_area, expose_area, flags)
项目:griffith    作者:Strit    | 项目源码 | 文件源码
def people_treeview(self, create=True):
    row = None
    self.p_treemodel = gtk.TreeStore(gobject.TYPE_STRING, gobject.TYPE_STRING, gobject.TYPE_STRING, gobject.TYPE_STRING)
    self.widgets['preferences']['treeview'].set_model(self.p_treemodel)
    self.widgets['preferences']['treeview'].set_headers_visible(True)

    if create is True:
        # name column
        renderer = gtk.CellRendererText()
        column = gtk.TreeViewColumn(_('Name'), renderer, text=0)
        column.set_resizable(True)
        column.set_sort_column_id(0)
        self.widgets['preferences']['treeview'].append_column(column)
        # email column
        renderer = gtk.CellRendererText()
        column = gtk.TreeViewColumn(_('E-mail'), renderer, text=1)
        column.set_resizable(True)
        column.set_sort_column_id(1)
        self.widgets['preferences']['treeview'].append_column(column)
    # add data to treeview
    self.p_treemodel.clear()
    for i in self.db.session.query(db.Person.name, db.Person.email).order_by(db.Person.name.asc()):
        myiter = self.p_treemodel.insert_before(None, None)
        self.p_treemodel.set_value(myiter, 0, i.name)
        self.p_treemodel.set_value(myiter, 1, i.email)
    self.widgets['preferences']['treeview'].show()
项目:griffith    作者:Strit    | 项目源码 | 文件源码
def web_results(self):
    self.treemodel_results = gtk.TreeStore(str, str)
    self.widgets['results']['treeview'].set_model(self.treemodel_results)
    self.widgets['results']['treeview'].set_headers_visible(False)
    # column ids
    renderer = gtk.CellRendererText()
    column1 = gtk.TreeViewColumn(None, renderer, text=0)
    column1.set_visible(False)
    self.widgets['results']['treeview'].append_column(column1)
    # column titles
    renderer = gtk.CellRendererText()
    column2 = gtk.TreeViewColumn(None, renderer, text=1)
    column2.set_resizable(True)
    column2.set_sort_column_id(1)
    self.widgets['results']['treeview'].append_column(column2)
项目:griffith    作者:Strit    | 项目源码 | 文件源码
def set_model_from_list(cb, items):
    """Setup a ComboBox or ComboBoxEntry based on a list of strings."""
    model = gtk.ListStore(str)
    for i in items:
        model.append([i])
    cb.set_model(model)
    if type(cb) == gtk.ComboBoxEntry:
        cb.set_text_column(0)
    elif type(cb) == gtk.ComboBox:
        cell = gtk.CellRendererText()
        cb.pack_start(cell, True)
        cb.add_attribute(cell, 'text', 0)
项目:python-3-for-absolute-begs    作者:Apress    | 项目源码 | 文件源码
def create_treelist(self):
        """create_treelist

        Create list of options
        """ 
        # Add some messages to the window
        self.liststore = gtk.ListStore(str,str,'gboolean')
        # we'll add some data now
        self.liststore.append(['Kernel', gtk.STOCK_OPEN, True])
        self.liststore.append(['CPU', gtk.STOCK_OPEN, True])
        self.liststore.append(['RAM', gtk.STOCK_OPEN, True])
        self.liststore.append(['Sound Modules', gtk.STOCK_OPEN, True])
        self.liststore.append(['Sound Devices', gtk.STOCK_OPEN, True])
        self.liststore.append(['Asound', gtk.STOCK_OPEN, True])

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

        # Append liststore model to treeview
        self.treeview1.set_model(model=self.liststore)   

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

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

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

        # set the cell "text" attribute to column 0 - retrieve text
        # from that column in treestore
        self.tvcolumn.set_cell_data_func(self.cell0, self.make_pixbuf)
        self.tvcolumn.add_attribute(self.cell, 'text', 0)
        return
项目:gnome-connection-manager    作者:mjun    | 项目源码 | 文件源码
def initLeftPane(self):
        global groups       

        self.treeModel = gtk.TreeStore(gobject.TYPE_STRING, gobject.TYPE_PYOBJECT, gtk.gdk.Pixbuf)
        self.treeServers.set_model(self.treeModel)

        self.treeServers.set_level_indentation(5)
        #Force the alternating row colors, by default it's off with one column
        self.treeServers.set_property('rules-hint', True)
        gtk.rc_parse_string( """
                style "custom-treestyle"{
                    GtkTreeView::allow-rules = 1
                }
                widget "*treeServers*" style "custom-treestyle"
            """)
        column = gtk.TreeViewColumn()
        column.set_title('Servers')
        self.treeServers.append_column( column )

        renderer = gtk.CellRendererPixbuf()
        column.pack_start(renderer, expand=False)
        column.add_attribute(renderer, 'pixbuf', 2)

        renderer = gtk.CellRendererText()
        column.pack_start(renderer, expand=True)
        column.add_attribute(renderer, 'text', 0)

        self.treeServers.set_has_tooltip(True)
        self.treeServers.connect('query-tooltip', self.on_treeServers_tooltip)
        self.loadConfig()
        self.updateTree()
项目:gnome-connection-manager    作者:mjun    | 项目源码 | 文件源码
def new(self):        
        self.treeHosts = self.get_widget('treeHosts')
        self.treeStore = gtk.TreeStore( gobject.TYPE_BOOLEAN, gobject.TYPE_STRING, gobject.TYPE_OBJECT )
        for x in self.terms:
            self.treeStore.append( None, (False, x[0], x[1]) )
        self.treeHosts.set_model( self.treeStore )               

        crt = gtk.CellRendererToggle()
        crt.set_property('activatable', True)
        crt.connect('toggled', self.on_active_toggled)        
        col = gtk.TreeViewColumn(_("Activar"), crt, active=0)               
        self.treeHosts.append_column( col )
        self.treeHosts.append_column(gtk.TreeViewColumn(_("Host"), gtk.CellRendererText(), text=1 ))
        self.get_widget("txtCommands").history = []
    #-- Wcluster.new }

    #-- Wcluster custom methods {
    #   Write your own methods here
项目:gnome-connection-manager    作者:mjun    | 项目源码 | 文件源码
def __init__(self):
        gtk.CellRendererText.__init__(self)
        self._in_editor_menu = False
项目:linux-pentest-util    作者:fikr4n    | 项目源码 | 文件源码
def _create_treeview(self, model):
        cell_text = gtk.CellRendererText()
        cell_icon = gtk.CellRendererPixbuf()
        column = gtk.TreeViewColumn()
        column.pack_start(cell_icon, False)
        column.add_attribute(cell_icon, 'stock_id', 1)
        column.pack_start(cell_text, True)
        column.set_cell_data_func(cell_text, self.render_name_cell)
        treeview = gtk.TreeView(model)
        treeview.append_column(column)
        treeview.set_headers_visible(False)
        treeview.get_selection().set_mode(gtk.SELECTION_MULTIPLE)
        treeview.connect('key_press_event', self.on_treeview_key_press)
        return treeview
项目:linkanalysis    作者:jaap-karssenberg    | 项目源码 | 文件源码
def __init__(self, parent, notebook):
        Dialog.__init__(self, parent,
            _('Pages By Number Of Links'), # T: dialog title
            buttons=gtk.BUTTONS_CLOSE
        )
        self.notebook = notebook

        self.direction_input = gtk.combo_box_new_text()
        for dir in sorted(self.LABELS):
            self.direction_input.append_text(self.LABELS[dir])

        self.uistate.setdefault('link_direction', LINK_DIR_BACKWARD, self.LABELS.keys())
        gtk_combobox_set_active_text(
            self.direction_input,
            self.LABELS[self.uistate['link_direction']]
        )
        self.direction_input.connect('changed', self.on_direction_input_changed)

        hbox = gtk.HBox()
        hbox.pack_start(gtk.Label(_('Trace Links')+':'), False)
        hbox.add(self.direction_input)
        self.vbox.pack_start(hbox, False)

        self.listview = SingleClickTreeView(gtk.ListStore(int, str))
        self.listview.set_reorderable(True)
        for i, label in enumerate((_('#'), _('Page'))):
            column = gtk.TreeViewColumn(label, gtk.CellRendererText(), text=i)
            column.set_sort_column_id(i)
            self.listview.append_column(column)
        # TODO: self.listview.connect('row-activated', self.on_row_activated())

        self.vbox.add(ScrolledWindow(self.listview))
        self.populate_listview()
项目:chirp_fork    作者:mach327    | 项目源码 | 文件源码
def _build_ui(self):
        self._display = gtk.Table(20, 2)

        self._store = gtk.TreeStore(gobject.TYPE_STRING, gobject.TYPE_PYOBJECT)
        self._tree = gtk.TreeView(self._store)

        rend = gtk.CellRendererText()
        tvc = gtk.TreeViewColumn('Element', rend, text=0)
        self._tree.append_column(tvc)
        self._tree.connect('button_press_event', self._tree_click)
        self._tree.set_size_request(200, -1)

        self.root = gtk.HBox(False, 3)
        sw = gtk.ScrolledWindow()
        sw.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
        sw.add(self._tree)
        sw.show()
        self.root.pack_start(sw, 0, 0, 0)
        sw = gtk.ScrolledWindow()
        sw.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
        sw.add_with_viewport(self._display)
        sw.show()
        self.root.pack_start(sw, 1, 1, 1)
        self._tree.show()
        self._display.show()
        self.root.show()
项目:chirp_fork    作者:mach327    | 项目源码 | 文件源码
def _make_view(self):
        colnum = -1

        for typ, cap in self.columns:
            colnum += 1
            if colnum == 0:
                continue  # Key column

            if typ in [gobject.TYPE_STRING, gobject.TYPE_INT,
                       gobject.TYPE_FLOAT]:
                rend = gtk.CellRendererText()
                rend.set_property("ellipsize", pango.ELLIPSIZE_END)
                column = gtk.TreeViewColumn(cap, rend, text=colnum)
            elif typ in [gobject.TYPE_BOOLEAN]:
                rend = gtk.CellRendererToggle()
                rend.connect("toggled", self._toggle, colnum)
                column = gtk.TreeViewColumn(cap, rend, active=colnum)
            else:
                raise Exception("Unsupported type %s" % typ)

            column.set_sort_column_id(colnum)
            self.__view.append_column(column)

        self.__view.connect("button_press_event", self._mouse)
项目:chirp_fork    作者:mach327    | 项目源码 | 文件源码
def make_view(self, columns):
        self._view = gtk.TreeView(self._store)

        for _type, _col in columns:
            if _col.startswith("__"):
                continue

            index = columns.index((_type, _col))
            if _type == gobject.TYPE_STRING or \
                    _type == gobject.TYPE_INT or \
                    _type == gobject.TYPE_FLOAT:
                rend = gtk.CellRendererText()
                column = gtk.TreeViewColumn(_col, rend, text=index)
                column.set_resizable(True)
                rend.set_property("ellipsize", pango.ELLIPSIZE_END)
            elif _type == gobject.TYPE_BOOLEAN:
                rend = gtk.CellRendererToggle()
                rend.connect("toggled", self._toggle, index)
                column = gtk.TreeViewColumn(_col, rend, active=index)
            else:
                raise Exception("Unknown column type (%i)" % index)

            column.set_sort_column_id(index)
            self._view.append_column(column)

        self._view.connect("button_press_event", self.mouse_cb)
项目:ns3-rdma    作者:bobzhuyb    | 项目源码 | 文件源码
def __init__(self, visualizer, node_index):
        InformationWindow.__init__(self)
        self.win = gtk.Dialog(parent=visualizer.window,
                              flags=gtk.DIALOG_DESTROY_WITH_PARENT|gtk.DIALOG_NO_SEPARATOR,
                              buttons=(gtk.STOCK_CLOSE, gtk.RESPONSE_CLOSE))
        self.win.set_default_size(gtk.gdk.screen_width()/2, gtk.gdk.screen_height()/2)
        self.win.connect("response", self._response_cb)
        self.win.set_title("OLSR routing table for node %i" % node_index) 
        self.visualizer = visualizer
        self.node_index = node_index

        self.table_model = gtk.ListStore(str, str, str, int)

        treeview = gtk.TreeView(self.table_model)
        treeview.show()
        sw = gtk.ScrolledWindow()
        sw.set_properties(hscrollbar_policy=gtk.POLICY_AUTOMATIC,
                          vscrollbar_policy=gtk.POLICY_AUTOMATIC)
        sw.show()
        sw.add(treeview)
        self.win.vbox.add(sw)

        # Dest.
        column = gtk.TreeViewColumn('Destination', gtk.CellRendererText(),
                                    text=self.COLUMN_DESTINATION)
        treeview.append_column(column)

        # Next hop
        column = gtk.TreeViewColumn('Next hop', gtk.CellRendererText(),
                                    text=self.COLUMN_NEXT_HOP)
        treeview.append_column(column)

        # Interface
        column = gtk.TreeViewColumn('Interface', gtk.CellRendererText(),
                                    text=self.COLUMN_INTERFACE)
        treeview.append_column(column)

        # Num. Hops
        column = gtk.TreeViewColumn('Num. Hops', gtk.CellRendererText(),
                                    text=self.COLUMN_NUM_HOPS)
        treeview.append_column(column)

        self.visualizer.add_information_window(self)
        self.win.show()
项目:ns3-rdma    作者:bobzhuyb    | 项目源码 | 文件源码
def __init__(self, visualizer, node_index):
        InformationWindow.__init__(self)
        self.win = gtk.Dialog(parent=visualizer.window,
                              flags=gtk.DIALOG_DESTROY_WITH_PARENT|gtk.DIALOG_NO_SEPARATOR,
                              buttons=(gtk.STOCK_CLOSE, gtk.RESPONSE_CLOSE))
        self.win.connect("response", self._response_cb)
        self.win.set_title("IPv4 routing table for node %i" % node_index) 
        self.visualizer = visualizer
        self.node_index = node_index

        self.table_model = gtk.ListStore(str, str, str, str, int)

        treeview = gtk.TreeView(self.table_model)
        treeview.show()
        sw = gtk.ScrolledWindow()
        sw.set_properties(hscrollbar_policy=gtk.POLICY_AUTOMATIC,
                          vscrollbar_policy=gtk.POLICY_AUTOMATIC)
        sw.show()
        sw.add(treeview)
        self.win.vbox.add(sw)
        self.win.set_default_size(600, 300)

        # Dest.
        column = gtk.TreeViewColumn('Destination', gtk.CellRendererText(),
                                    text=self.COLUMN_DESTINATION)
        treeview.append_column(column)

        # Next hop
        column = gtk.TreeViewColumn('Next hop', gtk.CellRendererText(),
                                    text=self.COLUMN_NEXT_HOP)
        treeview.append_column(column)

        # Interface
        column = gtk.TreeViewColumn('Interface', gtk.CellRendererText(),
                                    text=self.COLUMN_INTERFACE)
        treeview.append_column(column)

        # Type
        column = gtk.TreeViewColumn('Type', gtk.CellRendererText(),
                                    text=self.COLUMN_TYPE)
        treeview.append_column(column)

        # Prio
        column = gtk.TreeViewColumn('Prio', gtk.CellRendererText(),
                                    text=self.COLUMN_PRIO)
        treeview.append_column(column)

        self.visualizer.add_information_window(self)
        self.win.show()
项目:zim-icontags-plugin    作者:Pl-M    | 项目源码 | 文件源码
def _PageTreeView_init_(self, ui):
        '''
        This is a slightly modified copy of PageTreeView constructor 
        with one additional column for icons.
        '''
        BrowserTreeView.__init__(self)
        self.set_name('zim-pageindex')
        self.ui = ui
        self._cleanup = None # temporary created path that needs to be removed later

        column = gtk.TreeViewColumn('_pages_')
        self.append_column(column)

        # Added Icon column.
        cr0 = gtk.CellRendererPixbuf()
        column.pack_start(cr0, expand = False)
        column.set_attributes(cr0, pixbuf = ICON_COL)

        cr1 = gtk.CellRendererText()
        cr1.set_property('ellipsize', pango.ELLIPSIZE_END)
        column.pack_start(cr1, True)
        column.set_attributes(cr1, text=NAME_COL,
                              style=STYLE_COL, foreground=FGCOLOR_COL, weight=WEIGHT_COL)

        cr2 = self.get_cell_renderer_number_of_items()
        column.pack_start(cr2, False)
        column.set_attributes(cr2, text=N_CHILD_COL, weight=WEIGHT_COL)

        if gtk.gtk_version >= (2, 12) \
           and gtk.pygtk_version >= (2, 12):
            self.set_tooltip_column(TIP_COL)

        self.set_headers_visible(False)

        self.set_enable_search(True)
        self.set_search_column(0)

        self.enable_model_drag_source(
            gtk.gdk.BUTTON1_MASK, (INTERNAL_PAGELIST_TARGET,),
            gtk.gdk.ACTION_LINK | gtk.gdk.ACTION_MOVE )
        self.enable_model_drag_dest(
            (INTERNAL_PAGELIST_TARGET,),
            gtk.gdk.ACTION_MOVE )
项目:barbieri-playground    作者:barbieri    | 项目源码 | 文件源码
def setup_gui_preferences(self):
        self.player_path = gtk.Entry()
        self.player_params = gtk.Entry()

        self.player_ao_model = gtk.ListStore(str)
        self.player_ao = gtk.ComboBox(self.player_ao_model)
        cell = gtk.CellRendererText()
        self.player_ao.pack_start(cell, True)
        self.player_ao.add_attribute(cell, "text", 0)

        for t in ("esd", "gst"):
            self.player_ao_model.append((t,))


        self.player_acodec_model = gtk.ListStore(str)
        self.player_acodec = gtk.ComboBox(self.player_acodec_model)
        cell = gtk.CellRendererText()
        self.player_acodec.pack_start(cell, True)
        self.player_acodec.add_attribute(cell, "text", 0)

        for t in ("ffmpeg", "dspmp3"):
            self.player_acodec_model.append((t,))



        hbox = gtk.HBox(homogeneous=False, spacing=2)
        btn = gtk.Button(stock=gtk.STOCK_OPEN)
        hbox.pack_start(self.player_path, fill=True, expand=True)
        hbox.pack_start(btn, fill=True, expand=False)
        btn.connect("clicked", self._choose_mplayer_path)

        hbox.show_all()

        wids = ("MPlayer",
                ("Path:", hbox),
                ("Parameters:", self.player_params),
                ("Audio Output:", self.player_ao),
                ("Audio Codec:", self.player_acodec),
                )

        self.gui_preferences = wids
    # setup_gui_preferences()
项目:NativeCAM    作者:FernV    | 项目源码 | 文件源码
def create_treeview(self):
        self.treeview = gtk.TreeView(self.treestore)
        self.treeview.set_grid_lines(gtk.TREE_VIEW_GRID_LINES_VERTICAL)
        self.builder.get_object("feat_scrolledwindow").add(self.treeview)

        self.treeview.add_events(gdk.BUTTON_PRESS_MASK)
        self.treeview.connect('button-press-event', self.pop_menu)
        self.treeview.connect('row_activated', self.tv_row_activated)
        self.treeview.connect('key_press_event', self.tv_key_pressed_event)

        # icon and name
        col = gtk.TreeViewColumn(_("Name"))
        cell = gtk.CellRendererPixbuf()
        cell.set_fixed_size(treeview_icon_size, treeview_icon_size)
        self.tv1_icon_cell = cell
        col.pack_start(cell, expand = False)
        col.set_cell_data_func(cell, self.get_col_icon)
        col.set_min_width(int(self.col_width_adj.get_value()))

        self.name_cell = gtk.CellRendererText()
        col.pack_start(self.name_cell, expand = True)
        col.set_cell_data_func(self.name_cell, self.get_col_name)
        col.set_resizable(True)
        self.name_cell.set_property('ellipsize', self.pref.name_ellipsis)
        self.name_cell.set_property('xpad', 2)

        self.treeview.append_column(col)

        # value
        col = gtk.TreeViewColumn(_("Value"))

        cell = CellRendererMx(self.treeview)
        cell.edited = self.edited
        cell.set_preediting(self.get_editinfo)
        cell.set_refresh_fn(self.get_selected_feature)
        col.pack_start(cell, expand = True)
        col.set_cell_data_func(cell, self.get_col_value)
        col.set_min_width(200)
        col.set_resizable(True)
        self.treeview.append_column(col)

        self.treeview.set_tooltip_column(1)
        self.treeview.connect("cursor-changed", self.get_selected_feature)

        self.treeview.set_model(self.master_filter)
项目:NativeCAM    作者:FernV    | 项目源码 | 文件源码
def create_second_treeview(self):
        self.treeview2 = gtk.TreeView()
        self.treeview2.add_events(gdk.BUTTON_PRESS_MASK)
        self.treeview2.connect('button-press-event', self.pop_menu)
        self.treeview2.connect('cursor-changed', self.tv2_selected)
        self.treeview2.connect('row_activated', self.tv_row_activated)
        self.treeview2.set_grid_lines(gtk.TREE_VIEW_GRID_LINES_VERTICAL)
        self.treeview2.set_show_expanders(self.pref.tv2_expandable)
        if self.pref.tv2_expandable :
            self.treeview2.set_level_indentation(-5)
        else :
            self.treeview2.set_level_indentation(12)

        # icon and name
        col = gtk.TreeViewColumn(_("Name"))
        cell = gtk.CellRendererPixbuf()
        cell.set_fixed_size(treeview_icon_size, treeview_icon_size)
        self.tv2_icon_cell = cell

        col.pack_start(cell, expand = False)
        col.set_cell_data_func(cell, self.get_col_icon)

        self.name_cell2 = gtk.CellRendererText()
        self.name_cell2.set_property('xpad', 2)
        self.name_cell2.set_property('ellipsize', self.pref.name_ellipsis)
        col.pack_start(self.name_cell2, expand = True)
        col.set_cell_data_func(self.name_cell2, self.get_col_name)
        col.set_resizable(True)
        col.set_min_width(int(self.col_width_adj.get_value()))
        self.treeview2.append_column(col)

        # value
        col = gtk.TreeViewColumn(_("Value"))
        cell = CellRendererMx(self.treeview2)
        cell.set_property("editable", True)
        cell.edited = self.edited
        cell.set_preediting(self.get_editinfo)
        cell.set_refresh_fn(self.get_selected_feature)

        col.pack_start(cell, expand = False)
        col.set_cell_data_func(cell, self.get_col_value)
        col.set_resizable(True)
        col.set_min_width(200)
        self.treeview2.append_column(col)

        self.treeview2.set_tooltip_column(1)
        self.treeview2.set_model(self.treestore)
        self.treeview2.set_model(self.details_filter)
        self.params_scroll.add(self.treeview2)
        self.treeview2.connect('key-press-event', self.tv_key_pressed_event)
项目:wahcade    作者:sairuk    | 项目源码 | 文件源码
def setup_iconview(self, columns, column_types, container, changed_cb=None, activate_cb=None, text_style='text'):
        """ Create a ready-to-use (list based) iconview widget (GTK+2.6 and baove)
        Parameters:
            columns      : List of column names (should only be two - one for icon & one for description)
            column_types : List of variable types for each column
                           (eg. [gobject.TYPE_STRING, gobject.TYPE_LONG])
            container    : reference to widget that is to contain list,
                           almost always a scrolled window - gtk.ScrolledWindow()
            changed_cb   : the callback function for the "changed" TreeViewSelection signal
            activate_cb  : the callback function for the "changed" TreeViewSelection signal
            text_style   : 'text' for normail plain text,
                           'markup' for pango marked-up text
        Returns:
            Reference to IconView and ListStore widgets

        e.g. to create a four column (first two displayed, rest hidden) icon view...
            self.tvwProjects, self.lsProjects, self.tvwsProjects = self.setup_treeview(
                ['Picture', 'Desc'],
                [gtk.gdk.Pixbuf, gobject.TYPE_STRING, gobject.TYPE_LONG, gobject.TYPE_STRING],
                self.scwPictures,
                self.on_tvwsPictures_changed,
                None
                'text')
        """
        #create the ListStore and IconView objects
        ls = gtk.ListStore(*column_types)
        ivw = gtk.IconView(ls)
        #set columns
        for i in range(len(columns)):
            if column_types[i] != gtk.gdk.Pixbuf:
                #create text renderer
                tvwRendererText = gtk.CellRendererText()
                tvwRendererText.set_property('yalign', 0.0)
                if text_style == 'markup':
                    #markup text rendering
                    column = gtk.TreeViewColumn(columns[i], tvwRendererText, markup=i)
                    ivw.set_markup_column(i)
                else:
                    #default text rendering
                    column = gtk.TreeViewColumn(columns[i], tvwRendererText, text=i)
                    ivw.set_text_column(i)
            else:
                #create pixbuf renderer
                tvwRendererPixbuf = gtk.CellRendererPixbuf()
                column = gtk.TreeViewColumn(columns[i], tvwRendererPixbuf, pixbuf=i)
                ivw.set_pixbuf_column(i)
        #display it (add iconview to given widget)
        container.add(ivw)
        ivw.show()
        #connect callbacks
        if changed_cb:
            ivw.connect('selection_changed', changed_cb)
        if activate_cb:
            ivw.connect('item_activated', activate_cb)
        #done
        return ivw, ls
项目:chirp_fork    作者:mach327    | 项目源码 | 文件源码
def make_view(self):
        editable = [self.col_nloc, self.col_name, self.col_comm]

        self.__store = gtk.ListStore(gobject.TYPE_BOOLEAN,  # Import
                                     gobject.TYPE_INT,      # Source loc
                                     gobject.TYPE_INT,      # Destination loc
                                     gobject.TYPE_STRING,   # Name
                                     gobject.TYPE_STRING,   # Frequency
                                     gobject.TYPE_STRING,   # Comment
                                     gobject.TYPE_BOOLEAN,
                                     gobject.TYPE_STRING)
        self.__view = gtk.TreeView(self.__store)
        self.__view.show()

        tips = gtk.Tooltips()

        for k in self.caps.keys():
            t = self.types[k]

            if t == gobject.TYPE_BOOLEAN:
                rend = gtk.CellRendererToggle()
                rend.connect("toggled", self._toggle, k)
                column = gtk.TreeViewColumn(self.caps[k], rend,
                                            active=k,
                                            sensitive=self.col_okay,
                                            activatable=self.col_okay)
            else:
                rend = gtk.CellRendererText()
                if k in editable:
                    rend.set_property("editable", True)
                    rend.connect("edited", self._edited, k)
                column = gtk.TreeViewColumn(self.caps[k], rend,
                                            text=k,
                                            sensitive=self.col_okay)

            if k == self.col_nloc:
                column.set_cell_data_func(rend, self._render, k)

            if k in self.tips.keys():
                LOG.debug("Doing %s" % k)
                lab = gtk.Label(self.caps[k])
                column.set_widget(lab)
                tips.set_tip(lab, self.tips[k])
                lab.show()
            column.set_sort_column_id(k)
            self.__view.append_column(column)

        self.__view.set_tooltip_column(self.col_tmsg)

        sw = gtk.ScrolledWindow()
        sw.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
        sw.add(self.__view)
        sw.show()

        return sw