Wednesday, 25 May 2022

A Simple Web Browser Using WebKit2Gtk

WebKit is a html rendering engine developed by Apple and primarily used in its Safari web browser, as well as all iOS web browsers. WebKitGtk is a GTK toolkit that can call WebKit under Linux GTK platform. This app shows how to create a very simple web browser using WebKit running on a GTK+3 Linux platform.



  1. Define an entry for entering URI.
  2. Define buttons: Go, Zoom In and Zoom Out for controlling the browser.
  3. Include component WebKit2Gtk by from gi.repository import WebKit2 and WebKit2.WebView().
  4. Use the command webview.load_uri() to load a web page.
  5. Use the command webview.set_zoom_level(zoom_size) to zoom the web page, where zoom_size = 1.0 means 100%.

Reference

https://webkitgtk.org/reference/webkit2gtk/2.5.1/WebKitWebView.html

To install the component WebKit2Gtk under Debian Linux:
# apt-get install gir1.2-webkit2-4.0


Source Code


No comments:

Post a Comment