Embed wxGTKWebKit in wxPython application

Hello,

I'm trying to embed a webkit window inside a wx.Panel in my wxPython
application, based on code published at http://wiki.wxpython.org/wxGTKWebKit
.

The problem is that I apparently need to provide my wx.Frame instance
as an argument to the HtmlWindow constructor, which causes the webkit
window to be rendered in the top-left corner of the application
window. I haven't been able to figure out how to position it inside my
wx.Panel. If I provide my wx.PaneI I want it to be rendered inside, it
will fail on:

whdl = self.GetHandle()
window = gtk.gdk.window_lookup(whdl)
self.pizza = pizza = window.get_user_data()

where the window variable is returned as NoneType inside the
wxGTKWebKit code, and the application will fail when trying to run
get_user_data() on a NoneType object. In addition I get the following
error on stdout:

/usr/lib/python2.6/dist-packages/wx-2.8-gtk2-unicode/wx/_core.py:
10263: GtkWarning: /build/buildd/gtk+2.0-2.20.1/gdk/x11/gdkdrawable-
x11.c:952 drawable is not a pixmap or window
  return _core_.Window_GetHandle(*args, **kwargs)

Can someone please advice on how to solve this?

In advance, thanks.

Hello Frank,

Maybe this blog post will help you:

http://blog.marcelofernandez.info/2010/10/navegador-simple-con-wxpython-webkitgtk/

It's in spanish, but the code snippets are understable anyway :slight_smile:

If it doesn't, could you post the code example which is giving you this problem?

Regards

···

2011/2/16 Frank <frank.aune@gmail.com>:

Hello,

I'm trying to embed a webkit window inside a wx.Panel in my wxPython
application, based on code published at wxGTKWebKit - wxPyWiki
.

The problem is that I apparently need to provide my wx.Frame instance
as an argument to the HtmlWindow constructor, which causes the webkit
window to be rendered in the top-left corner of the application
window. I haven't been able to figure out how to position it inside my
wx.Panel. If I provide my wx.PaneI I want it to be rendered inside, it
will fail on:

whdl = self.GetHandle()
window = gtk.gdk.window_lookup(whdl)
self.pizza = pizza = window.get_user_data()

where the window variable is returned as NoneType inside the
wxGTKWebKit code, and the application will fail when trying to run
get_user_data() on a NoneType object. In addition I get the following
error on stdout:

/usr/lib/python2.6/dist-packages/wx-2.8-gtk2-unicode/wx/_core.py:
10263: GtkWarning: /build/buildd/gtk+2.0-2.20.1/gdk/x11/gdkdrawable-
x11.c:952 drawable is not a pixmap or window
return _core_.Window_GetHandle(*args, **kwargs)

Can someone please advice on how to solve this?

In advance, thanks.

--
Marcelo F. Fernández
Buenos Aires, Argentina
Licenciado en Sistemas - CCNA

E-Mail: fernandezm@gmail.com
Web Site: http://www.marcelofernandez.info
Twitter: @fidelfernandez

Did you see the comment in the code about it only working after the widget has been "realized" or shown? I expect that is your problem. You could probably get it working more naturally if you move the code in WKHtmlWindow.__init__ to an event handler for the EVT_WINDOW_CREATED event. Then you'll also want to ensure that the other methods that use self.ctrl fail gracefully if that event handler hasn't been run yet, or perhaps just queue up the operations until after the EVT_WINDOW_CREATED handler has finished.

···

On 2/16/11 5:07 AM, Frank wrote:

Hello,

I'm trying to embed a webkit window inside a wx.Panel in my wxPython
application, based on code published at wxGTKWebKit - wxPyWiki
.

The problem is that I apparently need to provide my wx.Frame instance
as an argument to the HtmlWindow constructor, which causes the webkit
window to be rendered in the top-left corner of the application
window. I haven't been able to figure out how to position it inside my
wx.Panel. If I provide my wx.PaneI I want it to be rendered inside, it
will fail on:

whdl = self.GetHandle()
window = gtk.gdk.window_lookup(whdl)
self.pizza = pizza = window.get_user_data()

where the window variable is returned as NoneType inside the
wxGTKWebKit code, and the application will fail when trying to run
get_user_data() on a NoneType object.

--
Robin Dunn
Software Craftsman