Jul-12-2020, 02:56 AM
(This post was last modified: Jul-12-2020, 02:57 AM by MeghansUncle2.)
In the code below (within wx.Frame.__init__) when I add "style=wx.NO_BORDER" the panels shrink to almost nothing.
Please run with and without this style to see the difference. Can anyone explain this behavior? I am learning Python and this behavior seems to me to be in error. I would like to understand why this is happening so that I can prevent it.
Please run with and without this style to see the difference. Can anyone explain this behavior? I am learning Python and this behavior seems to me to be in error. I would like to understand why this is happening so that I can prevent it.
import wx ######################################################################## class RandomPanel(wx.Panel): """""" #---------------------------------------------------------------------- def __init__(self, parent, color): """Constructor""" wx.Panel.__init__(self, parent) self.SetBackgroundColour(color) ######################################################################## class MainPanel(wx.Panel): """""" #---------------------------------------------------------------------- def __init__(self, parent): """Constructor""" wx.Panel.__init__(self, parent) topSplitter = wx.SplitterWindow(self) hSplitter = wx.SplitterWindow(topSplitter) panelOne = RandomPanel(hSplitter, "blue") panelTwo = RandomPanel(hSplitter, "red") hSplitter.SplitVertically(panelOne, panelTwo) hSplitter.SetSashGravity(0.7) panelThree = RandomPanel(topSplitter, "green") topSplitter.SplitHorizontally(hSplitter, panelThree) topSplitter.SetSashGravity(0.5) sizer = wx.BoxSizer(wx.VERTICAL) sizer.Add(topSplitter, 1, wx.EXPAND) self.SetSizer(sizer) ######################################################################## class MainFrame(wx.Frame): """""" #---------------------------------------------------------------------- def __init__(self): """Constructor""" wx.Frame.__init__(self, None, title="", size=(800,600), style=wx.NO_BORDER) panel = MainPanel(self) self.Show() #---------------------------------------------------------------------- if __name__ == "__main__": app = wx.App(False) frame = MainFrame() app.MainLoop()