Mike Spadaru Mike Spadaru - 1 year ago 162
Python Question

Youtube in Webkit/Python/GTK app

I'm trying to do a python(2.7)/GTK+ app, and I have a window, containing a WebKit WebView.

from gi.repository import Gtk, WebKit

class MainWindow:
def __init__( self ):
self.builder = Gtk.Builder()
self.main_window = self.builder.get_object("main_window")
self.scrl_window = self.builder.get_object("scrl_window")
self.webview = WebKit.WebView()

tube_window = MainWindow()

When I run my app I get the folowing error:

ERROR: Invalid browser function table. Some functionality may be
restricted. java version "1.6.0_24" OpenJDK Runtime Environment
(IcedTea6 1.11.3) (6b24-1.11.3-1ubuntu0.12.04.1) OpenJDK 64-Bit Server
VM (build 20.0-b12, mixed mode)
** Message: console message: undefined @0: TypeError: 'undefined' is not an object

The page loads, but I can't play my video :( (The video box is all black and doesn't have any play button, nothing)

The UI is made in Glade and the XML file generated by Glade, youtubeWindow.ui is:

<?xml version="1.0" encoding="UTF-8"?>
<!-- interface-requires gtk+ 3.0 -->
<object class="GtkWindow" id="main_window">
<property name="can_focus">False</property>
<property name="type_hint">menu</property>
<object class="GtkScrolledWindow" id="scrl_window">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="shadow_type">in</property>

Can you please help me?

Answer Source

I found a solution that works for me. I used

import gtk 
import webkit

instead of:

from gi.repository import Gtk, WebKit
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download