using multiple column in checklistbox

1,077 views
Skip to first unread message

youngrap

unread,
Sep 15, 2009, 12:41:09 AM9/15/09
to wxPython-users
hi~

Please be unable to understand English well

I want to do it using multiple column in checklistbox

Please comment.

thanx~

Robin Dunn

unread,
Sep 15, 2009, 8:36:28 PM9/15/09
to wxpytho...@googlegroups.com
On 9/14/09 9:41 PM, youngrap wrote:
>
> hi~
>
> Please be unable to understand English well
>
> I want to do it using multiple column in checklistbox
>

wx.CheckListBox is just a plain wx.ListBox with some extra
functionality, so it can't handle multiple columns. Instead you can get
approximately the same thing by using a wx.ListCtrl in report mode, and
use images to indicate checked or unchecked status. There is a mixin
class in the library that makes this fairly easy, see the
CheckListCtrlMixin sample in the demo.

--
Robin Dunn
Software Craftsman
http://wxPython.org

Reckoner

unread,
Oct 19, 2009, 8:35:04 PM10/19/09
to wxPython-users
Hi,

could you please provide an example? I am trying to create a two
column CheckListBox so that each row has two items which can be
checked or not.

Little help? I am new to wxpython.

Thanks in advance.

On Sep 15, 5:36 pm, Robin Dunn <ro...@alldunn.com> wrote:
> On 9/14/09 9:41 PM, youngrap wrote:
>
>
>
> > hi~
>
> > Please be unable to understand English well
>
> > I want to do it using multiplecolumninchecklistbox
>
> wx.CheckListBoxis just a plain wx.ListBox with some extra

Mike Driscoll

unread,
Oct 19, 2009, 10:22:22 PM10/19/09
to wxpytho...@googlegroups.com
Hi,

On Mon, Oct 19, 2009 at 7:35 PM, Reckoner <reck...@gmail.com> wrote:

Hi,

could you please provide an example? I am trying to create a two
column CheckListBox so that each row has two items which can be
checked or not.

Little help? I am new to wxpython.

Thanks in advance.


I think it would be easiest just to use Andrea's UltimateListCtrl:

http://xoomer.virgilio.it/infinity77/main/UltimateListCtrl.html

It's pure python and can be hacked like crazy. Besides, it appears to support widgets within columns. Check it out! There's even a demo!
 
-----------------
Mike Driscoll

Blog:   http://blog.pythonlibrary.org

michael h

unread,
Oct 19, 2009, 10:41:39 PM10/19/09
to wxPython-users
andrea's hypertreelist and ultimatelistctrl support adding any kind of
non-toplevel widget to the tree/rows (images, checkboxes, toggle
buttons to name a few ideas for indicating true/false)

If i misunderstand and you don't actually need two checkboxes in the
same listctrl, i'd check out objectlistview at http://objectlistview.sourceforge.net/python/
it's pretty handy...

the wxpython demos are a really good place to start...I use it fairly
often for ideas even still...

- michael

Reckoner

unread,
Oct 26, 2009, 12:31:49 PM10/26/09
to wxPython-users
Below is a rough example using UltimateListCtrl that puts a checkbox
next to every item with the associated callback.

Suggestions welcome.

===

import wx
import sys
import sys
import UltimateListCtrl as ULC


packages = [('jessica alba', 'pomona', '1981'), ('sigourney weaver',
'new york', '1949'),
('angelina jolie', 'los angeles', '1975'), ('natalie portman',
'jerusalem', '1981'),
('rachel weiss', 'london', '1971'), ('scarlett johansson', 'new
york', '1984' ),
('rachel weiss', 'london', '1971'), ('scarlett johansson', 'new
york', '1984' ),
('rachel weiss', 'london', '1971'), ('scarlett johansson', 'new
york', '1984' ),
('rachel weiss', 'london', '1971'), ('scarlett johansson', 'new
york', '1984' )]

class Actresses(wx.Frame):
def __init__(self, parent, id, title):
wx.Frame.__init__(self, parent, id, title, size=(400, 130))

hbox = wx.BoxSizer(wx.HORIZONTAL)
panel = wx.Panel(self, -1)

self.list = ULC.UltimateListCtrl(panel, -1,
style=wx.LC_REPORT)
self.list.InsertColumn(0, 'name', width=140)
self.list.InsertColumn(1, 'place', width=130)
self.list.InsertColumn(2, 'year', wx.LIST_FORMAT_RIGHT, 90)

for i in packages:
index = self.list.InsertStringItem(sys.maxint, i[0])
self.list.SetStringItem(index, 1, i[1])
self.list.SetStringItem(index, 2, i[2])

self.chk_dict = dict()
for j in range(3):
for i in range(len(packages)):
item = self.list.GetItem(i,j)
chk = wx.CheckBox(self.list,id=-1)
item.SetWindow(chk)
self.chk_dict[chk.GetId()]= item
self.list.SetItem(item)

hbox.Add(self.list, 1, wx.EXPAND)
self.list.Select(11)
self.list.EnsureVisible(11)
self.Bind(wx.EVT_CHECKBOX,self.OnCheck)
panel.SetSizer(hbox)
self.Show(True)

def OnCheck(self,event):
x=self.chk_dict[event.GetId()].GetText()
pass

app = wx.App()
Actresses(None, -1, 'actresses')
app.MainLoop()


On Oct 19, 7:41 pm, michael h <michaelke...@gmail.com> wrote:
> andrea's hypertreelist and ultimatelistctrl support adding any kind of
> non-toplevel widget to the tree/rows (images, checkboxes, toggle
> buttons to name a few ideas for indicating true/false)
>
> If i misunderstand and you don't actually need two checkboxes in the
> same listctrl, i'd check out objectlistview athttp://objectlistview.sourceforge.net/python/
> it's pretty handy...
>
> the wxpython demos are a really good place to start...I use it fairly
> often for ideas even still...
>
> - michael
>
Reply all
Reply to author
Forward
0 new messages