473,322 Members | 1,379 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,322 software developers and data experts.

Item Checking not possible with UltimateListCtrl in ULC_VIRTUAL mode

15
Following is the system and software info

Platforms: Windows XP and OSX Lion
Activestate Python 2.7.2
wxPython2.9-osx-cocoa-py2.7 (for OSX)
wxPython2.9-win32-py27 (for Windows XP)


I am trying to create a UltimateListCtrl using ULC_VIRTUAL and ULC_REPORT mode. I would like to know how can I put a checkbox beside the first column of every row and catch the event when a user checks the box. I was able to do the same using UltimateListCtrl without VIRTUAL mode. But, with the ULC_VIRTUAL flag ON, I don't know how to proceed. Following is the code I created, but this still doesn't allow me to check the boxes associated with the first column. Please help.

Expand|Select|Wrap|Line Numbers
  1. import wx
  2. import images
  3. import random
  4. import os, sys
  5. from wx.lib.agw import ultimatelistctrl as ULC
  6.  
  7. class TestUltimateListCtrl(ULC.UltimateListCtrl):
  8.     def __init__(self, parent, log):
  9.  
  10.         ULC.UltimateListCtrl.__init__(self, parent, -1, agwStyle=ULC.ULC_AUTO_CHECK_CHILD|ULC.ULC_VIRTUAL|ULC.ULC_REPORT|ULC.ULC_SINGLE_SEL|ULC.ULC_VRULES|ULC.ULC_HRULES)
  11.     self.SetItemCount(1000)
  12.     self.table_fields=['First','Second','Third']
  13.     field_index=0
  14.         for field in self.table_fields:
  15.         info = ULC.UltimateListItem()
  16.         info._mask = wx.LIST_MASK_TEXT | wx.LIST_MASK_IMAGE | wx.LIST_MASK_FORMAT | ULC.ULC_MASK_CHECK
  17.         info._image = []
  18.         info._format = wx.LIST_FORMAT_CENTER
  19.         info._kind = 1        
  20.         info._text = field
  21.         info._font= wx.Font(13, wx.ROMAN, wx.NORMAL, wx.BOLD)
  22.         self.InsertColumnInfo(field_index, info)
  23.         self.SetColumnWidth(field_index,175)
  24.         field_index += 1
  25.  
  26.     def getColumnText(self, index, col):
  27.         item = self.GetItem(index, col)
  28.         return item.GetText()
  29.  
  30.     def OnGetItemText(self, item, col):
  31.         return "Item %d, Column %d" % (item,col)
  32.  
  33.     def OnGetItemColumnImage(self, item, col):
  34.         return []
  35.  
  36.     def OnGetItemImage(self, item):
  37.         return []
  38.  
  39.     def OnGetItemAttr(self, item):
  40.         return None
  41.  
  42.     def OnGetItemTextColour(self, item, col):
  43.         return None
  44.  
  45.     #def OnGetItemColumnCheck(self, item, col):
  46.     #return True
  47.  
  48.     #def OnGetItemCheck(self, item):
  49.     #item=self.GetItem(item)
  50.     #return item.IsChecked()
  51.  
  52.     def OnGetItemToolTip(self, item, col):
  53.         return None
  54.  
  55.     def OnGetItemKind(self, item):
  56.         return 1
  57.  
  58.     def OnGetItemColumnKind(self, item, col):
  59.         if col==0:
  60.             return self.OnGetItemKind(item)
  61.         return 0
  62.  
  63. class TestFrame(wx.Frame):
  64.     def __init__(self, parent, log):
  65.         wx.Frame.__init__(self, parent, -1, "UltimateListCtrl in wx.LC_VIRTUAL mode", size=(700, 600))
  66.         panel = wx.Panel(self, -1)
  67.         sizer = wx.BoxSizer(wx.VERTICAL)
  68.         listCtrl = TestUltimateListCtrl(panel, log)
  69.         sizer.Add(listCtrl, 1, wx.EXPAND)
  70.         panel.SetSizer(sizer)
  71.         sizer.Layout()
  72.         self.CenterOnScreen()
  73.         self.Show()
  74.  
  75. if __name__ == '__main__':
  76.     import sys
  77.     app = wx.PySimpleApp()
  78.     frame = TestFrame(None, sys.stdout)
  79.     frame.Show(True)
  80.     app.MainLoop()
  81.  
Btw, following is the code I used to create the same thing without the VIRTUAL mode. And in this case, I can check the boxes beside the first column data in every row. But, I will be working with tens of thousands of items and I cannot rely on loading the items like below because it is very slow. Hence, I want to use the Virtual List, but I don't know how to get the same functionality in it.

