| 9 | import platform |
| 10 | |
| 11 | class MainFrame(wx.Frame): |
| 12 | def __init__(self): |
| 13 | wx.Frame.__init__(self, parent=None, id=wx.ID_ANY, |
| 14 | title='cefwx example1', size=(800,600)) |
| 15 | |
| 16 | self.cefWindow = chrome.ChromeWindow(self, |
| 17 | url=os.path.join(os.path.dirname(os.path.abspath(__file__)), |
| 18 | "sample1.html")) |
| 19 | |
| 20 | sizer = wx.BoxSizer() |
| 21 | sizer.Add(self.cefWindow, 1, wx.EXPAND, 0) |
| 22 | self.SetSizer(sizer) |
| 23 | |
| 24 | self.Bind(wx.EVT_CLOSE, self.OnClose) |
| 25 | |
| 26 | def OnClose(self, event): |
| 27 | # Remember to destroy all CEF browser references before calling |
| 28 | # Destroy(), so that browser closes cleanly. In this specific |
| 29 | # example there are no references kept, but keep this in mind |
| 30 | # for the future. |
| 31 | self.Destroy() |
| 32 | # On Mac the code after app.MainLoop() never executes, so |
| 33 | # need to call CEF shutdown here. |
| 34 | if platform.system() == "Darwin": |
| 35 | chrome.Shutdown() |
| 36 | wx.GetApp().Exit() |
| 37 | |
| 38 | class MyApp(wx.App): |
| 39 | def OnInit(self): |