23:01 < Riddell> anyone want to learn a bit of pyqt?
23:02 < Sundance> Riddell: Is this going to be about PyQt, or Plasmoids in Python specifically?
23:02 < Riddell> this was advertised as a plasma with python talk
23:02 < Riddell> I'm afraid that's not going to happen today
23:02 < Riddell> it seems plasma with python is ready yet
23:02 < Riddell> sorry about that
23:02 < Riddell> the work is going on in if you want to follow it
23:02 < dwidmann> Riddell: missing a not in that last setence, I presume?
23:03 < Riddell> dwidmann: right
23:03 < Riddell> maybe someone will have better luck than us at getting those example to work
23:03 < Riddell> HappySmileMan: it doesn't work reliably yet and it's not documented
23:03 < Riddell> however it should be possible soon
23:04 < Riddell> and we'll do a tutorial when that happens
23:04 < Riddell> so I thought we'd make a web browser in pyqt instead
23:04 < Riddell> supert0nes: yep
23:04 < Riddell> this needs Qt 4.4 and the same version of python-qt4
23:04 < Riddell> add this to /etc/apt/sources.list
23:04 < Riddell> deb hardy main
23:05 < Riddell> apt-get update
23:05 < Riddell> apt-get install libqt4-webkit python-qt4
23:06 < Riddell> so our first revision goes like this
23:06 < Riddell> #!/usr/bin/env python
23:06 < Riddell> because it's python
23:06 < Riddell> import sys
23:06 < Riddell> from PyQt4.QtCore import *
23:06 < Riddell> from PyQt4.QtGui import *
23:06 < Riddell> from PyQt4.QtWebKit import *
23:06 < Riddell> to load up the libraries
23:07 < Riddell> python's inbuilt sys library and the necessary parts of Qt
23:07 < Riddell> app = QApplication(sys.argv)
23:07 < Riddell> that create the vital application object which does lots of work behind the scenes to create a running application
23:07 < Riddell> web = QWebView()
23:07 < Riddell> web.load(QUrl(""))
23:07 < Riddell>
23:07 < Riddell> here we create the web browser widget
23:07 < Riddell> Qt 4.4 has WebKit built into it
23:08 < Riddell> so a web browser widget is easy to add
23:08 < Riddell> sys.exit(app.exec_())
23:08 < Riddell> that's the final line
23:08 < Riddell> app.exec_() runs it
23:08 < Riddell> and when that method returns it'll quit the app with the appropriate exit code
23:09 < Riddell> the full thing is at the address above
23:09 < Riddell> has anyone got it working?
23:09 < Riddell> nosrednaekim?
23:09 < Riddell> yay!
23:10 < Riddell> it should look like this
23:10 < Riddell> just a window with the webview widget in it
23:10 < Riddell> any questions?
23:11 < Sundance> Riddell: What HTTP features does QUrl support? Cookies? Cache?
23:11 < nosrednaekim> Riddell: unfortunately I had to update my qt4 packages which is taking forever on the PPA
23:11 < Riddell> Sundance: QUrl just holds the url, QtWebKit library does all the fancy stuff
23:11 < Riddell> Sundance: I believe it does cookies and caching and ssl and all that
23:12 < Riddell> Sundance: but it's also possible to replace those methods with your own
23:12 < Riddell> Sundance: so webkitkde uses the QtWebKit library but replaces cookies and fetching with http with the KDE ways of doing those
23:13 < Riddell> supert0nes: yes in a simple case like this, of course you can set up widgets later if you need to 
23:13 < Riddell> but a web browser needs an address bar
23:13 < Riddell> so lets add one
23:13 < Riddell> the widget for that is Qt's QLineEdit which is a pretty common widget
23:13 < Riddell> ah but it also needs a parent widget
23:14 < Riddell> which has a layout two hold the two widgets we care about (lineedit and webview)
23:14 < Riddell> widget = QWidget()
23:14 < Riddell> creates the parent widget
23:14 < Riddell> layout = QVBoxLayout(widget)
23:14 < Riddell> give it a layout
23:14 < Riddell> web = QWebView(widget)
23:14 < Riddell> web.load(QUrl(""))
23:14 < Riddell> layout.addWidget(web)
23:14 < Riddell>
23:14 < Riddell> put our webview widget into the layout
23:14 < Riddell> code is at
23:15 < Riddell> the result is much the same as before
23:15 < Riddell> but there's a border there which is caused by the layout
23:15 < fliegenderfrosch> Riddell: is there a problem if I install the packages from the PPA when I've already installed PyQt4.4 using "make install"?
23:16 < Riddell> fliegenderfrosch: if you already have pyqt 4.4 you shouldn't need the packages
23:16 < Riddell> fliegenderfrosch: but it shouldn't be a problem, it might overwrite your own compile if it's installed to /usr
23:17 < fliegenderfrosch> Riddell: I have pyqt 4.4 but I get an error about not having webkit (libqt4-webkit is installed)
23:17 < Riddell> removing the border is an exercise you can try, it needs the layout to have its margins set
23:17 < Riddell> the qt documentation is very extensive so it should be easy to work out how to do that
23:17 < Riddell> fliegenderfrosch: try installing the ppa packages then
23:17 < fliegenderfrosch> Riddell: ok, thanks
23:18 < Riddell> so is where we're at
23:18 < Riddell> adding the address bar is easy peasy
23:18 < Riddell> addressBar = QLineEdit(widget)
23:18 < Riddell> layout.addWidget(addressBar)
23:18 < Riddell> which gives us something like this
23:19 < Riddell> full code is at
23:19 < Riddell> anyone got it working?
23:20 < Riddell> dwidmann: working for you?
23:21 < Riddell> not so long ago getting an app to show a web page was the tricky part :)
23:21 < Riddell> next we need to connect our address bar to send its text to the webview widget
23:21 < Riddell> so we can load web pages that we want
23:22 < Riddell> for this we need to create a method we can call
23:22 < Riddell> which will grab the text out of the address bar and tell the webview to load it
23:22 < Riddell> def loadUrl(): print "Loading " + addressBar.text() web.load( QUrl(addressBar.text()) )
23:23 < Riddell> hmm, that should be on multiple lines
23:23 < Riddell> def loadUrl():
23:23 < Riddell>   print "Loading " + addressBar.text()
23:23 < Riddell>   web.load( QUrl(addressBar.text()) )
23:23 < Riddell> here we define a method called loadUrl()
23:23 < Riddell> it has a debugging line so we can see what's going on at the command line
23:24 < Riddell> and it calls the webview widget with the text converted into a QUrl
23:24 < Riddell> then we need to add a signal/slot connection to run that method
23:24 < Riddell> signals happen in Qt widgets when something interesting happens
23:24 < Riddell> and you connect them to slots (which in pyqt are just methods, like the one above)
23:25 < Riddell> QObject.connect(addressBar, SIGNAL("returnPressed()"), loadUrl)
23:25 < Riddell> I looked up the lineedit documentation
23:25 < Riddell> saw it had just the signal we needed, returnPressed()
23:25 < Riddell> and so we connect it to our method
23:26 < Riddell> full program is at
23:26 < Riddell> it looks just like the web3 version, but if you type in a url and press return it'll load that website
23:26 < Riddell>
23:26 < Riddell> mackand: pastebin    apt-cache policy python-qt4
23:28 < Riddell> who's got it working?
23:29 < Riddell> dwidmann: addressBar = QLineEdit(widget)
23:29 < Riddell> dwidmann: passing "widget" when creating that should make it parent to the "widget" we created
23:30 < Riddell> supert0nes: right, QUrl will only accept valid URLs
23:30 < Riddell> as an exercise, it wouldn't be hard to improve loadUrl() to add http if that's missing
23:30 < Riddell> dwidmann: you also create a layout for widget?
23:31 < Riddell> dwidmann: and add addressBar to that layout?
23:32 < Riddell> supert0nes: in most cases you don't need to
23:32 < Riddell> in most cases you'll create your own class which can have its methods in any order
23:32 < Riddell> that's a more common programme structure
23:33 < Riddell> (a class, if you don't know object orientated programming, is a collection of methods and variables from which you create objects.  it can itself be based on another class)
23:33 < Riddell>  that shows the same programme
23:33 < Riddell> but in a different structure
23:34 < Riddell> it defines a class which is (inherits) a the basic QWidget class
23:34 < Riddell> and adds its own children (the addressBar and web widgets)
23:35 < Riddell> when creating a class you use to create variables that belong to the class
23:35 < Riddell> and you pass self into any methods
23:35 < Riddell> fliegenderfrosch: doh!
23:35 < Riddell> dwidmann: ah hah
23:36 < Riddell> supert0nes: I'm afraid I didn't have time to create this in qt designer
23:36 < Riddell> but if you are making a user interface which is at all complex, I recomment making it in designer
23:38 < Riddell> HappySmileMan: I've never seen the point in that, just seems like something extra to learn that if statements can do just as well
23:38 < Riddell> looking at the signals given out by QWebView it would be easy to add a loading animation 
23:38 < Riddell>
23:39 < Riddell> just use loadStarted() and loadFinished()
23:39 < Riddell> inface you could use loadProgress(int) fed into a progressBar
23:39 < Riddell> infact..
23:39 < Riddell> we use python a lot in Kubuntu and Ubuntu generally
23:39 < Riddell> it's popular, well supported by Qt and KDE and other libraries
23:39 < Riddell> easy to learn and easy to write
23:40 < Riddell> supert0nes: yet, Ruby is a good choice too
23:40 < Riddell> s/yet/yes/
23:40 < Riddell> we happen to use python in the ubuntu world, but ruby is certainly good as well
23:41 < Riddell> KDE 4.1 will also see the first pyKDE app in KDE!
23:41 < Riddell> which is the printer-applet from Kubuntu
23:42 < Riddell> also guidance-power-manager is in KDE extragear for 4.1
23:42 < Riddell> it's very satisfying to be able to contribute to KDE through Kubuntu
23:42 < Riddell> HappySmileMan: grenius!
23:43 < Riddell> last tutorials day I gave a similar tutorial and nosrednaekim hang around and wrote us a compiz installer/config tool for Kubuntu
23:43 < Riddell> yay nosrednaekim!
23:43 < nosrednaekim> Riddell: which I need to work on :P
23:43 < Riddell> so if you're inspired to help out Kubuntu with pykde hang around on this channel and ask what needs done
23:43 < Riddell> (many things are listed at
23:45 < Riddell> well
23:45 < Riddell> yes and no
23:45 < Riddell> it's developed by Jim who puts it on riverbankcomputing
23:45 < Riddell> but then Sime grabs that and puts it in KDE's kdebindings module
23:46 < Riddell> we're using the version from kdebindings now since Sime works super hard to keep it up to date with the KDE version
23:46 < Riddell> supert0nes: plasma bindings are separate again
23:46 < Riddell> they use Kross
23:46 < Riddell> which is a nifty library originally for KOffice that lets apps gain scriptable ability easily
23:47 < Sundance> Riddell: For instance, if we had a mind to help with getting the Plasma bindings done, where should we turn to? I prodded the Seigo Man 'bout that a while ago, but didn't press the matter since he's always so busy running all over the world, spreading love and awesomeness. :)
23:47 < Riddell> so if you want to add a formula to KSpread you can easily do it in python and not have to worry about compiling
23:47 < Riddell> the plasma Kross plugin is being developed in
23:48 < Riddell> and the developer did assure me it worked, but I'm afraid I couldn't get it to do much
23:48 < Riddell> but do try it out yourself
23:48 < Riddell> you'll probably need an svn compile of kdebase for the latest plasma
23:49 < Sundance> Riddell: Didn't install last time I checked, and I couldn't find the documentation to figure it out. :/
23:58 < fliegenderfrosch> Riddell: why do you let Browser inherit QWidget and not QDialog?
23:58 -!- jr_ is now known as Riddelll
23:58 < Riddelll> hmm, so my server has decided to break
23:58 < Riddelll> if you look in  you'll see there's a few different types of plasma plugins
23:58 < Riddelll> the runner ones add features to the alt-F2 krunner dialogue
23:58 < nosrednaekim> Riddelll: ahhhh I was lookin for that forever the other day :P
23:58 < Riddelll> the dataengine ones provide the data without a UI, such as an interface into the power manager
23:58 < Riddelll> and the applet gives the plasmoid UI we all know and love
23:58 < Riddelll> if you want more examples of pyqt and pykde apps you can apt-get source python-qt4 which has a bunch of examples
23:58 < Riddelll> for something more complex look at printer-applet in kdeutils in KDE's svn
23:58 < Riddelll> or guidance-power-manager in extragear/utils in KDE's svn
23:58 < Riddelll> Sundance: what is it?
23:58 < supert0nes> gotta head out but thanks very much Riddelll, you have given me the kickstart necessary on PyQt
23:58 < Riddelll> oh and if you're looking for a way to contribute back
23:58 < Riddelll> needs pykde tutorials
23:58 < Riddelll> so you could convert this web browser to a pykde app
23:58 < Riddelll> and put it on techbase
23:58 < fliegenderfrosch> Riddelll: What does pykde provide (on top of pyqt)?
23:58 < Sundance> Riddelll: Just a small MU* client. Nothing spectacular, except that I try to mind the clarity of my code a lot.
23:58 < Riddelll> fliegenderfrosch: better integration with KDE
23:58 < Riddelll> it'll pick up the right KDE widget style, and you can use KDE icons
23:58 < Riddelll> it works with KDE translations too, which are much nicer than Qt's
23:58 < Riddelll> here's a basic pyKDE app
23:58 < fliegenderfrosch> Riddelll: nice, i've got to look at that for my pyqt apps. and with kde4, you don't even lose windows/osx compatibility, right?
23:58 < Riddelll> fliegenderfrosch: shouldn't do, although I'm not sure if pykde is working on windows/mac yet
23:59 < fliegenderfrosch> Riddelll: that doesn't matter, my programs are not even ready for linux users yet...
23:59 < Riddelll> ok, time up, it would be great if someone did turn this into a tutorial on techbase, let me know if you want to do that
00:00 < Riddelll> txwikinger: ready in a minute?