unselect single item in wxTreeCtrl

Hi all,

is there a builtin way to deselect a single item in a wxTreeCtrl
(wxTR_MULTIPLE style)?
I have some items in the tree that must not be selectable and so I want to
deselect them as soon as they are selected.
But the only thing I found is wxTreeCtrl::UnselectAll. This makes it necessary
to save all selections temporarily, then deselect all and then reselect all
previously selected items, except the not-selectable one.
As I know which Item I want to deselect something Like Unselect(item) would be
much nicer.

tia

/ch

···

--
Wieviele Mitarbeiter von Microsoft benoetigt man fuer das auswechseln
einer defekten Gluehbirne? Keine, Microsoft erklaert die Dunkelheit zum
Marktstandart.

How about using an EVT_TREE_SEL_CHANGING() event & vetoing any change if the selection is not allowed.

eg for a tree control win1:

EVT_TREE_SEL_CHANGING(self.win1, ID1, self.OnSelChanging_win1)

def OnSelChanging_win1(self, evt):
self.item = evt.GetItem()
if self.win1.GetItemText(self.item) == “MP3 Listing”:
self.SelectAll(self.win1)
evt.Veto()

Hope this helps.

But I’d love to be able to unselect an individual item as you said.

···

----- Original Message -----
From: Clemens Hermann

To: wxpython-users@lists.wxwindows.org

Sent: Sunday, November 03, 2002 7:06 AM

Subject: [wxPython-users] unselect single item in wxTreeCtrl

Hi all,

is there a builtin way to deselect a single item in a wxTreeCtrl
(wxTR_MULTIPLE style)?
I have some items in the tree that must not be selectable and so I want to
deselect them as soon as they are selected.
But the only thing I found is wxTreeCtrl::UnselectAll. This makes it necessary
to save all selections temporarily, then deselect all and then reselect all
previously selected items, except the not-selectable one.
As I know which Item I want to deselect something Like Unselect(item) would be
much nicer.

tia

/ch


Wieviele Mitarbeiter von Microsoft benoetigt man fuer das auswechseln
einer defekten Gluehbirne? Keine, Microsoft erklaert die Dunkelheit zum
Marktstandart.


To unsubscribe, e-mail: wxPython-users-unsubscribe@lists.wxwindows.org
For additional commands, e-mail: wxPython-users-help@lists.wxwindows.org

Hi Chris,

How about using an EVT_TREE_SEL_CHANGING() event & vetoing any change if the selection is not allowed.

thanks for the input! The problem is, I want to allow multiselect and "unselectable" items should
just be excluded. When I cancel the whole event, I also cancel the valid part of the multiselect, right?

/ch

···

Am 03.11.2002 um 09:41:19 schrieb Chris Munchenberg:

--
Wieviele Mitarbeiter von Microsoft benoetigt man fuer das auswechseln
einer defekten Gluehbirne? Keine, Microsoft erklaert die Dunkelheit zum
Marktstandart.

I think I understand what you want to do, but I have no idea how to do it.

I only use a single branch on a tree and use it to block selection of the root item, I haven’t tried what you want to do.

Sorry, I have to pass on this one.

Chris.

···

----- Original Message -----
From: Clemens Hermann

To: wxPython-users@lists.wxwindows.org

Sent: Sunday, November 03, 2002 9:51 AM

Subject: Re: [wxPython-users] unselect single item in wxTreeCtrl

Am 03.11.2002 um 09:41:19 schrieb Chris Munchenberg:

Hi Chris,

How about using an EVT_TREE_SEL_CHANGING() event & vetoing any change if the selection is not allowed.

thanks for the input! The problem is, I want to allow multiselect and “unselectable” items should
just be excluded. When I cancel the whole event, I also cancel the valid part of the multiselect, right?

/ch


Wieviele Mitarbeiter von Microsoft benoetigt man fuer das auswechseln
einer defekten Gluehbirne? Keine, Microsoft erklaert die Dunkelheit zum
Marktstandart.


To unsubscribe, e-mail: wxPython-users-unsubscribe@lists.wxwindows.org
For additional commands, e-mail: wxPython-users-help@lists.wxwindows.org

Clemens Hermann wrote:

Hi all,

is there a builtin way to deselect a single item in a wxTreeCtrl (wxTR_MULTIPLE style)?
I have some items in the tree that must not be selectable and so I want to deselect them as soon as they are selected.
But the only thing I found is wxTreeCtrl::UnselectAll. This makes it necessary
to save all selections temporarily, then deselect all and then reselect all
previously selected items, except the not-selectable one.
As I know which Item I want to deselect something Like Unselect(item) would be much nicer.

I don't see any other way. It seem like there should be a UnselectItem method though. Please create a request for it in the bug tracker and hopefully somebody will get to it soon.

···

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