checkboxCtrlMixin显示选定的值

时间:2013-03-30 18:48:09

标签: python checkbox wxpython checkboxlist listctrl

我有一个checkboxCtrlmixin,我想要的是显示checkboxCtrlmixin的选定值。 checkboxctrlmixin中是否有任何特殊功能显示选择了哪些值?

我的代码:

class TestListCtrl(wx.ListCtrl, listmix.CheckListCtrlMixin, listmix.ListCtrlAutoWidthMixin):
def __init__(self,*args,**kwargs):
wx.ListCtrl.__init__(self,*args,**kwargs)
listmix.CheckListCtrlMixin.__init__(self)
listmix.ListCtrlAutoWidthMixin.__init__(self)
self.setResizeColumn(3)


class rulesFrame(wx.Frame):##open about frame
""""""

#----------------------------------------------------------------------
def __init__(self):
    """Constructor"""
    wx.Frame.__init__(self, None, wx.ID_ANY, "Choose Rules")
panel = wx.Panel(self)##create panel
prules=subprocess.check_output("perl ruleFinder.pl dataset24819.arff rules_test1Fold0w4_sample00ll1.dat", shell=True)
prules = prules.split()
ruleiden = [x for x in prules if x!='159']
ruleiden = list(set(ruleiden))
sortrule = [int(x) for x in ruleiden]
sortrule.sort()
with open('rules_test1Fold0w4_sample00ll1.dat') as fileobj:
    lines = list(fileobj)
actualrules=''
##sortrule=[item+1 for item in sortrule]
##print sortrule
for index in sortrule:
    actualrules += lines[index]

actualrules = actualrules.split('\n')

wx.Button(panel,label="Show Selected Rules",pos=(170,520),size=(200,25))

self.list = TestListCtrl(panel,size=(1000,500), style = wx.LC_REPORT)

self.list.InsertColumn(0,'Rules')
self.list.SetColumnWidth(0,500)


for i in actualrules:

    self.list.InsertStringItem(sys.maxint,i)

1 个答案:

答案 0 :(得分:0)

要确定是否选中了某个项目,请使用listctrl的以下方法

IsChecked(self, index)

对于给定的索引将返回True / False。