515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
|
def config_treeview(opt, columns=["Icon", "Command"]):
lno = len(columns)
if lno == 2:
liststore = gtk.ListStore(str, str, str)
else:
liststore = gtk.ListStore(*[str for i in range(0, lno)])
w = gtk.TreeView(liststore)
# two text columns and renderers
for i in range(0, lno):
c = gtk.TreeViewColumn(columns[i])
c.set_resizable(True)
c.set_sizing(gtk.TREE_VIEW_COLUMN_FIXED)
c.set_fixed_width(int(430/lno))
r = gtk.CellRendererText()
c.pack_end(r, expand=True)
r.set_property("editable", True)
r.connect("edited", uikit.liststore_edit, (liststore, i))
c.add_attribute(r, "text", i)
#c.add_attribute(r, "editable", 2)
w.append_column(c)
# add pixbuf holder to last column
if lno < 3:
r = gtk.CellRendererPixbuf()
c.pack_start(r, expand=False)
c.add_attribute(r, "stock_id", 2)
w.set_property("width_request", 450)
w.set_property("height_request", 115)
return w, liststore
# Generic Gtk callback to update ListStore when entries get edited.
# where user_data = (liststore, column #id)
@staticmethod
def liststore_edit(cell, row, text, user_data):
#log.EDIT(cell, row, text, user_data)
row = int(row)
|
>
>
>
|
|
|
|
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
|
def config_treeview(opt, columns=["Icon", "Command"]):
lno = len(columns)
if lno == 2:
liststore = gtk.ListStore(str, str, str)
else:
liststore = gtk.ListStore(*[str for i in range(0, lno)])
w = gtk.TreeView(liststore)
sw = gtk.ScrolledWindow()
sw.set_border_width(5)
sw.add(w)
# two text columns and renderers
for i in range(0, lno):
c = gtk.TreeViewColumn(columns[i])
c.set_resizable(True)
c.set_sizing(gtk.TREE_VIEW_COLUMN_FIXED)
c.set_fixed_width(int(550/lno))
r = gtk.CellRendererText()
c.pack_end(r, expand=True)
r.set_property("editable", True)
r.connect("edited", uikit.liststore_edit, (liststore, i))
c.add_attribute(r, "text", i)
#c.add_attribute(r, "editable", 2)
w.append_column(c)
# add pixbuf holder to last column
if lno < 3:
r = gtk.CellRendererPixbuf()
c.pack_start(r, expand=False)
c.add_attribute(r, "stock_id", 2)
w.set_property("width_request", 470)
w.set_property("height_request", 115)
return sw, liststore
# Generic Gtk callback to update ListStore when entries get edited.
# where user_data = (liststore, column #id)
@staticmethod
def liststore_edit(cell, row, text, user_data):
#log.EDIT(cell, row, text, user_data)
row = int(row)
|