What is report mode

In report mode, the list is displayed in a true multi-column format, with each row able to have an arbitrary number of columns attached to it, as displayed in figure 13.4.

□ wx.ListCtrl in wx.LC_REPORT mode

Request ID

1 Summary

Date

A

H 937441

additions to RTTT?

2004-07-0310:2;

S 346368

wxTextCtrl - disable auto-scrolling

2003-11-20 21:2:

846367

Less flicker when resizing a window

2003-11-20 21:2'

D 346366

Wishlist - wxDbGetConnection return value

2003-11-20 21:21

846364

wxPostscriptDC with floating point coordinates

2003-11-20 21:2;

i

[I 846363

Wishlist - Better wxString Formatting

2003-11-20 21:2;

346362

Wishlist - Crossplatform wxRichText Widget

2003-11-20 21:21

Ù953341

Support for paper trays when printing

2004-05-13 08:01

D952466

mac menu - Window menu

2004-05-12 03:li

1 928899

FloatCanvas demo should work with numarray

2004-04-03 08:3(

—1

Q 912714

wxGrid: Support for Search / Replace

2004-03-0« 05:4(

901061

wxComboBox- add small icons as in MSW CComboBoxEx

2004-02-20 04

Ù 900768

Please add more codepages support to your source built

2004-02-19 15:4i

1 394921

trigger on event-system creation

2004-02-11 08: It

Ù869308

HitTest in wxCheckListBox

2004-01-03 01:2;

D863306

wxGrid - Thaw/Freeze column/row

2003-12-19 17:5'

H 9 75435

wxMenu anchor right position in wxMenuBar

2004-06-18 08:4*

1 969811

wxColourEnumerator

2004-06-09 11:41

_

1 959349

wx.Grid aridlines oast max row/eol

2004-05-2419:3:

A]

llll

Lu

Figure 13.4 A sample list control in report mode

The report mode is different enough from the icon mode that it's worth presenting the sample code here as well. Listing 13.2 displays the code for creating a list in report mode.

Listing 13.2 Creating a sample list in report mode import wx import sys, glob, random import data class DemoFrame(wx.Frame):

"wx.ListCtrl in wx.LC_REPORT mode", size=(6 00,4 00))

il = wx.ImageList(16,16, True)

for name in glob.glob("smicon??.png"):

bmp = wx.Bitmap(name, wx.BITMAP_TYPE_PNG) il_max = il.Add(bmp) Creating the list self.list = wx.ListCtrl(self, -1, style=wx.LC_REPORT) <-self.list.AssignImageList(il, wx.IMAGE_LIST_SMALL)

for col, text in enumerate(data.columns)

<— Adding columns self.list.InsertColumn(col, text)

for item in data.rows: <-1 Adding rows index = self.list.InsertStringItem(sys.maxint, item[0]) for col, text in enumerate(item[1:]):

self.list.SetStringItem(index, col+1, text)

# give each item a random image img = random.randint(0, il_max) self.list.SetItemImage(index, img, img)

self.list.SetColumnWidth(0, 120) <1-1 Setting column widths self.list.SetColumnWidth(1, wx.LIST_AUTOSIZE)

self.list.SetColumnWidth(2, wx.LIST_AUTOSIZE)

self.list.SetColumnWidth(3, wx.LIST_AUTOSIZE_USEHEADER)

app = wx.PySimpleApp() frame = DemoFrame() frame.Show() app.MainLoop()

In the next sections, we'll discuss how the values are inserted into the proper locations. Report controls are not intended to be very complicated in their display logic. They are best suited for simple lists that contain one or two extra columns of data. If your list control is complex, or contains more data, it is recommended that you switch to a grid control, as described in chapter 14.

Was this article helpful?

0 0

Post a comment