Some err happened to me, when i use multiple panel, it's so strange!

I want add three Panel in frame with Sizer. but the last Panel appear in left-top:


________________________________________________
|*           |                  |               |         
|            |                  |               |            
|            |                  |               |
|            |                  |               |
|____________|__________________|_______________|

β€˜*’ is the lest Panel color.
But the err sometimes occer in run twice or more.

i upload image in my github:

Thank you for your help~

import wx


class MyForm(wx.Frame):
    def __init__(self):
        wx.Frame.__init__(self, None, wx.ID_ANY,
                          "Panel",
                          size=(800, 600))

        self.panel_one = wx.Panel(self, size=wx.DefaultSize,
                                  style=wx.SUNKEN_BORDER)
        self.panel_two = wx.Panel(self, size=wx.DefaultSize,
                                  style=wx.SUNKEN_BORDER)
        self.panel_three = wx.Panel(self, size=wx.DefaultSize,
                                    style=wx.SUNKEN_BORDER)
        
        self.panel_one.SetBackgroundColour("#6495ED")
        self.panel_two.SetBackgroundColour("#191970")
        self.panel_three.SetBackgroundColour("#F8F8FF")

        self.sizer = wx.BoxSizer(wx.HORIZONTAL)
        self.sizer.Add(self.panel_one, 1, wx.EXPAND)
        self.sizer.Add(self.panel_two, 1, wx.EXPAND)
        self.sizer.Add(self.panel_three, 1, wx.EXPAND)
        self.SetSizer(self.sizer)


if __name__ == "__main__":
    app = wx.App(False)
    frame = MyForm()
    frame.Show()
    app.MainLoop()

It works for me. OpenSuse 15.1, python 3.6, wxPython 4.0.7

when i run it twice, the err occur. win 10, python 3.7, wxPython 4.0.7
i upload image to my github.
thank for your help.

When you say β€œrun it twice” is that two separate invocations from the command line? Or are you running it twice inside a single Python environment, such as from a Python interactive environment, IPython, or some IDE?

1 Like

i only run this .py file twice or more in pycharm.
pycharm 2019 2.3 community edition.
Is it work for you?