I create two panels (A & B) in a frame. Each panel has
a txtControl in the upper left corner. The Panels aorigin is set so that they
overlap. I create panel A first, then B – so in the display it appears
that B is on top of A. Each panel binds to the evt_mouse_down, but call its
own event handler. For the test, which ever panel was clicked write the mouse
position in its tectbox. For debug purposes I also print the message that says
which panel was clicked.
When I run this, if I click on the part of Panel B which overlaps
panel A, panel A handlers responds, and writes the mouse position in its text
box, with respects to its origin. The only way I can get panel B to grab the
event is to click on a part of panel B that does not overlap panel A.
As an aside, on Panel A, if I position the mouse in panel A’s
text box it the cursor changes to text, as it should. But if I position over
the text box in panel B, the cursor remains an arrow.
I am running this on windows XP. IS this normal behavior.
If not, what am I doing wrong???
Here’s the code:
···
import wx
class frame(wx.Frame):
def __init__(self):
wx.Frame.__init__(self, None, title="test
move",size=(400,400))
self.panelA =
wx.Panel(self,pos=(20,20),size=(200,200),style=wx.DOUBLE_BORDER)
self.panelA.Bind(wx.EVT_LEFT_DOWN,
self.OnLeftClickA)
self.panelA.t1A = wx.TextCtrl(self.panelA, -1,
“panel A”, size=(125, -1))
self.panelB =
wx.Panel(self,pos=(60,60),size=(200,200),style=wx.DOUBLE_BORDER)
self.panelB.Bind(wx.EVT_LEFT_DOWN,
self.OnLeftClickB)
self.panelB.t1B = wx.TextCtrl(self.panelB, -1,
"panel B ", size=(125, -1))
def OnLeftClickA(self, event):
print "leftclick A"
self.panelA.t1A.SetValue(“A”+str(event.GetPosition()))
def OnLeftClickB(self, event):
print "Left Click B"
self.panelB.t1B.SetValue(“B”+str(event.GetPosition()))
class App(wx.App):
def OnInit(self):
myframe = frame()
myframe.Show()
return True
if name == ‘main’:
app = App()
app.MainLoop()
Norm