gtkinfo.py 文件源码

python
阅读 19 收藏 0 点赞 0 评论 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
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号