Skip to content

Commit 79399ba

Browse files
CzarekCzarek
authored andcommitted
The "Exit" in the menu now exits the application in the wxpython.py
script. The menu did not appear on Linux, it is required to put the browser into some container, the gtk widget of the main frame cannot be used to embed browser if the main frame needs to have a menu.
1 parent 5f74be8 commit 79399ba

4 files changed

Lines changed: 14 additions & 6 deletions

File tree

cefpython/cef1/linux/binaries_32bit/wxpython.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,8 @@ def __init__(self):
107107
def CreateMenu(self):
108108
filemenu = wx.Menu()
109109
filemenu.Append(1, "Open")
110-
filemenu.Append(2, "Exit")
110+
exit = filemenu.Append(2, "Exit")
111+
self.Bind(wx.EVT_MENU, self.OnClose, exit)
111112
aboutmenu = wx.Menu()
112113
aboutmenu.Append(1, "CEF Python")
113114
menubar = wx.MenuBar()

cefpython/cef1/linux/binaries_64bit/wxpython.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -74,15 +74,19 @@ class MainFrame(wx.Frame):
7474
browser = None
7575
initialized = False
7676
idleCount = 0
77-
box = None
77+
mainPanel = None
7878

7979
def __init__(self):
8080
wx.Frame.__init__(self, parent=None, id=wx.ID_ANY,
8181
title='wxPython example', size=(800,600))
8282
self.CreateMenu()
8383

84+
# Cannot attach browser to the main frame as this will cause
85+
# the menu not to work.
86+
self.mainPanel = wx.Panel(self)
87+
8488
windowInfo = cefpython.WindowInfo()
85-
windowInfo.SetAsChild(self.GetGtkWidget())
89+
windowInfo.SetAsChild(self.mainPanel.GetGtkWidget())
8690
# Linux requires adding "file://" for local files,
8791
# otherwise /home/some will be replaced as http://home/some
8892
self.browser = cefpython.CreateBrowserSync(
@@ -107,7 +111,8 @@ def __init__(self):
107111
def CreateMenu(self):
108112
filemenu = wx.Menu()
109113
filemenu.Append(1, "Open")
110-
filemenu.Append(2, "Exit")
114+
exit = filemenu.Append(2, "Exit")
115+
self.Bind(wx.EVT_MENU, self.OnClose, exit)
111116
aboutmenu = wx.Menu()
112117
aboutmenu.Append(1, "CEF Python")
113118
menubar = wx.MenuBar()

cefpython/cef1/windows/binaries/wxpython.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,8 @@ def __init__(self):
8383
def CreateMenu(self):
8484
filemenu = wx.Menu()
8585
filemenu.Append(1, "Open")
86-
filemenu.Append(2, "Exit")
86+
exit = filemenu.Append(2, "Exit")
87+
self.Bind(wx.EVT_MENU, self.OnClose, exit)
8788
aboutmenu = wx.Menu()
8889
aboutmenu.Append(1, "CEF Python")
8990
menubar = wx.MenuBar()

cefpython/cef3/windows/binaries/wxpython.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,8 @@ def __init__(self):
8383
def CreateMenu(self):
8484
filemenu = wx.Menu()
8585
filemenu.Append(1, "Open")
86-
filemenu.Append(2, "Exit")
86+
exit = filemenu.Append(2, "Exit")
87+
self.Bind(wx.EVT_MENU, self.OnClose, exit)
8788
aboutmenu = wx.Menu()
8889
aboutmenu.Append(1, "CEF Python")
8990
menubar = wx.MenuBar()

0 commit comments

Comments
 (0)