cefpython

Back button in cefpython3


I am trying to convert a web application into a desktop application by embedding cefpython3.

The application (sometimes) requires the back button for navigation. Is there a simple way (ie without requiring another graphics framework like Qt) to get it?

Note: It seems that Shift+Backspace and Alt+Right Arrow don't work also.


Solution

  • If you have control over the web application then you can implement back/forward buttons using HTML5 and Javascript. When button is clicked use javascript bindings to communicate with Python and call appropriate CEF functions such as Browser.GoForward and Browser.GoBack. In case of third party web application you can still inject custom javascript to add buttons by using LoadHandler and Frame.ExecuteJavascript.

    If you want to do it using OS native controls and don't want to use third party libraries then you can use OS native APIs via ctypes/pyobjc modules.

    The Tkinter library is lightweight, so you can consider using it. There is the tkinter_.py example available (doesn't work on Mac though).

    You can handle keyboard events by implementing KeyboardHandler.

    You can also navigate through mouse context menu.