Get editcontrol of customtreectrl node

Get editcontrol of customtreectrl node
Is there any way to get a reference to the editing control that corresponds to a GenericTreeItem in a CustomTreeCtrl? I have a tree that has multiple nodes corresponding to the same underlying data. So when I use a textctrl or a checkbox or a combobox to edit one item…I’d like the data being displayed in all of the other editing controls (corresponding to the data that was editing) to be updated. I can obtain references to the GenericTreeItems that need to have their editing controls updated (via model listeners), but I cannot figure out how to get references to the editing controls themselves. I’d rather not have to maintain an additional dictionary that maps GenericTreeItems to wx controls.

I see that there is a “GetEditControl” on the CustomTreeCtrl class itself (which doesn’t take a GenericTreeItem as a parameter)…which always returns None for me - so I’m not exactly sure what that is supposed to do.

Thanks,

Andrew

Hi Andrew,

Is there any way to get a reference to the editing control that corresponds
to a GenericTreeItem in a CustomTreeCtrl?

What about GenericTreeItem.GetWindow()?

def GetWindow(self):
    """Returns the window associated to the item."""

    return self._wnd

Andrea.

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

Sorry, I think I have misunderstood your question... you mean the edit
control that appears when you use wx.TR_EDIT_LABELS as a tree style
and you start editing the item? Well, this control is created and
destroyed on the fly for the item you are actually editing: the other
items do *not* have an edit control associated because you are not
editing them. Is that what you meant? Because CustomTreeCtrl can have
also wx.TextCtrl attached as a control right to the items, it is not
very clear to me what you are trying to accomplish...

Andrea.

···

On 1/18/07, Andrea Gavana <andrea.gavana@gmail.com> wrote:

Hi Andrew,

> Is there any way to get a reference to the editing control that corresponds
> to a GenericTreeItem in a CustomTreeCtrl?

What about GenericTreeItem.GetWindow()?

def GetWindow(self):
   """Returns the window associated to the item."""

   return self._wnd

Andrea.

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

--
Andrea.

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

These types of controls:
http://www.andrewpangborn.com/files/pictures/customtreectrl.jpg

Looking at the InsertItemByIndex constructor again...perhaps the wxcontrol that I am giving it is infact the "window".

···

-----Original Message-----
From: Andrea Gavana [mailto:andrea.gavana@gmail.com]
Sent: Thursday, January 18, 2007 1:13 PM
To: wxPython-users@lists.wxwidgets.org
Subject: Re: [wxPython-users] Get editcontrol of customtreectrl node

Sorry, I think I have misunderstood your question... you mean the edit
control that appears when you use wx.TR_EDIT_LABELS as a tree style
and you start editing the item? Well, this control is created and
destroyed on the fly for the item you are actually editing: the other
items do *not* have an edit control associated because you are not
editing them. Is that what you meant? Because CustomTreeCtrl can have
also wx.TextCtrl attached as a control right to the items, it is not
very clear to me what you are trying to accomplish...

Andrea.

On 1/18/07, Andrea Gavana <andrea.gavana@gmail.com> wrote:

Hi Andrew,

> Is there any way to get a reference to the editing control that corresponds
> to a GenericTreeItem in a CustomTreeCtrl?

What about GenericTreeItem.GetWindow()?

def GetWindow(self):
   """Returns the window associated to the item."""

   return self._wnd

Andrea.

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

--
Andrea.

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

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

I was just playing with this this morning.

GetEditControl() works, but it only return a useful value *when the line is being edited*.
So if you use it in an init method, you'll always find no value. My intention was to
try and add a validator to the text control as an alternative to the method Andrea suggested
to me (I was just playing around).

The edit control seems to have a value after EVT_TREE_BEGIN_LABEL_EDIT is fired.
Unfortunately if I bind a method to this event, I still don't seem to be able to do anything
useful. As a test, I tried to set the background color, but it wasn't reflected on the screen,
I don't know why.

Here's the code snippet, FWIW.

         def __init__(self):
                 self.tree = app.mainFrame.comboPanel.tree
                 self.tree.Bind(wx.EVT_TREE_BEGIN_LABEL_EDIT, self.OnBeginEdit)

         def OnBeginEdit(self,event):
                 ec=self.tree.GetEditControl()
                 ec.SetBackgroundColour('red')

this code doesn't work, but at least ec is non-null.

HTH,
Danny

···

At 07:12 PM 1/18/2007 +0100, you wrote:

Sorry, I think I have misunderstood your question... you mean the edit
control that appears when you use wx.TR_EDIT_LABELS as a tree style
and you start editing the item? Well, this control is created and
destroyed on the fly for the item you are actually editing: the other
items do *not* have an edit control associated because you are not
editing them. Is that what you meant? Because CustomTreeCtrl can have
also wx.TextCtrl attached as a control right to the items, it is not
very clear to me what you are trying to accomplish...

Andrea.

On 1/18/07, Andrea Gavana <andrea.gavana@gmail.com> wrote:

Hi Andrew,

> Is there any way to get a reference to the editing control that corresponds
> to a GenericTreeItem in a CustomTreeCtrl?

What about GenericTreeItem.GetWindow()?

def GetWindow(self):
   """Returns the window associated to the item."""

   return self._wnd

Andrea.

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

--
Andrea.

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

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

oops. I was referring to TreeCtrl, not customtreectrl. Please ignore...

D

···

At 11:53 AM 1/18/2007 -0700, you wrote:

I was just playing with this this morning.

GetEditControl() works, but it only return a useful value *when the line is being edited*.
So if you use it in an init method, you'll always find no value. My intention was to
try and add a validator to the text control as an alternative to the method Andrea suggested
to me (I was just playing around).

