It looks like the RAISED_BORDER removes 3 pixels from each side of the panel. I can MouseOver all the pixels when there is no RAISED_BORDER. So just set your size to be (66,66) if you want to keep the border.
-Paul
···
From: Peter Schmitt [mailto:pschmittml@gmail.com]
Sent: Friday, October 06, 2006 1:05 PM
To: wxpython-users@lists.wxwidgets.org
Subject:
[wxPython-users] SetSizeHints issues
I have a 60x60 panel and an event handler to display the mouse’s (x,y) coordinates over the panel
When the position of the 60x60 panel is set manually (i.e. pos=(0,0)), the (x,y) coordinates are displayed properly.
However, if I do not specify the exact position of the sizer, and instead include it to a GridBagSizer, I cannot “mouseover” the last few x and y coordinates… In other words, part of my panel chopped off when I set my layout up with a GridBagSizer (or any other sizer for that matter)
Someone on freenode: #wxwidgets suggested using sizer.SetSizeHints(self.panel), but that didn’t work…
How do I prevent a sizer from chopping off part of my panel? Here’s a simple wxPython example that shows only lets me mouseover panels that are 55x55 pixels big.
Thanks,
Pete#######################################
#EXAMPLE:
#######################################
import wxclass theFrame(wx.Frame):
def init(self):
wx.Frame._init _(self,None, -1, “Color Gradient Editor”, wx.DefaultPosition, [150,150])#create panels, set background colors... self.panel = wx.Panel(self) topleft = wx.Panel(self.panel, size= wx.Size(60,60), style=wx.RAISED_BORDER) topleft.SetBackgroundColour(wx.Colour(255,0,0)) botright = wx.Panel(self.panel, size=wx.Size(60,60), style=wx.RAISED_BORDER) botright.SetBackgroundColour (wx.Colour(0,255,0)) #add to sizer. sizer = wx.GridBagSizer(2,2) sizer.Add(topleft, pos=(0,0)) sizer.Add(botright, pos=(1,1)) sizer.Fit(self.panel) sizer.SetSizeHints(self.panel) self.panel.SetSizer(sizer) self.CreateStatusBar() #event handler wx.EVT_MOTION(topleft, self.on_mouse_move) wx.EVT_MOTION(botright, self.on_mouse_move) def on_mouse_move(self, event): screenX = event.GetX() screenY = event.GetY() self.SetStatusText("%d, %d"%(screenX, screenY))
app = wx.PySimpleApp ()
frame = theFrame()
frame.Show()
app.MainLoop()