Need a simple “Hello World” example using the Webkit library in Python

后端 未结 2 1128
予麋鹿
予麋鹿 2020-12-14 11:43

Does anyone know of a simple \"Hello World\" example for using the Webkit library in Python? I have a GTK window, and inside I want to put Webkit.

With Python/mozemb

2条回答
  •  [愿得一人]
    2020-12-14 12:00

    Did you check the Python bindings for the WebKit GTK+ port. In one of the directory there are demos on how to use it, including a browser: python demos/tabbed_browser.py

    You could check also the slides of a FOSDEM by Alp Toker on WebKit GTK+ (pdf) Developing hybrid Web/GTK+ rich internet applications.

    import gtk 
    import webkit 
    
    view = webkit.WebView() 
    
    sw = gtk.ScrolledWindow() 
    sw.add(view) 
    
    win = gtk.Window(gtk.WINDOW_TOPLEVEL) 
    win.add(sw) 
    win.show_all() 
    
    view.open("http://w3.org/") 
    gtk.main()
    

    That should give you good hints for starting.

提交回复
热议问题