Skip to main content

Ralsina.Me — Roberto Alsina's website

Posts about Writing (old posts, page 5)

Today's first hour of hacking...

... has been all about UI.

I have al­ways had a prob­lem when writ­ing PyQt app­s: stock icon­s.

Which ones should I use? Where are they?

I usu­al­ly fished through the crys­talsvg icon set un­til I found one that seemed to be what I need­ed, and then copied it to my ap­p.

Sad­ly, that's an­noy­ing in sev­er­al ways:

  1. Since those are PNG icon­s, you need to find the right size.

  2. Not all icons are there for all sizes!

  3. Be­­cause of 2, I need to check three or four fold­ers to see all the icon­s.

So, I de­cid­ed to cut my loss­es, and see what else could be done. And here it is:

bartleblog11.png

I am now us­ing all SVG icon­s, from the rein­hardt set that will look equal­ly out of place in all OS­s, but which I like (and I think look awe­some with this re­laxed Domi­no the­me). And be­cause they are all SVG, I don't care about sizes, and they are all in the same place, and all is good.

And when­ev­er Oxy­gen is re­leased, all I need to do is switch the files around and that's that. Which is nice, too.

Of course there is a catch... it does look out of place, and I ex­pect many to find it ug­ly. So what, since I am the on­ly us­er of this ap­p! ;-)

Today's two hours of hacking

  • Done with the main blog con­­fig di­a­log.

  • Fixed a dozen bugs

  • Gen­er­ate the blog in a rea­­son­able place

  • Fixed a lot of UI bugs (tab or­der­s, sizes)

Still lots and lots of things to be done, tho.

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 ;-)

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.

New BartleBlog Feature: marketspeak!

Now, I don't know if this is use­ful, but I do think it's way neat.

In­spired by S5, rst2s5, and mootools I took an hour (or two) and hacked this neat lit­tle slide tool.

The goals dif­fer from S5 in that I in­tend to write a fron­tend, so that you have a sort of very-poor-­man's pow­er­point, but al­so in that the out­put should be sim­ple to em­bed in oth­er pages so that I can even­tu­al­ly make this a part of bartle­blog.

Check it out (click to go to next slide, move mouse to the top of the slideshow for con­trol­s):

<<   >>

Why use BartleBlog

(If you are a nerd)

Author: Roberto Alsina <ralsina@kde.org>

It's nerd-oriented

It's triv­ial to dis­play source code, with prop­er syn­tax high­light­ing.

from base64 import *
def myFirstFunction():
      print b64decode ('YnllIHdvcmxkIQ==')

Even for things like shell ses­sion­s. Dammit, I am a nerd, I will try to add ev­ery nerd fea­ture I deem cool.

It does things simply

Wan­na show a flickr pho­to?

.. flickr:: myPhotoTitle

How about us­ing openo­my.­com to share your files? And what­ev­er else you can think of, it prob­a­bly can be done.

It's very easy to extend

Re­al­ly. It's sim­ple python code.

  • The mod­ule to do syn­tax high­light­ing has 41 lines.
  • The mod­ule to do dy­nam­ic an­i­mat­ed menus has 103.
  • The mod­ule to do cal­en­dars has 72.

If there is a python mod­ule or web ser­vice to do what you wan­t, hook­ing it in­to Bartle­Blog is sim­ple.

And it has kickass features

Like on­line, em­bed­ded, an­i­mat­ed slideshows! Like this one! Done with 65 lines of sim­ple al­most-­plain-­text markup! Ok, it's not ful­ly im­ple­ment­ed yet, be­cause it needs some man­u­al code, but the hard part is done!

Or au­to­mat­ic SVN changel­og dis­play ( I ad­mit that's some­what niche ;-))

Now, who else has that kind of thing?

There may be an ar­ti­fact when you slide out the syn­tax-high­light­ed box­es, but I have no idea how to fix it.

Al­so, I have not test­ed it at all in IE, so if it fails there, don't wor­ry, that's to be ex­pect­ed!

Next time I speak in pub­lic, I may use this :-)

And, as a teas­er... this is the source for the pre­sen­ta­tion you just saw:

Why use BartleBlog
==================

(If you are a nerd)
~~~~~~~~~~~~~~~~~~~

:author: Roberto Alsina <ralsina@kde.org>

It's nerd-oriented
------------------

It's trivial to display source code, with
proper syntax highlighting.

.. code-block:: python

  from base64 import *
  def myFirstFunction():
        print b64decode ('YnllIHdvcmxkIQ==')

Even for things like shell sessions.
Dammit, I am a nerd, I will try to add every nerd
feature I deem cool.


It does things simply
---------------------

Wanna show a flickr photo?

.. code-block:: rst

  .. flickr:: myPhotoTitle

How about using openomy.com to share your files?
And whatever else you can think of, it probably
**can** be done.

It's very easy to extend
------------------------

Really. It's simple python code.

* The module to do syntax highlighting has 41 lines.

* The module to do dynamic animated menus has 103.

* The module to do calendars has 72.

If there is a python module or web service to do what you
want, hooking it into BartleBlog is simple.

And it has kickass features
---------------------------

Like online, embedded, animated slideshows! Like this one!
Done with 65 lines of simple almost-plain-text markup!
Ok, it's not fully implemented yet, because it needs some manual
code, but the hard part is done!

Or automatic SVN changelog display ( I admit that's *somewhat niche* ;-))

Now, who else has that kind of thing?

Contents © 2000-2024 Roberto Alsina