CustomTreeCtrl has the same "ghost" problems as TreeCtrl ?

hello,

We had already the discussion of the weird behaviour of the tree in the wxPython demos,
now I was hoping CustomTreeCtrl didn't have this behaviour :wink:
but it has :frowning:

I've an application, where there's only one item that can receive focus,
and that's an CustumTreeCtrl.
The other part is a drawing canvas, which can't receive focus,
but needs to catch key events, when the user is working on the drawing canvas.
So I created a dummy panel which is placed behind the CustomTreeCtrl.
This dummy panel receives focus when the user works on the drawing canvas,
enabling key reception to the drawing canvas.

聽聽聽self.Splitter = wx.SplitterWindow ( self, 11, style = wx.SP_LIVE_UPDATE)

聽聽聽聽# **********************************
聽聽聽聽# dummy panel, to fetch key-events for the drawing canvas
聽聽聽聽# MUST NOT INTERFERE WITH THE TREE CONTROL !!!
聽聽聽聽self.Panel_Left_Bottom2 = \
聽聽聽聽聽聽wx.Window ( self.Splitter, pos = ( 1, 1500 ), size = ( 1,1 ) )
聽聽聽聽# **********************************
聽聽聽聽self.Tree = MyCustomTreeCtrl (self.Splitter, self,'TREE ROOT')

聽聽聽聽self.Shape_Container = tPyLabView_ShapeCanvas (
聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽self.Splitter, self, pos=(0,0),size=(500,500))

As you can see, I now have placed the dummy panel off screen.
But at the start I put the dummy panel, just in the upper left corner,
and it has a size of (50,50)
In this case it's impossible to expand the first node in the tree,
by clicking on the +/- sign of the tree.
Apparently, the click is not received by the tree,
but is received by the dummy panel.

I used this trick many times in other languages, without any problems.

So I wonder if this "ghost" behavior is general for wxPython ?

thanks,
Stef Mientki

Hi Stef,

We had already the discussion of the weird behaviour of the tree in the
wxPython demos,
now I was hoping CustomTreeCtrl didn't have this behaviour :wink:
but it has :frowning:

I've an application, where there's only one item that can receive focus,
and that's an CustumTreeCtrl.
The other part is a drawing canvas, which can't receive focus,
but needs to catch key events, when the user is working on the drawing
canvas.
So I created a dummy panel which is placed behind the CustomTreeCtrl.
This dummy panel receives focus when the user works on the drawing canvas,
enabling key reception to the drawing canvas.

  self.Splitter = wx.SplitterWindow ( self, 11, style = wx.SP_LIVE_UPDATE)

   # **********************************
   # dummy panel, to fetch key-events for the drawing canvas
   # MUST NOT INTERFERE WITH THE TREE CONTROL !!!
   self.Panel_Left_Bottom2 = \
     wx.Window ( self.Splitter, pos = ( 1, 1500 ), size = ( 1,1 ) )
   # **********************************
   self.Tree = MyCustomTreeCtrl (self.Splitter, self,'TREE ROOT')

   self.Shape_Container = tPyLabView_ShapeCanvas (
                          self.Splitter, self, pos=(0,0),size=(500,500))

As you can see, I now have placed the dummy panel off screen.
But at the start I put the dummy panel, just in the upper left corner,
and it has a size of (50,50)
In this case it's impossible to expand the first node in the tree,
by clicking on the +/- sign of the tree.
Apparently, the click is not received by the tree,
but is received by the dummy panel.

I used this trick many times in other languages, without any problems.

So I wonder if this "ghost" behavior is general for wxPython ?

I don't think it's a prerogative of wx.TreeCtrl or CustomTreeCtrl,
it's just the way wxWidgets works. It's a bit obscure to me what you
are trying to accomplish... Why your canvas cannot receive the focus?
And why do you send the focus to a ghost panel instead of to the
wx.TreeCtrl/CustomTreeCtrl? It looks a bit tortuous :-). Anyway, you
could try calling something like:

wx.CallAfter(self.SendSizeEvent)

at the end of the __init__ method of your main frame (i.e. when you
finish the construction of all your widgets)? This sends a size event
to the main frame, which is in theory propagated to all its children
(splitter, sizers, panels, trees, etc...) so that your dummy panel
regains its size=(1,1). I am not sure it will work, but honestly I
can't say I have understood completely the logic behind your
approach... It's not a critic, it's just that maybe my mind is too
slow :smiley:

Andrea.

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

路路路

On Nov 16, 2007 1:49 PM, Stef Mientki wrote:

hi Andrea,

Andrea Gavana wrote:

Hi Stef,

We had already the discussion of the weird behaviour of the tree in the
wxPython demos,
now I was hoping CustomTreeCtrl didn't have this behaviour :wink:
but it has :frowning:

I've an application, where there's only one item that can receive focus,
and that's an CustumTreeCtrl.
The other part is a drawing canvas, which can't receive focus,
but needs to catch key events, when the user is working on the drawing
canvas.
So I created a dummy panel which is placed behind the CustomTreeCtrl.
This dummy panel receives focus when the user works on the drawing canvas,
enabling key reception to the drawing canvas.

  self.Splitter = wx.SplitterWindow ( self, 11, style = wx.SP_LIVE_UPDATE)

   # **********************************
   # dummy panel, to fetch key-events for the drawing canvas
   # MUST NOT INTERFERE WITH THE TREE CONTROL !!!
   self.Panel_Left_Bottom2 = \
     wx.Window ( self.Splitter, pos = ( 1, 1500 ), size = ( 1,1 ) )
   # **********************************
   self.Tree = MyCustomTreeCtrl (self.Splitter, self,'TREE ROOT')

   self.Shape_Container = tPyLabView_ShapeCanvas (
                          self.Splitter, self, pos=(0,0),size=(500,500))

As you can see, I now have placed the dummy panel off screen.
But at the start I put the dummy panel, just in the upper left corner,
and it has a size of (50,50)
In this case it's impossible to expand the first node in the tree,
by clicking on the +/- sign of the tree.
Apparently, the click is not received by the tree,
but is received by the dummy panel.

I used this trick many times in other languages, without any problems.

So I wonder if this "ghost" behavior is general for wxPython ?
    
I don't think it's a prerogative of wx.TreeCtrl or CustomTreeCtrl,
it's just the way wxWidgets works.

I was afraid of that :wink:

It's a bit obscure to me what you
are trying to accomplish... Why your canvas cannot receive the focus?
  

Well I don't know, but both ogl and ogllike aren't able to get focus.
Is that easy to add ?

And why do you send the focus to a ghost panel instead of to the
wx.TreeCtrl/CustomTreeCtrl?

If I press "Del", should I delete the active treeitem or the active drawing object ?

btw, I just looked at your site,
and saw that you've added the "custom colors" to your CubeColourDialog,
fantastic !!
Now I've to try it soon.

cheers,
Stef

路路路

On Nov 16, 2007 1:49 PM, Stef Mientki wrote: