import wx

class MyDialog(wx.Dialog):
    def __init__(self, *args, **kwargs):
        pre = wx.PreDialog()
        #style = pre.GetExtraStyle()
        #pre.SetExtraStyle(style & ~wx.WS_EX_BLOCK_EVENTS)
        pre.Create(*args, **kwargs)
        self.PostCreate(pre)        
        

class MyFrame(wx.Frame):
    def __init__(self, *args, **kwargs):
        wx.Frame.__init__(self, *args, **kwargs)
        panel = wx.Panel(self, -1)
        framebtn = wx.Button(panel, -1, "new frame")        
        dlgbtn = wx.Button(panel, -1, "modal dailog")
        filebtn = wx.Button(panel, -1, "file open")
        framebtn.SetPosition((15, 20))
        dlgbtn.SetPosition((15, 60))
        filebtn.SetPosition((15, 100))
        self.Bind(wx.EVT_BUTTON, self.NewFrame, framebtn)
        self.Bind(wx.EVT_BUTTON, self.ModalDlg, dlgbtn)
        self.Bind(wx.EVT_BUTTON, self.FileDlg, filebtn)
        
        
    def NewFrame(self, event):
        new_frame()

    def ModalDlg(self, event):
        dlg = MyDialog(self, -1, 'MODAL DIALOG')
        if dlg.ShowModal() == wx.ID_OK:
            wx.Bell()        
        dlg.Destroy()            
        
    def FileDlg(self, event):
        dlg = wx.FileDialog(
            self,
            message='Choose a file',
            defaultDir='',
            defaultFile='',
            wildcard='',
            style=wx.OPEN | wx.CHANGE_DIR | wx.FILE_MUST_EXIST
            )
        if dlg.ShowModal() == wx.ID_OK:
            wx.Bell()
        dlg.Destroy()                

def new_frame():
    frame = MyFrame(None, -1, 'test') 
    frame.Show()
    wx.GetApp().SetTopWindow(frame)
        
app = wx.PySimpleApp()
new_frame()
new_frame()
app.MainLoop()