This site has been retired. For up to date information, see handbook.gnome.org or gitlab.gnome.org.


[Home] [TitleIndex] [WordIndex

Language Bindings

To use WebKit2Gtk+ with other languages we should use GObject Introspection. For example:

Python

   1 #!/usr/bin/python
   2 from gi.repository import WebKit2
   3 from gi.repository import Gtk
   4 
   5 def close(window):
   6         Gtk.main_quit()
   7 
   8 def main():
   9         Gtk.init()
  10 
  11         view = WebKit2.WebView()
  12         view.load_uri("http://google.es")
  13         window = Gtk.Window()
  14         window.add(view)
  15         window.connect("destroy", close)
  16         window.show_all()
  17 
  18         Gtk.main()
  19 
  20 main()

JavaScript

#!/usr/bin/gjs

const Gtk = imports.gi.Gtk;
const WebKit2 = imports.gi.WebKit2;

Gtk.init(null, 0);

var win = new Gtk.Window({type: Gtk.WindowType.TOPLEVEL});
var view = new WebKit2.WebView();
view.load_uri("http://google.es");
win.add(view);

win.connect("destroy", function (window) {Gtk.main_quit();});
win.show_all();

Gtk.main();


Previous Top Next


2024-10-23 11:37