Gtk.ListStore(*datatypes) 字符串错误 [英] Gtk.ListStore(*datatypes) string error

查看:56
本文介绍了Gtk.ListStore(*datatypes) 字符串错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

self.ip_liststore = Gtk.ListStore(*datatypes)

哪里

datatypes = [str,str,str]

我也试过

datatypes = ['gchararray','gchararray']

翻译人员回复

Traceback (most recent call last):
  File "./gtktutorial.py", line 128, in <module>
    main()
File "./gtktutorial.py", line 119, in main
[str,str,str,str,str,str,str])
File "./gtktutorial.py", line 37, in __init__
self.ip_liststore = Gtk.ListStore(*datatypes)
File "/usr/lib/python2.7/dist-packages/gi/overrides/Gtk.py", line 943, in __init__
self.set_column_types(column_types)
TypeError: Item 0: Must be gobject.GType, not str

列表解包后会发生什么?内容是否转换为字符串?有什么我不知道的关于开箱的事情吗?

What happens after the list is unpacked? Are the contents converted to strings? Is there something I don't know about unpacking?

推荐答案

我相信这只是有点混乱,我记得我找错了时间.

I believe there is just a little confusion, and I remember I had a wrong time searching for it.

这就是我所做的:

self.searchCols     = ["Object", "Index", "Date", "Program", "Person", "Mode"]
sequence            = [str] * len(self.searchCols)
self.resultStore    = gtk.ListStore( * sequence )
self.resView        = gtk.TreeView(self.resultStore)
self.resView.cell   = [None] * len(self.searchCols)
rvcolumn            = [None] * len(self.searchCols)
for colnum, col in enumerate ( self.searchCols ) :
    self.resView.cell[colnum] = gtk.CellRendererText()
    rvcolumn[colnum] = gtk.TreeViewColumn(col, self.resView.cell[colnum])
    rvcolumn[colnum].add_attribute(self.resView.cell[colnum], 'text', colnum)
    self.resView.append_column(rvcolumn[colnum])

这篇关于Gtk.ListStore(*datatypes) 字符串错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