Python - multiple windows (frames)

Below example show how to create 2 frames after clicking on a button.
Simple constructor wx.Frame creates an object.
wx.Frame.Show(..) - shows an object.

top1file.py

import wx
import wx.lib.dialogs
import fr2
import fr3
 
class Top1file(wx.Frame):
    def __init__(self, parent):
        wx.Frame.__init__(self, id=-1, parent=parent, size=wx.Size(500, 400), title='Top1file')
        self.panel1 = wx.Panel(self, id=-1)
 
        self.button1 = wx.Button(self.panel1, id=-1, label='button1', pos=wx.Point(96, 56), size=wx.Size(87, 28), style=0)
        self.button2 = wx.Button(self.panel1, id=-1, label='button2', pos=wx.Point(96, 104), size=wx.Size(87, 28), style=0)
 
        self.button1.Bind(wx.EVT_BUTTON, self.OnButton1Button, id=-1)
        self.button2.Bind(wx.EVT_BUTTON, self.OnButton2Button, id=-1)        
 
    def OnButton1Button(self, event):
        self.frame2 = wx.Frame(self, id=-1, size=wx.Size(500, 400), title='Frame2') # Create frame
        self.frame2.Show() # Show frame
        event.Skip()
 
    def OnButton2Button(self, event):
        self.frame3 = wx.Frame(self, id=-1, size=wx.Size(500, 400), title='Frame3') # Create frame
        self.frame3.Show() # Show frame
        event.Skip()
 
if __name__ == '__main__':
    app = wx.PySimpleApp()
    frame = Top1file(None)
    frame.Show()
 
    app.MainLoop()

Version with 3 files:

This version is not much different. Top file is almost the same as
previous top1file.py. However now - instead of creating objects
wx.Frame - we create Frame2 object (from file fr2.py) and Frame3 (from file fr3.py).
The trick here is that Frame2 and Frame3 are both children of wx.Frame,
extending its functionalities.

top.py:

import wx
import wx.lib.dialogs
import fr2
import fr3
 
class Top(wx.Frame):
    def __init__(self, parent):
        wx.Frame.__init__(self, id=-1, parent=parent, size=wx.Size(500, 400), title='Top')
        self.panel1 = wx.Panel(self, id=-1)
 
        self.button1 = wx.Button(self.panel1, id=-1, label='button1', pos=wx.Point(96, 56), size=wx.Size(87, 28), style=0)
        self.button2 = wx.Button(self.panel1, id=-1, label='button2', pos=wx.Point(96, 104), size=wx.Size(87, 28), style=0)
 
        self.button1.Bind(wx.EVT_BUTTON, self.OnButton1Button, id=-1)
        self.button2.Bind(wx.EVT_BUTTON, self.OnButton2Button, id=-1)        
 
    def OnButton1Button(self, event):
        self.frame2 = fr2.create(self)
        self.frame2.Show()
        event.Skip()
 
    def OnButton2Button(self, event):
        self.frame3 = fr3.create(self)
        self.frame3.Show()
        event.Skip()
 
if __name__ == '__main__':
    app = wx.PySimpleApp()
    frame = Top(None)
    frame.Show()
 
    app.MainLoop()

fr2.py:

import wx
 
def create(parent):
    return Frame2(parent)
 
class Frame2(wx.Frame):
    def __init__(self, prnt):
        # generated method, don't edit
        wx.Frame.__init__(self, id=-1, parent=prnt, title='Frame2')
        self.panel1 = wx.Panel(self, id=-1, size=wx.Size(100, 100))
        wx.StaticText(self.panel1, id=-1, label='Hello from Frame2', pos=wx.Point(10, 10))

fr3.py:

import wx
 
def create(parent):
    return Frame3(parent)
 
class Frame3(wx.Frame):
    def __init__(self, prnt):
        wx.Frame.__init__(self, id=-1, name='', parent=prnt, title='Frame3')
        self.panel1 = wx.Panel(self, id=-1, size=wx.Size(50, 50))
        wx.StaticText(self.panel1, id=-1, label='Hello from Frame3', pos=wx.Point(12, 10))