Skip to content

Commit 57282f6

Browse files
committed
Update wxpython.py - it runs, but with issues (resize and probably more)
1 parent d21c2b5 commit 57282f6

File tree

2 files changed

+30
-44
lines changed

2 files changed

+30
-44
lines changed

src/linux/binaries_64bit/pygtk_.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,6 @@ def OnVBoxSize(self, widget, data):
179179
width = data.width
180180
height = data.height - self.menubar_height
181181
self.browser.SetBounds(x, y, width, height)
182-
print("%s %s %s %s" % (x,y,width,height))
183182

184183
def OnMenubarSize(self, widget, data):
185184
self.menubar_height = data.height

src/linux/binaries_64bit/wxpython.py

Lines changed: 30 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,11 @@ def __init__(self, url=None):
132132
clientHandler._OnAfterCreated)
133133

134134
windowInfo = cefpython.WindowInfo()
135-
windowInfo.SetAsChild(self.mainPanel.GetGtkWidget())
135+
# Must show window otherwise GetHandle() returns 0
136+
self.Show()
137+
cefpython.WindowUtils.InstallX11ErrorHandlers()
138+
windowInfo.SetAsChild(self.mainPanel.GetHandle(),
139+
[0,0,0,0])
136140
# Linux requires adding "file://" for local files,
137141
# otherwise /home/some will be replaced as http://home/some
138142
self.browser = cefpython.CreateBrowserSync(
@@ -176,12 +180,12 @@ def CreateMenu(self):
176180
def OnClose(self, event):
177181
# In wx.chromectrl calling browser.CloseBrowser() and/or
178182
# self.Destroy() in OnClose is causing crashes when embedding
179-
# multiple browser tabs. The solution is to call only
183+
# multiple browser tabs. The solution is to call only
180184
# browser.ParentWindowWillClose. Behavior of this example
181185
# seems different as it extends wx.Frame, while ChromeWindow
182186
# from chromectrl extends wx.Window. Calling CloseBrowser
183187
# and Destroy does not cause crashes, but is not recommended.
184-
# Call ParentWindowWillClose and event.Skip() instead. See
188+
# Call ParentWindowWillClose and event.Skip() instead. See
185189
# also Issue 107.
186190
self.browser.ParentWindowWillClose()
187191
event.Skip()
@@ -206,9 +210,9 @@ def GoForward(self):
206210
self.mainBrowser.GoForward()
207211

208212
def CreateAnotherBrowser(self, url=None):
209-
"""
213+
"""
210214
TODO: There are errors in the console when closing the window:
211-
>> Check failed: window
215+
>> Check failed: window
212216
>> Gdk: _gdk_window_destroy_hierarchy: assertion `GDK_IS_WINDOW\
213217
>> (window)' failed
214218
>> GLib-GObject: g_object_unref: assertion `G_IS_OBJECT (object)' failed
@@ -384,16 +388,19 @@ def OnConsoleMessage(self, browser, message, source, line):
384388

385389
def OnPreKeyEvent(self, browser, event, eventHandle,
386390
isKeyboardShortcutOut):
387-
print("[wxpython.py] KeyboardHandler::OnPreKeyEvent()")
388391

389-
def OnKeyEvent(self, browser, event, eventHandle):
390-
if event["type"] == cefpython.KEYEVENT_KEYUP:
391-
# OnKeyEvent is called twice for F5/Esc keys, with event
392-
# type KEYEVENT_RAWKEYDOWN and KEYEVENT_KEYUP.
393-
# Normal characters a-z should have KEYEVENT_CHAR.
394-
return False
395-
print("[wxpython.py] KeyboardHandler::OnKeyEvent()")
396-
print(" type=%s" % event["type"])
392+
stype = event["type"]
393+
if stype == cefpython.KEYEVENT_RAWKEYDOWN:
394+
stype = "RAWKEYDOWN"
395+
elif stype == cefpython.KEYEVENT_KEYDOWN:
396+
stype = "KEYDOWN"
397+
elif stype == cefpython.KEYEVENT_KEYUP:
398+
stype = "KEYUP"
399+
elif stype == cefpython.KEYEVENT_CHAR:
400+
stype = "CHAR"
401+
402+
print("[wxpython.py] KeyboardHandler::OnPreKeyEvent()")
403+
print(" type=%s" % stype)
397404
print(" modifiers=%s" % event["modifiers"])
398405
print(" windows_key_code=%s" % event["windows_key_code"])
399406
print(" native_key_code=%s" % event["native_key_code"])
@@ -402,29 +409,9 @@ def OnKeyEvent(self, browser, event, eventHandle):
402409
print(" unmodified_character=%s" % event["unmodified_character"])
403410
print(" focus_on_editable_field=%s"\
404411
% event["focus_on_editable_field"])
405-
if platform.system() == "Linux":
406-
# F5
407-
if event["native_key_code"] == 71:
408-
print("[wxpython.py] F5 pressed, calling"\
409-
" browser.ReloadIgnoreCache()")
410-
browser.ReloadIgnoreCache()
411-
return True
412-
# Escape
413-
if event["native_key_code"] == 9:
414-
print("[wxpython.py] Esc pressed, calling browser.StopLoad()")
415-
browser.StopLoad()
416-
return True
417-
# F12
418-
if event["native_key_code"] == 96:
419-
print("[wxpython.py] F12 pressed, calling"\
420-
" browser.ShowDevTools()")
421-
browser.ShowDevTools()
422-
return True
423-
elif platform.system() == "Windows":
424-
# F5 todo
425-
# Escape todo
426-
pass
427-
return False
412+
413+
def OnKeyEvent(self, browser, event, eventHandle):
414+
pass
428415

429416
# -------------------------------------------------------------------------
430417
# RequestHandler
@@ -562,7 +549,7 @@ def OnLoadEnd(self, browser, frame, httpStatusCode):
562549
print(" http status code = %s" % httpStatusCode)
563550
# Tests for the Browser object methods
564551
self._Browser_LoadUrl(browser)
565-
552+
566553
def _Browser_LoadUrl(self, browser):
567554
if browser.GetUrl() == "data:text/html,Test#Browser.LoadUrl":
568555
browser.LoadUrl("file://"+GetApplicationPath("wxpython.html"))
@@ -731,7 +718,7 @@ def GetSources():
731718
# is set to True. It will force a separate renderer process
732719
# for each browser created using CreateBrowserSync.
733720
"unique_request_context_per_browser": True,
734-
# Downloads are handled automatically. A default SaveAs file
721+
# Downloads are handled automatically. A default SaveAs file
735722
# dialog provided by OS will be displayed.
736723
"downloads_enabled": True,
737724
# Remote debugging port, required for Developer Tools support.
@@ -759,7 +746,7 @@ def GetSources():
759746
# "file_access_from_file_urls_allowed": True,
760747
# "universal_access_from_file_urls_allowed": True,
761748
}
762-
749+
763750
# Command line switches set programmatically
764751
switches = {
765752
# "proxy-server": "socks5://127.0.0.1:8888",
@@ -769,12 +756,12 @@ def GetSources():
769756
# "disable-gpu": "",
770757
# "--invalid-switch": "" -> Invalid switch name
771758
}
772-
759+
773760
cefpython.Initialize(settings, switches)
774-
761+
775762
app = MyApp(False)
776763
app.MainLoop()
777764
# Let wx.App destructor do the cleanup before calling cefpython.Shutdown().
778765
del app
779-
766+
780767
cefpython.Shutdown()

0 commit comments

Comments
 (0)