Expand|Select|Wrap|Line Numbers
  1. import wx
  2. import images
  3. import random
  4. import os, sys
  5. from wx.lib.agw import ultimatelistctrl as ULC
  6.  
  7. class TestUltimateListCtrl(ULC.UltimateListCtrl):
  8.     def __init__(self, parent, log):
  9.  
  10.         ULC.UltimateListCtrl.__init__(self, parent, -1, agwStyle=ULC.ULC_REPORT|ULC.ULC_SINGLE_SEL|ULC.ULC_VRULES|ULC.ULC_HRULES)
  11.  
  12.     self.table_fields=['First','Second','Third']
  13.     field_index=0
  14.         for field in self.table_fields:
  15.         info = ULC.UltimateListItem()
  16.         info._mask = wx.LIST_MASK_TEXT | wx.LIST_MASK_IMAGE | wx.LIST_MASK_FORMAT | ULC.ULC_MASK_CHECK
  17.         info._image = []
  18.         info._format = wx.LIST_FORMAT_CENTER
  19.         info._kind = 1        
  20.         info._text = field
  21.         info._font= wx.Font(13, wx.ROMAN, wx.NORMAL, wx.BOLD)
  22.         self.InsertColumnInfo(field_index, info)
  23.         self.SetColumnWidth(field_index,175)
  24.         field_index += 1
  25.  
  26.     for record_index in range(0,1000):
  27.         for field in self.table_fields:
  28.         if self.table_fields.index(field)==0:
  29.             self.InsertStringItem(record_index, 'Item %d, Column %d' % (record_index,self.table_fields.index(field)),it_kind=1)
  30.         else:
  31.             self.SetStringItem(record_index, self.table_fields.index(field), 'Item %d, Column %d' % (record_index,self.table_fields.index(field)))
  32.  
  33. class TestFrame(wx.Frame):
  34.     def __init__(self, parent, log):
  35.         wx.Frame.__init__(self, parent, -1, "UltimateListCtrl in wx.LC_VIRTUAL mode", size=(700, 600))
  36.         panel = wx.Panel(self, -1)
  37.         sizer = wx.BoxSizer(wx.VERTICAL)
  38.         listCtrl = TestUltimateListCtrl(panel, log)
  39.         sizer.Add(listCtrl, 1, wx.EXPAND)
  40.         panel.SetSizer(sizer)
  41.         sizer.Layout()
  42.         self.CenterOnScreen()
  43.         self.Show()
  44.  
  45. if __name__ == '__main__':
  46.     import sys
  47.     app = wx.PySimpleApp()
  48.     frame = TestFrame(None, sys.stdout)
  49.     frame.Show(True)
  50.     app.MainLoop()
Dec 22 '11 #1
0 1268

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: John Fouhy | last post by:
Since Python has no explcit ends to blocks, emacs doesn't always know the right indentation level to use. And <del> doesn't seem to be very consistent (it always seems to go back 8 characters,...
8
by: Gilles T. | last post by:
How I can get element ID in the edit mode of datagrid control? If I not in the edit mode, there are no problem. <asp:TemplateColumn ItemStyle-CssClass="grid_column_width_3"...
40
by: Ron Adam | last post by:
After considering several alternatives and trying out a few ideas with a modified list object Bengt Richter posted, (Thank You), I think I've found a way to make slice operation (especially far end...
6
by: allyn44 | last post by:
HI--what I am trying to do is 2 things: 1. Open a form in either data entry mode or edit mode depending on what task the user is performing 2. Cancel events tied to fields on the form if I am in...
6
by: Baskar RajaSekharan | last post by:
In C-sharp, I wnat to know whether the Component is compiled in Debug Mode or Run Mode through Code. How is it possible? Is there any way to Access the Config file and check? Please let me know...
3
by: louise raisbeck | last post by:
Hi, I have been on this for hours and just cannot work it out. I have a datagrid. I set the edititem index to a row to edit, that works. However if i want to put a value into this textbox it wont...
2
by: Richard Lewis Haggard | last post by:
How does one specify the Escape key as an accelerator? My client has specified that the Escape key be used as an accelerator for a particular menu item. In VS05's designer mode, this particular...
1
by: ledneh | last post by:
I've been working on concurrency checking for an application I'm building, and a minor part of it has me slightly stumped. I've got a DetailsView that populates from an ObjectDataSource, using...
21
by: bilgekhan | last post by:
After doing a succcessful insert() or find() on a set<Tcontainer is it possible to get the item number of this item in the set? (ie. its zero-based sequence number (position/location/rank/index)...
15
by: =?ISO-8859-15?Q?L=E9na=EFc?= Huard | last post by:
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Hello all, For some reasons, somewhere in a program, I'd like, if possible, to quickly parse a whole file before rewinding it and letting the...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.