Skip to main content

Ralsina.Me — Roberto Alsina's website

Posts about kde (old posts, page 23)

Making your QTextBrowser show remote images

It's re­mark­ably easy to turn your QTextBrows­er in­to a lim­it­ed web browser, at least good enough to show im­ages from the we­b.

Here's all the code:

from PyQt4 import QtCore,QtGui
import urllib, os, md5

class PBrowser(QtGui.QTextBrowser):
    def loadResource(self, type, name):
        url=unicode(name.toString())
        ret=QtCore.QVariant()
        if url.startswith('http://'):
            dn=os.path.expanduser('~/.bartleblog/cache/')
            if not os.path.isdir(dn):
                os.mkdir(dn)
            m=md5.new()
            m.update(url)
            fn=os.path.join(dn,m.hexdigest())
            if not os.path.isfile(fn):
                urllib.urlretrieve(url, fn)
            ret=QtGui.QTextBrowser.loadResource(self, type, QtCore.QUrl(fn))
        else:
            ret=QtGui.QTextBrowser.loadResource(self, type, name)
        return ret

And here's bartle­blog tak­ing ad­van­tage of it:

bartleblog10.png

It even has a prim­i­tive cache and ev­ery­thing ;-)

Neat KDE style: Domino

To­day I was fid­dling with my desk­top and de­cid­ed to check what KDE styles were avail­able in Arch Lin­ux.

Then I test­ed Domi­no.

It's very, very, very nice.

domino.png domino2.png

I have no idea how good it is per­for­mance-­wise (my note­book is pret­ty brawny) but hey, I am a bor­ing guy, and I'm wowed.

Giving BartleBlog the push it needs

I found a cou­ple of hours to hack, and de­cid­ed to spend them on Bartle­Blog.

Here's what got done:

  • UI for blog pre­f­er­ences (still need to do maybe ten of these lit­­tle mod­­ules).

  • Search for files in rea­­son­able places (in­stead of us­ing the DB in the cur­rent fold­er, for ex­am­­ple).

  • Start­ed work on a first-use wiz­­ard

  • Start­ed work­ing on a orig­i­­nal and sim­­ple help sys­tem (re­­source files, yay! ;-).

  • Im­­ple­­men­t­ed (lame­­ly) post­ing of "s­­to­ries" which are stat­ic pages that are not part of the blog's flow.

I in­tend to spend a cou­ple of hours on it ev­ery day for the next ten days or so. Af­ter that, who knows, maybe a re­lease will be rea­son­able.

What I am plotting...

...noth­ing.

Ok, here's what I have been do­ing:

  • Dad­dy work. Lots of it. Fun!

  • Ac­­tu­al work. Lots of it. Fun, but not so much!

  • Worked a lit­­tle more in RA-Flip. Play/Stop/­­Pause is done. The ed­it­ing mode and open­ing/sav­ing files is pret­­ty much done, so it will be ful­­ly func­­tion­al as soon as I can spend an af­ter­noon in it.

  • To­bo­­gan (My slideshow soft­­ware). It works nice­­ly. There are many rough spots and it needs a few fea­­tures:

    • Some way to ed­it the CSS for in­­­di­vid­u­al slides in a nice man­n­er. Like set­t­ing back­­­­­grounds and colours (and not much else)

    • A nice way to save the slideshow so it ends all in a sin­­­gle fold­er.

    • Many UI de­­­tails

    • Docs

    • A site

  • Bartle­Blog: it has worked well for me for a long while, since I have been post­ing this blog us­ing it. And re­al­­ly, it's a nice blog, is­n't it? ;-) But of course, there is stuff to be done:

    • Many UI de­­­tails

    • De­­­cent flickr and openo­my up­­­load­­­er­s/­­­man­agers

    • Some ex­­­tra gad­gets I have in mind

    • Docs

    • A site

And that's all I have in mind right now. Ex­cept maybe a graph­i­cal Be­funge in­ter­preter, but that's not re­al­ly im­por­tant ;-)

BOP: Ball Oriented programming

Some of you may be fa­mil­iar with weird pro­gram­ming lan­guages. Some of you may even know about bidi­men­sion­al lan­guages. Some of you may have seen Flip, where com­pu­ta­tion is per­formed by balls bounc­ing off things.

Now you can see Flip us­ing Qt. My Ra-Flip in­ter­preter. I wrote it in a lark af­ter find­ing out about Flip in Good Math, Bad Math and shares no code with the orig­i­nal, but it's a sim­ple lan­guage ;-)

It's al­most fea­ture-­com­plete. Miss­ing are:

  • Lev­­els (to make it three­­d­i­­men­­sion­al)

  • In­­put

  • Start-stop-­­pause-de­lay con­trols

Here is the manda­to­ry screen­shot:

flip.png

But that re­al­ly does­n't do it jus­tice, so here's a video:

The fun starts around 35 sec­onds in. The pro­gram prints an in­fi­nite se­ries of even num­bers and stores odd num­bers in a ... I am not sure how to call that. A cir­cuit?

I may think about writ­ing a some­thing-­to-Flip com­pil­er, so you can write your pro­grams in some sort of sim­plis­tic im­per­a­tive lan­guage and then see them as a pin­ball ma­chine.

It may be cute if an artist could spend a few hours mak­ing nicer gad­get­s, be­fore I do it (it won't be pret­ty ;-)

And yes, this is prob­a­bly the most use­less pro­gram writ­ten us­ing Qt, right there with kyes.


Contents © 2000-2024 Roberto Alsina