"""Create a modal dialog in OnInit that can be closed by the user.
"""
import wx

class MyFrame(wx.Frame):
    def __init__(self):
        wx.Frame.__init__(self, None, -1, 'Frame -- Test04_01', size=(200, 200))
        bf = wx.Button(self, -1, "frame", pos=(10,10))
        bd = wx.Button(self, -1, "dialog", pos=(10,80))
        bf.Bind(wx.EVT_BUTTON, self._MakeFrame)        
        bd.Bind(wx.EVT_BUTTON, self._MakeDialog)
        
    def _MakeFrame(self, evt):
        self.child_frame = MyChildFrame(self)
        self.child_frame.Iconize(False)
        self.child_frame.Show()
        self.child_frame.Raise()
    
    def _MakeDialog(self, evt):
        dialog = wx.MessageDialog(self, "does this fix it?", "can you see the frame?", wx.YES_NO | wx.ICON_QUESTION)
        dialog.ShowModal()
        dialog.Destroy()
        
class MyChildFrame(wx.Frame):
    def __init__(self, parent):
        wx.Frame.__init__(self, parent, -1, 'Child Frame', size=(300, 300))

class MyApp(wx.App):

    def OnInit(self):
        self.main_frame = MyFrame()
        self.main_frame.Show()
        self.SetTopWindow(self.main_frame)
        
        temp = FlashModal(self.main_frame)
        temp.ShowModal()        
        
        return True

class FlashModal(wx.Dialog):
    def __init__(self, parent):
        wx.Dialog.__init__(self, parent, -1, "kludge", size=(80,60))

if __name__=="__main__":
    app = MyApp(0)    
    app.MainLoop()
