Fix for collapsible stats panels

This commit is contained in:
blitzmann
2014-11-08 18:17:57 -05:00
parent 198ee8d129
commit ff55f2817b

View File

@@ -146,7 +146,6 @@ class TogglePanel ( wx.Panel ):
else: else:
return True return True
def IsExpanded(self): def IsExpanded(self):
""" Returns ``True`` if the pane window is currently shown. """ """ Returns ``True`` if the pane window is currently shown. """
if self._toggle == 1: if self._toggle == 1:
@@ -154,7 +153,6 @@ class TogglePanel ( wx.Panel ):
else: else:
return True return True
def OnStateChange(self, sz): def OnStateChange(self, sz):
""" """
Handles the status changes (collapsing/expanding). Handles the status changes (collapsing/expanding).
@@ -168,9 +166,8 @@ class TogglePanel ( wx.Panel ):
self.parent.GetSizer().SetSizeHints(self.parent) self.parent.GetSizer().SetSizeHints(self.parent)
if self.IsCollapsed(): if self.IsCollapsed():
# expanded . collapsed transition # expanded . collapsed transition
if self.parent.GetSizer(): if self.parent.GetSizer():
# we have just set the size hints... # we have just set the size hints...
sz = self.parent.GetSizer().CalcMin() sz = self.parent.GetSizer().CalcMin()
@@ -178,39 +175,36 @@ class TogglePanel ( wx.Panel ):
# use SetClientSize() and not SetSize() otherwise the size for # use SetClientSize() and not SetSize() otherwise the size for
# e.g. a wxFrame with a menubar wouldn't be correctly set # e.g. a wxFrame with a menubar wouldn't be correctly set
self.parent.SetClientSize(sz) self.parent.SetClientSize(sz)
else: else:
self.parent.Layout() self.parent.Layout()
else: else:
# collapsed . expanded transition
# collapsed . expanded transition # force our parent to "fit", i.e. expand so that it can honour
# our minimal size
# force our parent to "fit", i.e. expand so that it can honour
# our minimal size
self.parent.Fit() self.parent.Fit()
# Toggle the content panel (hide/show) # Toggle the content panel (hide/show)
def toggleContent(self, event):
def toggleContent( self, event ):
self.Freeze() self.Freeze()
print self.contentPanel.GetSize()
if self._toggle == 1: if self._toggle == 1:
self.contentMinSize = self.contentPanel.GetSize() self.contentMinSize = self.contentPanel.GetSize()
self.contentPanel.SetMinSize(wx.Size(self.contentMinSize[0],0)) self.contentPanel.Hide()
self.headerBmp.SetBitmap( self.bmpCollapsed) self.headerBmp.SetBitmap(self.bmpCollapsed)
else: else:
self.contentPanel.SetMinSize(self.contentMinSize) self.contentPanel.Show()
self.headerBmp.SetBitmap(self.bmpExpanded)
self.headerBmp.SetBitmap( self.bmpExpanded)
self._toggle *=-1
self._toggle *= -1
self.Layout()
self.Thaw() self.Thaw()
if self.forceLayout == -1: if self.forceLayout == -1:
self.OnStateChange(self.GetBestSize()) if wx.VERSION >= (3, 0):
x, y = self.GetBestSize()
y -= self.contentPanel.GetSize()[1]
else:
x, y = self.GetBestSize()
self.OnStateChange((x, y))
else: else:
self.parent.Layout() self.parent.Layout()