UltimateListCtrl is a class that mimics the behaviour of ListCtrl
, with almost
the same base functionalities plus some more enhancements. This class does
not rely on the native control, as it is a full owner-drawn list control.
In addition to the standard ListCtrl
behaviour this class supports:
Multiple images for items/subitems;
Images can be of any size and not limited to a single specific pair of width, height
as it is the case of wx.ImageList
. Simply use PyImageList
instead of wx.ImageList
to add your images.
Font, colour, background, custom renderers and formatting for items and subitems;
Ability to add persistent data to an item using SetItemPyData
and GetItemPyData
:
the data can be any Python object and not necessarily an integer as in ListCtrl
;
CheckBox-type items and subitems;
RadioButton-type items and subitems;
Overflowing items/subitems, a la grid.Grid
, i.e. an item/subitem may overwrite neighboring
items/subitems if its text would not normally fit in the space allotted to it;
Hyperlink-type items and subitems: they look like an hyperlink, with the proper mouse cursor on hovering;
Multiline text items and subitems;
Variable row heights depending on the item/subitem kind/text/window;
User defined item/subitem renderers: these renderer classes must implement the methods DrawSubItem, GetLineHeight and GetSubItemWidth (see the demo);
Enabling/disabling items (together with their plain or grayed out icons);
Whatever non-toplevel widget can be attached next to an item/subitem;
Column headers are fully customizable in terms of icons, colour, font, alignment etc…;
Column headers can have their own checkbox/radiobutton;
Column footers are fully customizable in terms of icons, colour, font, alignment etc…;
Column footers can have their own checkbox/radiobutton;
Ability to hide/show columns;
Default selection style, gradient (horizontal/vertical) selection style and Windows Vista selection style.
And a lot more. Check the demo for an almost complete review of the functionalities.
Usage example:
import sys
import wx
import wx.lib.agw.ultimatelistctrl as ULC
class MyFrame(wx.Frame):
def __init__(self, parent):
wx.Frame.__init__(self, parent, -1, "UltimateListCtrl Demo")
list = ULC.UltimateListCtrl(self, wx.ID_ANY, agwStyle=ULC.ULC_REPORT | ULC.ULC_VRULES | ULC.ULC_HRULES | ULC.ULC_SINGLE_SEL | ULC.ULC_HAS_VARIABLE_ROW_HEIGHT)
list.InsertColumn(0, "Column 1")
list.InsertColumn(1, "Column 2")
index = list.InsertStringItem(sys.maxsize, "Item 1")
list.SetStringItem(index, 1, "Sub-item 1")
index = list.InsertStringItem(sys.maxsize, "Item 2")
list.SetStringItem(index, 1, "Sub-item 2")
choice = wx.Choice(list, -1, choices=["one", "two"])
index = list.InsertStringItem(sys.maxsize, "A widget")
list.SetItemWindow(index, 1, choice, expand=True)
sizer = wx.BoxSizer(wx.VERTICAL)
sizer.Add(list, 1, wx.EXPAND)
self.SetSizer(sizer)
# our normal wxApp-derived class, as usual
- if __name__ == “__main__”:
app = wx.App(0)
frame = MyFrame(None) app.SetTopWindow(frame) frame.Show()
app.MainLoop()
This class supports the following window styles:
Window Styles |
Hex Value |
Description |
---|---|---|
|
0x1 |
Draws light vertical rules between rows in report mode. |
|
0x2 |
Draws light horizontal rules between rows in report mode. |
|
0x4 |
Large icon view, with optional labels. |
|
0x8 |
Small icon view, with optional labels. |
|
0x10 |
Multicolumn list view, with optional small icons. Columns are computed automatically, i.e. you don’t set columns as in |
|
0x20 |
Single or multicolumn report view, with optional header. |
|
0x40 |
Icons align to the top. Win32 default, Win32 only. |
|
0x80 |
Icons align to the left. |
|
0x100 |
Icons arrange themselves. Win32 only. |
|
0x200 |
The application provides items text on demand. May only be used with |
|
0x400 |
Labels are editable: the application will be notified when editing starts. |
|
0x800 |
No header in report mode. |
|
0x1000 |
No Docs. |
|
0x2000 |
Single selection (default is multiple). |
|
0x4000 |
Sort in ascending order. (You must still supply a comparison callback in |
|
0x8000 |
Sort in descending order. (You must still supply a comparison callback in |
|
0x10000 |
Each item appears as a full-sized icon with a label of one or more lines beside it (partially implemented). |
|
0x20000 |
No highlight when an item is selected. |
|
0x40000 |
Items are selected by simply hovering on them, with no need to click on them. |
|
0x80000 |
Don’t send a selection event when using |
|
0x100000 |
Send a left click event when an item is selected. |
|
0x200000 |
The list has variable row heights. |
|
0x400000 |
When a column header has a checkbox associated, auto-check all the subitems in that column. |
|
0x800000 |
When a column header has a checkbox associated, toggle all the subitems in that column. |
|
0x1000000 |
Only meaningful foe checkbox-type items: when an item is checked/unchecked its column header item is checked/unchecked as well. |
|
0x2000000 |
Show tooltips for ellipsized items/subitems (text too long to be shown in the available space) containing the full item/subitem text. |
|
0x4000000 |
Enable hot tracking of items on mouse motion. |
|
0x8000000 |
Changes border colour when an item is selected, instead of highlighting the item. |
|
0x10000000 |
Enables hot-track selection in a list control. Hot track selection means that an item is automatically selected when the cursor remains over the item for a certain period of time. The delay is retrieved on Windows using the win32api call win32gui.SystemParametersInfo(win32con.SPI_GETMOUSEHOVERTIME), and is defaulted to 400ms on other platforms. This style applies to all views of |
|
0x20000000 |
Show column headers in all view modes. |
|
0x40000000 |
When an item is selected, the only the item in the first column is highlighted. |
|
0x80000000 |
Show a footer too (only when header is present). |
|
0x100000000 |
Allows to set a custom row height (one value for all the items, only in report mode). |
|
0x200000000 |
Disable item dragging |
This class processes the following events:
Event Name |
Description |
---|---|
|
Begin dragging with the left mouse button. |
|
Begin dragging with the right mouse button. |
|
Begin editing a label. This can be prevented by calling Veto(). |
|
Finish editing a label. This can be prevented by calling Veto(). |
|
An item was deleted. |
|
All items were deleted. |
|
A key has been pressed. |
|
An item has been inserted. |
|
A column (m_col) has been left-clicked. |
|
A column (m_col) has been right-clicked. |
|
The user started resizing a column - can be vetoed. |
|
The user finished resizing a column. |
|
The divider between columns is being dragged. |
|
The item has been selected. |
|
The item has been deselected. |
|
The right mouse button has been clicked on an item. |
|
The middle mouse button has been clicked on an item. |
|
The item has been activated ( |
|
The currently focused item has changed. |
|
Prepare cache for a virtual list control. |
|
An item/subitem is being checked. |
|
An item/subitem has been checked. |
|
A column header is being checked. |
|
A column header has being checked. |
|
A column footer is being checked. |
|
A column footer has being checked. |
|
An hyperlink item has been clicked. |
|
The user left-clicked on a column footer. |
|
The user right-clicked on a column footer. |
|
Send a left-click event after an item is selected. |
|
Notify an end-drag operation. |
Windows (Windows XP);
UltimateListCtrl is distributed under the wxPython license.
Latest Revision: Andrea Gavana @ 27 Dec 2012, 21.00 GMT
Version 0.8
Checks whether a text contains multiline strings and if the listCtrl window |
|
Creates a new instance of |
|
Returns the drag and drop cursor image as a |
|
Returns the drag and drop cursor image as a decompressed stream of characters. |
|
Returns the drag and drop cursor image as a |
|
Creates a disabled-looking bitmap starting from the input one. |
|
Converts the input data into a Python list. |
A simple class which holds information about |
|
A list event holds information about events associated with |
|
A simple class which holds items geometries for |
|
A |
|
SelectionStore is used to store the selected items in the virtual |
|
UltimateListCtrl is a class that mimics the behaviour of |
|
A list event holds information about events associated with |
|
A simple class which holds information about |
|
This class holds the header window for |
|
This class stores information about a |
|
Represents the attributes (colour, font, …) of a |
|
A simple class which holds information about |
|
A simple class which holds line geometries for |
|
This is the main widget implementation of |
|
Timer used for enabling in-place edit. |
|
Control used for in-place edit. |
CheckVariableRowHeight
(listCtrl, text)¶Checks whether a text contains multiline strings and if the listCtrl window style is compatible with multiline strings.
listCtrl – an instance of UltimateListCtrl
;
text – the text to analyze.
CreateListItem
(itemOrId, col)¶Creates a new instance of UltimateListItem
.
itemOrId – can be an instance of UltimateListItem
or an integer;
col – the item column.
GetdragcursorData
()¶Returns the drag and drop cursor image as a decompressed stream of characters.
MakeDisabledBitmap
(original)¶Creates a disabled-looking bitmap starting from the input one.
original – an instance of wx.Bitmap
to be greyed-out.
to_list
(input)¶Converts the input data into a Python list.
input – can be an integer or a Python list (in which case nothing will be done to input.