I have a wx.Frame which I want to exactly fit one child Panel:
class DockingInfoFrame(DockingFrame):
def __init__(self, parent, title):
DockingFrame.__init__(self, parent, title=title)
self.childPanel = None
def ResizeToChild(self):
[logger.info](http://logger.info)("DockingInfoFrame re-sizing to child's size of %s" % (
self.childPanel.GetSize(),))
if self.childPanel:
self.SetClientSize(self.childPanel.GetSize())
def SetPanel(self, panel):
if self.childPanel is not None:
self.childPanel.Unbind(wx.EVT_SIZE, handler=self.OnChildSize)
self.RemoveChild(self.childPanel)
self.childPanel = panel
if self.childPanel is not None:
self.childPanel.Bind(wx.EVT_SIZE, self.OnChildSize)
self.ResizeToChild()
def OnChildSize(self, event):
logger.debug("DockingInfoFrame.OnChildSize fired with size %s",
event.GetSize())
event.Skip()
self.ResizeToChild()
In the child panel, I have some code where I calculate & set the size:
sizingLogger.debug("InfoPanel re-sizing to %s", (W, H))
self.SetSize((W, H))
This is what the logging output looks like:
gui.info_panel.sizing - DEBUG - InfoPanel re-sizing to (94, 245)
gui.GameFrame - DEBUG - DockingInfoFrame.OnChildSize fired with size (94, 245)
gui.GameFrame - INFO - DockingInfoFrame re-sizing to child’s size of (94, 245)
gui.GameFrame - DEBUG - DockingInfoFrame.OnChildSize fired with size (106, 245)
gui.GameFrame - INFO - DockingInfoFrame re-sizing to child’s size of (106, 245)
What seems to happen is that the .SetClientSize line is causing another child sizing event to be fired, this time with 12 extra pixels of width. This causes an ugly extra band on the panel which I want to remove. Why am I getting these extra pixels? Why is changing the client size of the Frame causing its child panel to get resized?
Thanks,
- Claudiu