Skip to main content

Ralsina.Me — Roberto Alsina's website

Very pythonic progress dialogs.

Sometimes, you see a piece of code and it just feels right. Here's an example I found when doing my "Import Antigravity" session for PyDay Buenos Aires: the progressbar module.

Here's an example that will teach you enough to use progressbar effectively:

progress = ProgressBar()
for i in progress(range(80)):

Yes, that's it, you will get a nice ASCII progress bar that goes across the ter­mi­nal, sup­ports re­siz­ing and moves as you it­er­ate from 0 to 79.

The progressbar module even lets you do fancier things like ETA or fie transfer speeds, all just as nicely.

Is­n't that code just right? You want a progress bar for that loop? Wrap it and you have one! And of course since I am a PyQt pro­gram­mer, how could I make PyQt have some­thing as right as that?

Here'show the out­put looks like:


You can do this with ev­ery toolk­it, and you prob­a­bly should!. It has one ex­tra fea­ture: you can in­ter­rupt the it­er­a­tion. Here's the (short) code:

# -*- coding: utf-8 -*-
import sys, time
from PyQt4 import QtCore, QtGui

def progress(data, *args):
    widget = QtGui.QProgressDialog(*args+(0,it.__length_hint__()))
    for v in it:
        if widget.wasCanceled():
            raise StopIteration

if __name__ == "__main__":
    app = QtGui.QApplication(sys.argv)

    # Do something slow
    for x in progress(xrange(50),"Show Progress", "Stop the madness!"):

Have fun!

For the Win

Cover for For the Win


A re­al page turn­er. Tak­ing ad­van­tage of it be­ing CC, I think I may at­tempt trans­lat­ing it to span­ish (ar­gen­tini­an flavour)

The first english Issue of PET (our Python Magazine) is out!

Hell yeah! It has been a lot of work but it's out at http://re­

Some ar­ti­cles:

  • PyAr, The His­­to­ry

  • from gc im­­port com­­mon­sense - Fin­ish Him!

  • Pain­­less Con­cur­ren­­cy: The mul­ti­pro­cess­ing Mod­­ule

  • In­­tro­­duc­­tion to Unit Test­ing with Python

  • Taint Mode in Python

  • Ap­­plied Dy­­namism

  • Dec­o­rat­ing code (Part 1)

  • We­b2Py for Ev­ery­­body

It's avail­able in pret­ty much ev­ery for­mat any­one can read, and if your favourite is not there, we will make it for you or may I be smote by the fly­ing spaghet­ti mon­ster's nood­ly ap­pendage!

AFAIK there is no oth­er Python mag­a­zine be­ing pub­lished (feel free to cor­rect me), so it's kind of a big thing for us in PyAr (the Ar­genti­na Python com­mu­ni­ty) that we are do­ing one, and in two lan­guages.

But why stop here? Want it to be avail­able in your lan­guage? Con­tact us at re­vistap­yar@net­man­ager­s.­ it may be doable!

And of course, very soon there will be a call for ar­ti­cles for Is­sue 2, and trust me: that one's go­ing to be epic: this one was just a warmup.


Cover for Fryupdale


Some things were fun, but it's not my cup of tea.

Making deployment of desktop Python apps trivial: an idea

Proprietor and printer in front of Schwartz Print Shop in Minneapolis

Here's what I'm think­ing: how hard could it be to make PyQt app de­ploy­ment ab­so­lute­ly easy? Well, I am guess­ing: not very hard.

Here's the trick: see what works in the re­al world, and adopt it.

Ques­tion: what has de­ployed bil­lions of apps and has its users hap­py? An­swer: phones app stores.

Ques­tion: how do they work? An­swer: well, that's not that short, so let's start ex­plain­ing.

As I see it, a rea­son­able app store has the fol­low­ing com­po­nents:

A Stable Deployment Target

You can't de­ploy from the store if you don't know what you are de­ploy­ing in­to. If the tar­get plat­form is shaky, you just can't know how to de­ploy with­out us­er as­sis­tance, and we are try­ing to make this easy for the user, which means that's not ac­cept­able.

So, what's a sta­ble de­ploy­ment tar­get we can provide?

  • PyQt (so we can de­­ploy GUIs to all ma­jor desk­­top plat­­for­m­s)

  • Python stan­­dard li­brary

  • Se­lec­t­ed mod­­ules

What can be (and should be) bun­dled with the ap­p?

  • Pure python mod­­ules

  • Art­­work and oth­­er re­­sources

What may be bun­dled:

  • Python mod­­ules writ­ten in C/C++, but you then have to re­­do the app for each plat­­for­m, and that kin­­da suck­­s.

Deployment Services

  • Apps should be able to check if there is a new ver­­sion of them in the store, to ask for up­­­grades.

  • Apps should be added by the de­­ploy­­ment plat­­form nice­­ly in­­­to the host sys­tem's menus, desk­­top, etc.

Monetization Services

  • Some way to charge for ap­p­s. Even for open source ap­p­s, you could ask for U$S0.99 if you in­­stall them through the store. Op­­tion­al, of course, and up to the app own­er.

  • Ad plat­­for­m? There must be a good one for desk­­top apps some­where?

The Store Itself

  • A we­b­site that down­loads a "pack­­age" as­­so­­ci­at­ed with a lo­­cal de­­ploy­­ment ap­­pli­­ca­­tion.

  • A app store ap­p. In­­stall things not via we­b, but via a desk­­top ap­­pli­­ca­­tion.

I don't ex­pect a func­tion­al ver­sion of this would take me more than a week work­ing full­time to im­ple­men­t. Of course then there are all sorts of us­abil­i­ty, look­s, etc. things to con­sid­er.

And... I am go­ing to do some­thing I very rarely do. I am go­ing to ask for mon­ey.

As an ex­per­i­men­t, I have set­up a project at­diegogo.­com/Qt-Shop and set a fund­ing goal of U$S 600.

There you can fund me. I prom­ise that if the project is to­tal­ly fund­ed, I will de­liv­er. If it is­n't, I may de­liv­er any­way. I would pre­fer to have the mon­ey though.

The plat­form would be re­leased un­der GPLv2 or lat­er.

Contents © 2000-2023 Roberto Alsina