Python Forum
Why is wx.NO_BORDER changing panels within a frame
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Why is wx.NO_BORDER changing panels within a frame
#1
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.



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()
Reply


Messages In This Thread
Why is wx.NO_BORDER changing panels within a frame - by MeghansUncle2 - Jul-12-2020, 02:56 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  [Tkinter] Trouble changing Font within tkinter frame title AnotherSam 1 4,352 Sep-30-2021, 05:57 PM
Last Post: menator01
  [Tkinter] Tkinter delete values in Entries, when I'm changing the Frame robertoCarlos 11 6,122 Jul-29-2020, 07:13 PM
Last Post: deanhystad
  [Tkinter] changing the frame colour nick123 4 16,904 Jul-24-2020, 07:32 AM
Last Post: LegacyCoding
  [Tkinter] Scrollbar, Frame and size of Frame Maksim 2 9,220 Sep-30-2019, 07:30 AM
Last Post: Maksim
  [Tkinter] create and insert a new frame on top of another frame atlass218 4 11,428 Apr-18-2019, 05:36 PM
Last Post: atlass218
  [Tkinter] Frame size only works if frame is empty(Solved) Tuck12173 7 6,664 Jan-29-2018, 10:44 PM
Last Post: Larz60+

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020