CustomTreeCtrl and wx.TR_MULTIPLE

Hi Andrea and others,

I can't seem to select more than one item in a CustomTreeCtrl with
wx.TR_MULTIPLE style on. See attached example. I would expect both
item1 and item2 to be selected, but they're not. What am I doing
wrong?

Thanks, Frank

ct_multiple.py (556 Bytes)

HI Frank,

I can't seem to select more than one item in a CustomTreeCtrl
with wx.TR_MULTIPLE style on. See attached example. I would
expect both
item1 and item2 to be selected, but they're not. What am I
doing wrong?

CustomTreeCtrl takes 2 "style" keywords: the first, names "style", assigns the style to the underline wx.PyScrolledWindow. The other one, called "ctstyle", is used for CustomTreeCtrl itself. On your sample, try this:

ctstyle=wx.TR_DEFAULT_STYLE | wx.TR_MULTIPLE

It works for me.

Andrea.

···

_________________________________________
Andrea Gavana (gavana@kpo.kz)
Reservoir Engineer
KPDL
4, Millbank
SW1P 3JA London

Direct Tel: +44 (0) 20 717 08936
Mobile Tel: +44 (0) 77 487 70534
Fax: +44 (0) 20 717 08900
Web: http://xoomer.virgilio.it/infinity77
¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯

Ah darn, I did try ct_style because that keyword is used for
AppendItem... Why two spellings?

Also, since a CustomTreeCtrl is a TreeCtrl first and a
PyScrolledWindow second wouldn't it be more logical to have a new
keyword for the scrolledwindow style and use 'style' for the tree
style?

Thanks, Frank

···

2007/2/12, Gavana, Andrea <gavana@kpo.kz>:

CustomTreeCtrl takes 2 "style" keywords: the first, names "style", assigns the style to the underline wx.PyScrolledWindow. The other one, called "ctstyle", is used for CustomTreeCtrl itself. On your sample, try this:

ctstyle=wx.TR_DEFAULT_STYLE | wx.TR_MULTIPLE

Hi Frank,

> ctstyle=wx.TR_DEFAULT_STYLE | wx.TR_MULTIPLE

Ah darn, I did try ct_style because that keyword is used for
AppendItem... Why two spellings?

I have no idea :smiley: .
I suppose I didn't pay too much attention when I wrote CustomTreeCtrl,
so it just slipped in as a perfect inconsistency.

Also, since a CustomTreeCtrl is a TreeCtrl first and a
PyScrolledWindow second wouldn't it be more logical to have a new
keyword for the scrolledwindow style and use 'style' for the tree
style?

Yes, I believe it would be much more logical. Any suggestion about the
new keyword? Actually, I think that these 2 modifications plus the
patch about the UnselectAll() bug plus the fix on the classmethod
missing in CustomTreeCtrl should go in a patch for Robin, if he has
time to integrate it for the new release.

Thanks for the bug reports :smiley: :smiley:

Andrea.

"Imagination Is The Only Weapon In The War Against Reality."
http://xoomer.virgilio.it/infinity77/

Andrea Gavana wrote:

Also, since a CustomTreeCtrl is a TreeCtrl first and a
PyScrolledWindow second wouldn't it be more logical to have a new
keyword for the scrolledwindow style and use 'style' for the tree
style?

Yes, I believe it would be much more logical. Any suggestion about the
new keyword?

Is there any reason why a single style parameter can't be used? The style flags with values in the upper half of the 32-bit value are reserved for generic window styles, but the lower half is reserved for the individual controls. So you should be able to have up to 16 styles in the range of 1 .. 2^15 without conflicting with anything that the scrolled window is going to be looking for.

Actually, I think that these 2 modifications plus the
patch about the UnselectAll() bug plus the fix on the classmethod
missing in CustomTreeCtrl should go in a patch for Robin, if he has
time to integrate it for the new release.

Sure.

···

--
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!

Hi Robin,

Andrea Gavana wrote:
>> Also, since a CustomTreeCtrl is a TreeCtrl first and a
>> PyScrolledWindow second wouldn't it be more logical to have a new
>> keyword for the scrolledwindow style and use 'style' for the tree
>> style?
>
> Yes, I believe it would be much more logical. Any suggestion about the
> new keyword?

Is there any reason why a single style parameter can't be used? The
style flags with values in the upper half of the 32-bit value are
reserved for generic window styles, but the lower half is reserved for
the individual controls. So you should be able to have up to 16 styles
in the range of 1 .. 2^15 without conflicting with anything that the
scrolled window is going to be looking for.

No, actually I don't think there is a special reason for that. At that
time, I was still influenced by "special" keywords (as in
FoldPanelBar), so I just decided to use "ctstyle" instead of grouping
everything together in a single keyword. I didn't realize it was a
silly behavior.
However, I'll try to modify the source code for CustomTreeCtrl:
obviously, this will break every app that uses the actual __init__
construction. While I don't really care about my apps (it's simply a
keyword to change), I suspect I will se a bunch of bug reports for the
different behavior across version and a ton of insults from
programmers that have to support different wxPython versions :smiley:

Andrea.

"Imagination Is The Only Weapon In The War Against Reality."
http://xoomer.virgilio.it/infinity77/

···

On 2/13/07, Robin Dunn wrote:

Andrea Gavana wrote:

Hi Robin,

Andrea Gavana wrote:
>> Also, since a CustomTreeCtrl is a TreeCtrl first and a
>> PyScrolledWindow second wouldn't it be more logical to have a new
>> keyword for the scrolledwindow style and use 'style' for the tree
>> style?
>
> Yes, I believe it would be much more logical. Any suggestion about the
> new keyword?

Is there any reason why a single style parameter can't be used? The
style flags with values in the upper half of the 32-bit value are
reserved for generic window styles, but the lower half is reserved for
the individual controls. So you should be able to have up to 16 styles
in the range of 1 .. 2^15 without conflicting with anything that the
scrolled window is going to be looking for.

No, actually I don't think there is a special reason for that. At that
time, I was still influenced by "special" keywords (as in
FoldPanelBar), so I just decided to use "ctstyle" instead of grouping
everything together in a single keyword. I didn't realize it was a
silly behavior.
However, I'll try to modify the source code for CustomTreeCtrl:
obviously, this will break every app that uses the actual __init__
construction. While I don't really care about my apps (it's simply a
keyword to change), I suspect I will se a bunch of bug reports for the
different behavior across version and a ton of insults from
programmers that have to support different wxPython versions :smiley:

You can leave a ctstyle parameter with a default value of zero, and then combine it with the style parameter in the __init__

···

On 2/13/07, Robin Dunn wrote:

--
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!