Posts about python (old posts, page 11)

2007-05-09 15:06

Today's two hours of hacking

  • Done with the main blog config dialog.
  • Fixed a dozen bugs
  • Generate the blog in a reasonable place
  • Fixed a lot of UI bugs (tab orders, sizes)

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

2007-05-08 21:05

Making your QTextBrowser show remote images

It's remarkably easy to turn your QTextBrowser into a limited web browser, at least good enough to show images from the web.

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 bartleblog taking advantage of it:

bartleblog10.png

It even has a primitive cache and everything ;-)

2007-05-05 18:29

Giving BartleBlog the push it needs

I found a couple of hours to hack, and decided to spend them on BartleBlog.

Here's what got done:

  • UI for blog preferences (still need to do maybe ten of these little modules).
  • Search for files in reasonable places (instead of using the DB in the current folder, for example).
  • Started work on a first-use wizard
  • Started working on a original and simple help system (resource files, yay! ;-).
  • Implemented (lamely) posting of "stories" which are static pages that are not part of the blog's flow.

I intend to spend a couple of hours on it every day for the next ten days or so. After that, who knows, maybe a release will be reasonable.

2007-05-01 19:39

What I am plotting...

...nothing.

Ok, here's what I have been doing:

  • Daddy work. Lots of it. Fun!
  • Actual work. Lots of it. Fun, but not so much!
  • Worked a little more in RA-Flip. Play/Stop/Pause is done. The editing mode and opening/saving files is pretty much done, so it will be fully functional as soon as I can spend an afternoon in it.
  • Tobogan (My slideshow software). It works nicely. There are many rough spots and it needs a few features:
    • Some way to edit the CSS for individual slides in a nice manner. Like setting backgrounds and colours (and not much else)
    • A nice way to save the slideshow so it ends all in a single folder.
    • Many UI details
    • Docs
    • A site
  • BartleBlog: it has worked well for me for a long while, since I have been posting this blog using it. And really, it's a nice blog, isn't it? ;-) But of course, there is stuff to be done:
    • Many UI details
    • Decent flickr and openomy uploaders/managers
    • Some extra gadgets I have in mind
    • Docs
    • A site

And that's all I have in mind right now. Except maybe a graphical Befunge interpreter, but that's not really important ;-)

2007-04-14 23:37

New project: Tobogan

As a result of my playing with mootools and creating powerpoint-style slideshows on webpages from restructured text, I am pretty much decided about turning this into a standalone, real application.

I am doing a PyQt4 frontend, and restructured text addons to generate the slides.

The native file format is restructured text itself, and it supports basic transitions between slides.

It still needs a ton of work, but here is a video showing how it looks after a couple of days hacking. You can see the current UI, a document's source, and a demonstration using firefox (only because Konqy doesn't suppose opacity, the rest of the transitions work even better on Konqueror)

It's Ogg/Theora and 3MB (thanks openomy.com!): the video

2007-04-12 17:35

New BartleBlog Feature: marketspeak!

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

Inspired by S5, rst2s5, and mootools I took an hour (or two) and hacked this neat little slide tool.

The goals differ from S5 in that I intend to write a frontend, so that you have a sort of very-poor-man's powerpoint, but also in that the output should be simple to embed in other pages so that I can eventually make this a part of bartleblog.

Check it out (click to go to next slide, move mouse to the top of the slideshow for controls):

<<   >>

Why use BartleBlog

(If you are a nerd)

Author: Roberto Alsina <[email protected]>

It's nerd-oriented

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

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?

.. 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?

There may be an artifact when you slide out the syntax-highlighted boxes, but I have no idea how to fix it.

Also, I have not tested it at all in IE, so if it fails there, don't worry, that's to be expected!

Next time I speak in public, I may use this :-)

And, as a teaser... this is the source for the presentation you just saw:

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

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

:author: Roberto Alsina <[email protected]>

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?

2007-04-10 23:13

Son of BartleBlog XIV: Moo

A new gadget: Mootools based menus.

It takes the same data format I used for the Yahoo UI menubar, and creates a dynamic, sliding, animated, pretty, works-on-lynx menu.

No screenshot because it makes no sense without the movement. You can see it at the top of the sidebar (click on the darker items, outside the links... that needs work).

And yes, that means this blog has, right now, two menus with exactly the same data in them. And on a non-JS browser both are fully expanded.

But that's just temporary ;-)

2007-04-08 20:22

Son of BartleBlog XIII: your blog software doesn't do this

The nerdiest feature of all time... simple SVN logs.

Here's the RST code:

.. svnlog:: https://ra-blog.googlecode.com/svn/trunk/
  :limit: 3

And here is what it does:


System Message: ERROR/3 (<string>, line 14)

Unknown directive type "svnlog".

.. svnlog:: https://ra-blog.googlecode.com/svn/trunk/
  :limit: 3


You can see the entries are nicely formatted. That's because this restructured text directive connects to your SVN server, retrieves the changelog, parses it, tries to process the individual entries as restructured text, and then formats and spits it out again.

I decided to add the recursive parsing because I tend to format everything I write as valid restructured text anyway. But that means I can include images, tables, files, and even other logs in my entries.

How is it useful? Well, I intend to have my projects' pages written using this. This way I don't need to keep a changelog.

Also, I bet the title is right ;-)

2007-04-08 18:20

Son of BartleBlog XII: post in mere seconds

It was pretty hard, but I finally managed to make bartleblog re-render only the necessary pages.

In fact, now my blog has a few less pages because some random stuff was generated in the past, and never got deleted.

There are still some bugs but, with this, it's a reasonably useful app.

Todo:

  • Alternative comment system based on JS-Kit
  • Flickr photoset directive
  • Nicer Openomy tag directive
  • Flickr and Openomy uploading
  • Many config pages and wizards
  • Background rendering
  • Lots of UI love
  • FeedBurner support to automatically use their version of the RSS feeds

Other than that, it's pretty much feature-complete, or at least it has enough features a nerd can use it to post a blog just like this one, for whatever that's worth.

2007-04-08 12:58

Using TinyURL in python

Isn't this neat?

import urllib

def makeTiny(url):

  url='http://tinyurl.com/api-create.php?'+urllib.urlencode({'url':url})
  return urllib.urlopen(url).read()

>>> makeTiny('http://www.kde.org')
'http://tinyurl.com/3cnthx'

Contents © 2000-2019 Roberto Alsina