Gtk.ListStore值错误

问题描述 投票:1回答:1

我正在尝试构建一个动态的组合框。因此,当更新特定文本文件时,组合框将跟随。但是,我在构建列表视图时遇到问题。我收到以下错误。 ValueError:行序列长度错误。以下是我正在使用的代码。我的列表只有一列。我的列表是['str1','str2','str3','... etc']。有人可以帮助我理解我所缺少的东西。谢谢!

def newlist(self, widget): 
    LRU_list = gtk.ListStore(str)
    for i in range(len(LRU)):
        LRU_list.append(LRU[i])<---- Value Error


    for row in LRU_list:
        print(row[:])
python-3.x gtk
1个回答
0
投票

你需要使用一个列表:

def newlist(self, widget): 
    LRU_list = gtk.ListStore(str)
    for i in range(len(LRU)):
        LRU_list.append([LRU[i]])<---- Value Error


    for row in LRU_list:
        print(row[:])
© www.soinside.com 2019 - 2024. All rights reserved.