In the wxPython demo if I shift the "Artist" column to the right most position and then right click the column header I can't get to the "view" column number - which should be "2" at this point.
Hoping that "item.GetColumn()" would give me the correct value, but it always returns 0.
I like to get to the visible column number and the width of that column by walking through all the columns. I have no problem getting the correct width but no luck with the column number, either I get "0" or I get the number of the position the column was originally created at.
Is it possible to get to this with a ListCtrl (wx.Python 2.9.2.4 or plus:-) ).
After digging around a bit, I found an event that works for me: EVT_LIST_COL_RIGHT_CLICK
If I bind to that, it works on my machine. I have included an example.
Interesting, but not of great help for me:-( .
My ultimate goal is to save the information of all columns in a database table and on next load the list is setup the way the user saw/configured it before saving. I guess I could ask the user to do a save after change of a column, but it would be nicer if he/she could shift columns around, set the width of the columns and when happy select the option to save it all.
It looks like there are some ListCtrl methods implemented only on MSW that you will need to use. They allow you to get/set the column order, and also map to/from col index and col order. I'll get those added for the next release, but keep in mind that they will not work on other platforms (and will probably raise a NotImplemented exception). Here are the C++ declarations:
// Gets the column order from its index or index from its order
int GetColumnOrder(int col) const;
int GetColumnIndexFromOrder(int order) const;
// Gets the column order for all columns
wxArrayInt GetColumnsOrder() const;
// Sets the column order for all columns
bool SetColumnsOrder(const wxArrayInt& orders);
···
On 10/24/11 9:53 AM, werner wrote:
Hi Mike,
On 10/24/2011 05:54 PM, Mike Driscoll wrote:
After digging around a bit, I found an event that works for me:
EVT_LIST_COL_RIGHT_CLICK
If I bind to that, it works on my machine. I have included an example.
Interesting, but not of great help for me:-( .
My ultimate goal is to save the information of all columns in a database
table and on next load the list is setup the way the user saw/configured
it before saving. I guess I could ask the user to do a save after change
of a column, but it would be nicer if he/she could shift columns around,
set the width of the columns and when happy select the option to save it
all.
After digging around a bit, I found an event that works for me:
EVT_LIST_COL_RIGHT_CLICK
If I bind to that, it works on my machine. I have included an example.
Interesting, but not of great help for me:-( .
My ultimate goal is to save the information of all columns in a database
table and on next load the list is setup the way the user saw/configured
it before saving. I guess I could ask the user to do a save after change
of a column, but it would be nicer if he/she could shift columns around,
set the width of the columns and when happy select the option to save it
all.
It looks like there are some ListCtrl methods implemented only on MSW that you will need to use. They allow you to get/set the column order, and also map to/from col index and col order. I'll get those added for the next release, but keep in mind that they will not work on other platforms (and will probably raise a NotImplemented exception). Here are the C++ declarations:
// Gets the column order from its index or index from its order
int GetColumnOrder(int col) const;
int GetColumnIndexFromOrder(int order) const;
// Gets the column order for all columns
wxArrayInt GetColumnsOrder() const;
// Sets the column order for all columns
bool SetColumnsOrder(const wxArrayInt& orders);
That sounds great, also not ideal as it is not cross platform, will just check form MSW when I use it.
Will/do the DVC control provide access to this information in a way which is cross platform?
I currently use ObjectListView (wrapper around listctrl) which is really nice/easy to use, but I am also tempted by what I see in the DVC demo's. One thing I use in the OLV is groups, i.e. be able to group by any column one defines as "groupable" and OLV then creates a kind of treectrl.
I'd wish I would be at the level to re-wrap OLV using the DVC stuff as a base - but this is way over my head.
That sounds great, also not ideal as it is not cross platform, will just
check form MSW when I use it.
Well, since the other implementations do not yet support allowing the user to drag columns around, not having the APIs is not too much of a loss. BTW, I also added a staticmethod HasColumnOrderSupport that you will be able to use to find out if column ordering can be done or not.
Will/do the DVC control provide access to this information in a way
which is cross platform?
Yes, although it's handled a little differently there since you've got discrete column objects to implement the column functionality and properties.