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

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

项目: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()
项目: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()
项目:pantea    作者:nim4    | 项目源码 | 文件源码
def update_view(self):
        global con
        iv = self.builder.get_object("iconview1")
        model = gtk.ListStore(str, gtk.gdk.Pixbuf)
        with con:
            cur = con.cursor()
            cur.execute("select * from dump")
            rows = cur.fetchall()
        for (cookie, angent, photo, info, url) in rows:
            try:
                pixbuf = gtk.gdk.pixbuf_new_from_file(photo)
                model.append([info, pixbuf])
            except:
                pass
        iv.set_model(model)
        iv.set_text_column(0)
        iv.set_pixbuf_column(1)
        iv.set_orientation(gtk.ORIENTATION_VERTICAL)
        iv.set_selection_mode(gtk.SELECTION_SINGLE)
        iv.set_columns(1)
        iv.set_item_width(-1)
        iv.set_size_request(72, -1)
        self.builder.get_object("window1").show_all()
        return True
项目: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 __init__(self, columns):
        gtk.HBox.__init__(self, True, 0)

        self.columns = columns

        types = tuple([x for x, y in columns])

        self.__store = gtk.ListStore(*types)
        self.__view = gtk.TreeView(self.__store)

        self.pack_start(self.__view, 1, 1, 1)

        self.__toggle_connected = False

        self._make_view()
        self.__view.show()
项目: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
项目: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)
项目:mgr.p2p.proxy    作者:tomusdrw    | 项目源码 | 文件源码
def createListStore(self, data):
        lstore = gtk.ListStore(gobject.TYPE_STRING)
        for item in data:
            iter = lstore.append()
            lstore.set(iter, 0, item)
        return lstore
项目: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 create_add_dialog(self):
        self.icon_store = gtk.ListStore(gdk.Pixbuf, str, str, str, int, str)
        self.add_iconview.set_model(self.icon_store)
        self.add_iconview.set_pixbuf_column(0)
        self.add_iconview.set_text_column(2)

        if self.catalog.tag == 'xml' :
            self.catalog_src = self.catalog
        else :
            for _ptr in range(len(self.catalog)) :
                _p = self.catalog[_ptr]
                if _p.tag.lower() in ["menu", "group"] :
                    self.catalog_src = _p
                    break
        self.update_catalog()
项目:griffith    作者:Strit    | 项目源码 | 文件源码
def loan_movie(self):
    people = self.db.session.query(db.Person.name).order_by(db.Person.name.asc()).all()
    model = gtk.ListStore(str)
    if len(people)>0:
        for person in people:
            model.append([person.name])
        self.widgets['movie']['loan_to'].set_model(model)
        self.widgets['movie']['loan_to'].set_text_column(0)
        self.widgets['movie']['loan_to'].set_active(0)
        self.widgets['w_loan_to'].show()
    else:
        gutils.info(_("No person is defined yet."), self.widgets['window'])
项目: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
项目:wahcade    作者:sairuk    | 项目源码 | 文件源码
def setup_combo_box_entry(self, cboe, initial_text=None):
        """initialise a given ComboBoxEntry"""
        #create items list
        ls = gtk.ListStore(gobject.TYPE_STRING)
        cboe.set_model(ls)
        cboe.set_text_column(0)
        #populate with text?
        if initial_text:
            ls.append((initial_text, ))
            cboe.child.set_text(initial_text)
项目: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()
项目:File-Explorer    作者:aj95    | 项目源码 | 文件源码
def create_store(self):
        store = gtk.ListStore(str, gtk.gdk.Pixbuf, bool)
        store.set_sort_column_id(COL_PATH, gtk.SORT_ASCENDING)
        return store
项目:Automation-Framework-for-devices    作者:tok-gogogo    | 项目源码 | 文件源码
def __init__(self):
        self.model = gtk.ListStore(gobject.TYPE_STRING)
        self.nameEntry = gtk.Entry()
        self.buttons = []
项目: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()
项目: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()
项目: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