Como hacer grids
Publicado por tronxx (16 intervenciones) el 03/05/2007 17:39:33
Hola amigos, estoy tratando de hacer unos programas mas o menos decentes, entonces quiero instalarle un grid a mi aplicacion, pero no se como hacerle para que se visualicen las lineas de division:
self.liststore = gtk.ListStore(str, str, str)
self.treeview = gtk.TreeView(self.liststore)
# create the TreeViewColumns to display the data
self.tvcolumn = gtk.TreeViewColumn('Codigo')
self.tvcolumn1 = gtk.TreeViewColumn('Nombre')
# add a row with text and a stock item - color strings for
# the background
self.mydb = MySQLdb.connect(host="localhost", user="user", passwd="pwd",db="inven")
vendedores_z = []
cursor = self.mydb.cursor()
sql_z = "select codigo, nombre from vendedor order by codigo"
cursor.execute(sql_z)
result = cursor.fetchall()
for record in result:
self.liststore.append([ record[0], "", record[1] ])
# add columns to treeview
self.treeview.append_column(self.tvcolumn)
self.treeview.append_column(self.tvcolumn1)
# create a CellRenderers to render the data
self.cell = gtk.CellRendererText()
self.cell1 = gtk.CellRendererText()
# add the cells to the columns - 2 in the first
self.tvcolumn.pack_start(self.cell, False)
self.tvcolumn1.pack_start(self.cell1, True)
# set the cell attributes to the appropriate liststore column
self.tvcolumn.set_attributes(self.cell, text=0)
self.tvcolumn1.set_attributes(self.cell1, text=2,
cell_background_set=3)
# Allow sorting on the column
self.tvcolumn.set_sort_column_id(0)
self.treeview.set_reorderable(True)
vbox.pack_start(self.treeview, gtk.FALSE, gtk.FALSE, 0)
vbox.show()
este es mi codigo, pero no se como ponerle las lineas. Si alguien sabe
self.liststore = gtk.ListStore(str, str, str)
self.treeview = gtk.TreeView(self.liststore)
# create the TreeViewColumns to display the data
self.tvcolumn = gtk.TreeViewColumn('Codigo')
self.tvcolumn1 = gtk.TreeViewColumn('Nombre')
# add a row with text and a stock item - color strings for
# the background
self.mydb = MySQLdb.connect(host="localhost", user="user", passwd="pwd",db="inven")
vendedores_z = []
cursor = self.mydb.cursor()
sql_z = "select codigo, nombre from vendedor order by codigo"
cursor.execute(sql_z)
result = cursor.fetchall()
for record in result:
self.liststore.append([ record[0], "", record[1] ])
# add columns to treeview
self.treeview.append_column(self.tvcolumn)
self.treeview.append_column(self.tvcolumn1)
# create a CellRenderers to render the data
self.cell = gtk.CellRendererText()
self.cell1 = gtk.CellRendererText()
# add the cells to the columns - 2 in the first
self.tvcolumn.pack_start(self.cell, False)
self.tvcolumn1.pack_start(self.cell1, True)
# set the cell attributes to the appropriate liststore column
self.tvcolumn.set_attributes(self.cell, text=0)
self.tvcolumn1.set_attributes(self.cell1, text=2,
cell_background_set=3)
# Allow sorting on the column
self.tvcolumn.set_sort_column_id(0)
self.treeview.set_reorderable(True)
vbox.pack_start(self.treeview, gtk.FALSE, gtk.FALSE, 0)
vbox.show()
este es mi codigo, pero no se como ponerle las lineas. Si alguien sabe
Valora esta pregunta


0