How to make GtkListStore store object attribute in a row?

后端 未结 1 1256
被撕碎了的回忆
被撕碎了的回忆 2021-01-15 00:24

I\'w trying to keep at ListStore non-text objects using snippet I found. These are the objects:

class Series(gobject.GObject, object):
 def __init__(self, ti         


        
相关标签:
1条回答
  • 2021-01-15 01:24

    Two mistakes in the second-to-last block.

    1. GtkWarning: gtk_tree_view_column_cell_layout_set_cell_data_func: assertion `info != NULL'

      In English, this means that the cell renderer is not in the column's list of cell renderers. You need to add the cell renderer to the column first before calling set_cell_data_func.

    2. Warning: unable to set property `text' of type `gchararray' from value of `typedata+TrayIcon+Series'

      This is because the add_attribute line causes GTK+ to try setting the cell text to a Series object, which of course fails. Just remove that line; the cell data func already takes care of setting the cell text.

    In code:

    col = gtk.TreeViewColumn(_("Series title"))
    cell = gtk.CellRendererText()
    col.pack_start(cell)
    col.set_cell_data_func(cell, get_series_title)
    
    0 讨论(0)
提交回复
热议问题