title: wx Python fitting screen to controls
body: <p>This is driving me mad. Got a simple screen, but it will not fit and show all of the controls. What am I doing wrong?</p>
  
  <p>[EDIT]I am running this on Ubuntu 16.4, Python 3.5.3, wx.Python 4.0.0b2 gtk2 (phoenix)[\EDIT]</p>
  
  <pre><code>import wx
  
  class MainEdit(wx.Frame):
      def __init__(self, parent=None, title="Main Edit"):
          wx.Frame.__init__(self, parent, -1, title=title)
          panel = MainPanel(self)
          self.Fit()
  
  
  class MainPanel(wx.Panel):
      def __init__(self, frame):
          wx.Panel.__init__(self, frame)
          txt_size = (300, 150)
          txt_style = wx.VSCROLL|wx.HSCROLL|wx.BORDER_SIMPLE|wx.TE_MULTILINE
          self.txt_A = wx.TextCtrl(self, size=txt_size, style=txt_style)
          self.txt_B = wx.TextCtrl(self, size=txt_size, style=txt_style)
          cmd_refresh = wx.Button(self, wx.ID_REFRESH)
  
          main_sizer = wx.BoxSizer(wx.VERTICAL)
          main_sizer.Add(self.txt_A, flag=wx.ALL, border=10)
          main_sizer.Add(self.txt_B, flag=wx.ALL, border=10)
          main_sizer.Add(cmd_refresh, flag=wx.ALL, border=10)
          self.SetSizerAndFit(main_sizer)
  
  if __name__ == '__main__':
      app = wx.App()
      frame = MainEdit()
      frame.Show()
      app.MainLoop()
  </code></pre>
  
  <p>[EDIT 2017 11 02 to show image]</p>
  
  <p>This is the effect I get</p>
  
  <p><a href="https://i.stack.imgur.com/lHvH9.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/lHvH9.png" alt="enter image description here"></a></p>
  
  <p>[\EDIT]</p>
  
  <p>[EDIT 2017 11 03 11:20]This is the output when I change the code to Rolf's suggestion</p>
  
  <pre><code>11:18:29: Debug: ClientToScreen cannot work when toplevel window is not shown
  1 (0, 0, 20, 20)
  11:18:29: Debug: ClientToScreen cannot work when toplevel window is not shown
  2 (0, 0, 320, 389)
  3 (0, 0, 400, 250)
  </code></pre>
  
  <p>The screen is still truncated</p>
  
  <p>[/EDIT]</p>
  
  <p>[\EDIT 2017 11 04 09:20]
  The following code works:</p>
  
  <pre><code>import wx
  
  class MainEdit(wx.Frame):
      def __init__(self, parent=None, title="Main Edit"):
          wx.Frame.__init__(self, parent, -1, title=title)
          txt_size = (300, 150)
          txt_style = wx.VSCROLL|wx.HSCROLL|wx.BORDER_SIMPLE|wx.TE_MULTILINE
          self.txt_A = wx.TextCtrl(self, size=txt_size, style=txt_style)
          self.txt_B = wx.TextCtrl(self, size=txt_size, style=txt_style)
          cmd_refresh = wx.Button(self, wx.ID_REFRESH)
  
          main_sizer = wx.BoxSizer(wx.VERTICAL)
          main_sizer.Add(self.txt_A, flag=wx.ALL, border=10)
          main_sizer.Add(self.txt_B, flag=wx.ALL, border=10)
          main_sizer.Add(cmd_refresh, flag=wx.ALL, border=10)
          self.SetSizerAndFit(main_sizer)
  
  
  if __name__ == '__main__':
      app = wx.App()
      frame = MainEdit()
      frame.Show()
      app.MainLoop()
  </code></pre>
  
  <p>As you can see I have removed the panel. However, I was told <a href="https://i.stack.imgur.com/lHvH9.png" rel="nofollow noreferrer">here</a> that "The frame should only have one child, a panel."</p>
  
  <p>So what is the recommended way of structuring a wxPython program?[/EDIT]</p>