The edit control seems to have a value after EVT_TREE_BEGIN_LABEL_EDIT is fired.
Unfortunately if I bind a method to this event, I still don't seem to be able to do anything
useful. As a test, I tried to set the background color, but it wasn't reflected on the screen,
I don't know why.

Here's the code snippet, FWIW.

        def __init__(self):
                self.tree = app.mainFrame.comboPanel.tree
                self.tree.Bind(wx.EVT_TREE_BEGIN_LABEL_EDIT, self.OnBeginEdit)

        def OnBeginEdit(self,event):
                ec=self.tree.GetEditControl()
                ec.SetBackgroundColour('red')

this code doesn't work, but at least ec is non-null.

HTH,
Danny

At 07:12 PM 1/18/2007 +0100, you wrote:

Sorry, I think I have misunderstood your question... you mean the edit
control that appears when you use wx.TR_EDIT_LABELS as a tree style
and you start editing the item? Well, this control is created and
destroyed on the fly for the item you are actually editing: the other
items do *not* have an edit control associated because you are not
editing them. Is that what you meant? Because CustomTreeCtrl can have
also wx.TextCtrl attached as a control right to the items, it is not
very clear to me what you are trying to accomplish...

Andrea.

On 1/18/07, Andrea Gavana <andrea.gavana@gmail.com> wrote:

Hi Andrew,

> Is there any way to get a reference to the editing control that corresponds
> to a GenericTreeItem in a CustomTreeCtrl?

What about GenericTreeItem.GetWindow()?

def GetWindow(self):
   """Returns the window associated to the item."""

   return self._wnd

Andrea.

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

--
Andrea.

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

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

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

Yes, it is. Those controls are retrieved using:

YourItem.GetWindow()

There are also method for SetWindow, GetWindowSize etc...

Andrea.

···

On 1/18/07, Pangborn, Andrew (ext. 324) <axp@qvii.com> wrote:

These types of controls:
http://www.andrewpangborn.com/files/pictures/customtreectrl.jpg

Looking at the InsertItemByIndex constructor again...perhaps the wxcontrol that I am giving it is infact the "window".

-----Original Message-----
From: Andrea Gavana [mailto:andrea.gavana@gmail.com]
Sent: Thursday, January 18, 2007 1:13 PM
To: wxPython-users@lists.wxwidgets.org
Subject: Re: [wxPython-users] Get editcontrol of customtreectrl node

Sorry, I think I have misunderstood your question... you mean the edit
control that appears when you use wx.TR_EDIT_LABELS as a tree style
and you start editing the item? Well, this control is created and
destroyed on the fly for the item you are actually editing: the other
items do *not* have an edit control associated because you are not
editing them. Is that what you meant? Because CustomTreeCtrl can have
also wx.TextCtrl attached as a control right to the items, it is not
very clear to me what you are trying to accomplish...

Andrea.

On 1/18/07, Andrea Gavana <andrea.gavana@gmail.com> wrote:
> Hi Andrew,
>
> > Is there any way to get a reference to the editing control that corresponds
> > to a GenericTreeItem in a CustomTreeCtrl?
>
> What about GenericTreeItem.GetWindow()?
>
> def GetWindow(self):
> """Returns the window associated to the item."""
>
> return self._wnd
>
> Andrea.
>
> "Imagination Is The Only Weapon In The War Against Reality."
> http://xoomer.virgilio.it/infinity77/
>

--
Andrea.

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

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

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

--
Andrea.

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

That works, thanks.

···

-----Original Message-----
From: Andrea Gavana [mailto:andrea.gavana@gmail.com]
Sent: Thursday, January 18, 2007 2:41 PM
To: wxPython-users@lists.wxwidgets.org
Subject: Re: [wxPython-users] Get editcontrol of customtreectrl node

Yes, it is. Those controls are retrieved using:

YourItem.GetWindow()

There are also method for SetWindow, GetWindowSize etc...

Andrea.

On 1/18/07, Pangborn, Andrew (ext. 324) <axp@qvii.com> wrote:

These types of controls:
http://www.andrewpangborn.com/files/pictures/customtreectrl.jpg

Looking at the InsertItemByIndex constructor again...perhaps the wxcontrol that I am giving it is infact the "window".

-----Original Message-----
From: Andrea Gavana [mailto:andrea.gavana@gmail.com]
Sent: Thursday, January 18, 2007 1:13 PM
To: wxPython-users@lists.wxwidgets.org
Subject: Re: [wxPython-users] Get editcontrol of customtreectrl node

Sorry, I think I have misunderstood your question... you mean the edit
control that appears when you use wx.TR_EDIT_LABELS as a tree style
and you start editing the item? Well, this control is created and
destroyed on the fly for the item you are actually editing: the other
items do *not* have an edit control associated because you are not
editing them. Is that what you meant? Because CustomTreeCtrl can have
also wx.TextCtrl attached as a control right to the items, it is not
very clear to me what you are trying to accomplish...

Andrea.

On 1/18/07, Andrea Gavana <andrea.gavana@gmail.com> wrote:
> Hi Andrew,
>
> > Is there any way to get a reference to the editing control that corresponds
> > to a GenericTreeItem in a CustomTreeCtrl?
>
> What about GenericTreeItem.GetWindow()?
>
> def GetWindow(self):
> """Returns the window associated to the item."""
>
> return self._wnd
>
>
> Andrea.
>
> "Imagination Is The Only Weapon In The War Against Reality."
> http://xoomer.virgilio.it/infinity77/
>

--
Andrea.

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

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

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

--
Andrea.

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

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