33
44# To install wxPython on Linux type "sudo apt-get install python-wxtools".
55
6- # Tested with wxPython 2.8 on Linux, wxPython 3.0 on Windows/Mac
7- # and CEF Python v55.3+.
6+ # Tested configurations:
7+ # - wxPython 2.8 on Linux
8+ # - wxPython 3.0.2.0 msw (classic) on Windows
9+ # - wxPython 3.0 on Mac
10+ # - CEF Python v55.3+
811
912import wx
1013from cefpython3 import cefpython as cef
@@ -28,7 +31,7 @@ def main():
2831 settings ["auto_zooming" ] = "system_dpi"
2932 # Embed DPI awareness xml manifest inside .exe (recommended,
3033 # most reliable) or call the SetProcessDpiAware function.
31- # noinspection PyUnresolvedReferences
34+ # noinspection PyUnresolvedReferences, PyArgumentList
3235 cef .DpiAware .SetProcessDpiAware ()
3336 cef .Initialize (settings = settings )
3437 app = CefApp (False )
@@ -40,7 +43,7 @@ def main():
4043def check_versions ():
4144 print ("[wxpython.py] CEF Python {ver}" .format (ver = cef .__version__ ))
4245 print ("[wxpython.py] Python {ver}" .format (ver = sys .version [:6 ]))
43- print ("[wxpython.py] wx {ver}" .format (ver = wx .version ()))
46+ print ("[wxpython.py] wxPython {ver}" .format (ver = wx .version ()))
4447 # CEF Python version requirement
4548 assert cef .__version__ >= "55.3" , "CEF Python v55.3+ required to run this"
4649
@@ -75,11 +78,10 @@ def setup_icon(self):
7578
7679 def create_menu (self ):
7780 filemenu = wx .Menu ()
78- filemenu .Append (1 , "Open" )
79- exit_ = filemenu .Append (2 , "Exit" )
80- self .Bind (wx .EVT_MENU , self .OnClose , exit_ )
81+ filemenu .Append (1 , "Some option" )
82+ exit_ = filemenu .Append (2 , "Another option" )
8183 aboutmenu = wx .Menu ()
82- aboutmenu .Append (1 , "CEF Python " )
84+ aboutmenu .Append (1 , "Yet another option " )
8385 menubar = wx .MenuBar ()
8486 menubar .Append (filemenu , "&File" )
8587 menubar .Append (aboutmenu , "&About" )
@@ -93,23 +95,24 @@ def embed_browser(self):
9395 self .browser .SetClientHandler (FocusHandler ())
9496
9597 def OnSetFocus (self , _ ):
96- if not self .brower :
98+ if not self .browser :
9799 return
98100 if WINDOWS :
99101 # noinspection PyUnresolvedReferences
100- cef .WindowUtils .OnSetFocus (self .GetHandleForBrowser (), 0 , 0 , 0 )
102+ cef .WindowUtils .OnSetFocus (self .browser_panel .GetHandle (),
103+ 0 , 0 , 0 )
101104 self .browser .SetFocus (True )
102105
103106 def OnSize (self , _ ):
104107 if not self .browser :
105108 return
106109 if WINDOWS :
107110 # noinspection PyUnresolvedReferences
108- cef .WindowUtils .OnSize (self .GetHandleForBrowser (), 0 , 0 , 0 )
111+ cef .WindowUtils .OnSize (self .browser_panel .GetHandle (),
112+ 0 , 0 , 0 )
109113 elif LINUX :
110114 (x , y ) = (0 , 0 )
111115 (width , height ) = self .browser_panel .GetSizeTuple ()
112- # noinspection PyUnresolvedReferences
113116 self .browser .SetBounds (x , y , width , height )
114117 self .browser .NotifyMoveOrResizeStarted ()
115118
@@ -154,9 +157,10 @@ def OnGotFocus(self, browser, **_):
154157 # window (alt+tab) and then back to this example, keyboard
155158 # focus becomes broken, you can't type anything, even
156159 # though a type cursor blinks in web view.
157- print ("[wxpython.py] FocusHandler.OnGotFocus:"
158- " keyboard focus fix (#284)" )
159- browser .SetFocus (True )
160+ if LINUX :
161+ print ("[wxpython.py] FocusHandler.OnGotFocus:"
162+ " keyboard focus fix (#284)" )
163+ browser .SetFocus (True )
160164
161165
162166class CefApp (wx .App ):
0 commit comments