Wednesday, June 19, 2013

Embedding a browser in a python application on a mac

I heard about PyQtWebkit (e.g. here). Sounds great.

First I had to get PyQt. Or maybe PyQt and Webkit, or Py and QtWebkit, or who knows. I wanted all those parts.

Tried to install it from source (e.g. from Riverbank) but that was a hopeless mess. Version 4 or 5? I don't know. I had to build SIP first, which eventually went fine. I tried to build PyQt, but had trouble because it couldn't find qmake, so I went looking for that. But then (as I often do when building things from source) I wondered if I was doing this whole thing wrong.

Tried to install PyQt using MacPorts, but either didn't find the right port or something didn't work. So I tried Homebrew (which is like MacPorts but newer; says you shouldn't run both but it's been okay for me so far):
brew install pyqt

Turns out, I guess, PyQtWebkit is included in PyQt; I just ran the code at the top of the above link, and bam! Google.pl in a python Qt window.
I wonder if I could have used pip to get PyQt; looks doubtful though.

Looks like instead maybe I could have downloaded PyQtX. But I haven't tried that.

Related: Selenium, but that drives an external browser, doesn't let you put one in your own app. Followed the instructions here.

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.