| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -179,7 +179,6 @@ def OnVBoxSize(self, widget, data): | |||
| 179 | 179 | width = data.width | |
| 180 | 180 | height = data.height - self.menubar_height | |
| 181 | 181 | self.browser.SetBounds(x, y, width, height) | |
| 182 | - print("%s %s %s %s" % (x,y,width,height)) | ||
| 183 | 182 | ||
| 184 | 183 | def OnMenubarSize(self, widget, data): | |
| 185 | 184 | self.menubar_height = data.height | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -132,7 +132,11 @@ def __init__(self, url=None): | |||
| 132 | 132 | clientHandler._OnAfterCreated) | |
| 133 | 133 | ||
| 134 | 134 | 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]) | ||
| 136 | 140 | # Linux requires adding "file://" for local files, | |
| 137 | 141 | # otherwise /home/some will be replaced as http://home/some | |
| 138 | 142 | self.browser = cefpython.CreateBrowserSync( | |
@@ -176,12 +180,12 @@ def CreateMenu(self): | |||
| 176 | 180 | def OnClose(self, event): | |
| 177 | 181 | # In wx.chromectrl calling browser.CloseBrowser() and/or | |
| 178 | 182 | # 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 | ||
| 180 | 184 | # browser.ParentWindowWillClose. Behavior of this example | |
| 181 | 185 | # seems different as it extends wx.Frame, while ChromeWindow | |
| 182 | 186 | # from chromectrl extends wx.Window. Calling CloseBrowser | |
| 183 | 187 | # 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 | ||
| 185 | 189 | # also Issue 107. | |
| 186 | 190 | self.browser.ParentWindowWillClose() | |
| 187 | 191 | event.Skip() | |
@@ -206,9 +210,9 @@ def GoForward(self): | |||
| 206 | 210 | self.mainBrowser.GoForward() | |
| 207 | 211 | ||
| 208 | 212 | def CreateAnotherBrowser(self, url=None): | |
| 209 | - """ | ||
| 213 | + """ | ||
| 210 | 214 | TODO: There are errors in the console when closing the window: | |
| 211 | - >> Check failed: window | ||
| 215 | + >> Check failed: window | ||
| 212 | 216 | >> Gdk: _gdk_window_destroy_hierarchy: assertion `GDK_IS_WINDOW\ | |
| 213 | 217 | >> (window)' failed | |
| 214 | 218 | >> GLib-GObject: g_object_unref: assertion `G_IS_OBJECT (object)' failed | |
@@ -384,16 +388,19 @@ def OnConsoleMessage(self, browser, message, source, line): | |||
| 384 | 388 | ||
| 385 | 389 | def OnPreKeyEvent(self, browser, event, eventHandle, | |
| 386 | 390 | isKeyboardShortcutOut): | |
| 387 | - print("[wxpython.py] KeyboardHandler::OnPreKeyEvent()") | ||
| 388 | 391 | ||
| 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) | ||
| 397 | 404 | print(" modifiers=%s" % event["modifiers"]) | |
| 398 | 405 | print(" windows_key_code=%s" % event["windows_key_code"]) | |
| 399 | 406 | print(" native_key_code=%s" % event["native_key_code"]) | |
@@ -402,29 +409,9 @@ def OnKeyEvent(self, browser, event, eventHandle): | |||
| 402 | 409 | print(" unmodified_character=%s" % event["unmodified_character"]) | |
| 403 | 410 | print(" focus_on_editable_field=%s"\ | |
| 404 | 411 | % 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 | ||
| 428 | 415 | ||
| 429 | 416 | # ------------------------------------------------------------------------- | |
| 430 | 417 | # RequestHandler | |
@@ -562,7 +549,7 @@ def OnLoadEnd(self, browser, frame, httpStatusCode): | |||
| 562 | 549 | print(" http status code = %s" % httpStatusCode) | |
| 563 | 550 | # Tests for the Browser object methods | |
| 564 | 551 | self._Browser_LoadUrl(browser) | |
| 565 | - | ||
| 552 | + | ||
| 566 | 553 | def _Browser_LoadUrl(self, browser): | |
| 567 | 554 | if browser.GetUrl() == "data:text/html,Test#Browser.LoadUrl": | |
| 568 | 555 | browser.LoadUrl("file://"+GetApplicationPath("wxpython.html")) | |
@@ -731,7 +718,7 @@ def GetSources(): | |||
| 731 | 718 | # is set to True. It will force a separate renderer process | |
| 732 | 719 | # for each browser created using CreateBrowserSync. | |
| 733 | 720 | "unique_request_context_per_browser": True, | |
| 734 | - # Downloads are handled automatically. A default SaveAs file | ||
| 721 | + # Downloads are handled automatically. A default SaveAs file | ||
| 735 | 722 | # dialog provided by OS will be displayed. | |
| 736 | 723 | "downloads_enabled": True, | |
| 737 | 724 | # Remote debugging port, required for Developer Tools support. | |
@@ -759,7 +746,7 @@ def GetSources(): | |||
| 759 | 746 | # "file_access_from_file_urls_allowed": True, | |
| 760 | 747 | # "universal_access_from_file_urls_allowed": True, | |
| 761 | 748 | } | |
| 762 | - | ||
| 749 | + | ||
| 763 | 750 | # Command line switches set programmatically | |
| 764 | 751 | switches = { | |
| 765 | 752 | # "proxy-server": "socks5://127.0.0.1:8888", | |
@@ -769,12 +756,12 @@ def GetSources(): | |||
| 769 | 756 | # "disable-gpu": "", | |
| 770 | 757 | # "--invalid-switch": "" -> Invalid switch name | |
| 771 | 758 | } | |
| 772 | - | ||
| 759 | + | ||
| 773 | 760 | cefpython.Initialize(settings, switches) | |
| 774 | - | ||
| 761 | + | ||
| 775 | 762 | app = MyApp(False) | |
| 776 | 763 | app.MainLoop() | |
| 777 | 764 | # Let wx.App destructor do the cleanup before calling cefpython.Shutdown(). | |
| 778 | 765 | del app | |
| 779 | - | ||
| 766 | + | ||
| 780 | 767 | cefpython.Shutdown() | |
| Back | FazBrowse Home | New Git URL |
0 commit comments