Tales of a GeekTrotter Binary Logbook


Mobile Applications in HTML5/CSS3 with Sencha Touch

A few years ago, I was writing about building smartphone applications with Rhomobile Rhodes.

Since then, I also tried several frameworks, such as Appcelerator Titanium Mobile but was especially satisfied by a relatively recent one, using only web technologies: Sencha Touch 2.0.
My main concern about Titanium Mobile is that the generated application was not behaving the same on Android and iOS (and was not working on iOS).
After writing code and testing on Android, I was very frustrated that it didn't work out-of-the-box on iPhone.
I didn't really have time to investigate the problem, but it gave me a bad image of the product.
That's how I ended up trying Sencha Touch 2.

A quick summary of the strengths and weakness of Sencha Touch 2.


  • Rapid testing (inside the browser)
  • Good User Interface API
  • MVC Design Pattern
  • Provides a GUI for quick mockup (Sencha Architect)
  • Pure HTML5/CSS3


  • New, working fine on Mac (from what I heard/read), but unstable on Windows/Linux*
  • Is limited by the cross-domain security that prevents from fetching data from other domains that do not?explicitly?allow it if ran in the browser (not packaged as an application)
  • Needs to be integrated into another framework such as PhoneGap (Cordova) to be packaged as a real?application*
  • Tiny visual difference between the desktop browser rendering and the smartphone browser rendering (text is not coloured in one of the pages)

*The Sencha command-line is supposed to provide packaging, but doesn't work well on Linux so I had to integrate the app inside a PhoneGap project to deploy as a real?application.

It took me about 8 working hours (a geek weekend) to build a simple application from scratch.
For testing, I created a small application that allows you to add transactions to the easy online money management service Buxfer, which provides a JSON API (Sencha Touch 2 can easily handle data coming from JSON/JSONP objects).

The application is very basic: 3 tabs (Home, Add and Logout).
On the Home tab, I list the accounts and the last transactions.
On the Add tab I allow to add a transaction (an expense or an income).
And the Logout tab will log the user out.

The application works very well on the desktop browser, and it's really fast to test our program:

However, there are a few differences on the real?application on the smartphone:
- There are no colours on the accounts balance listing (should be green if positive, red if negative)
- It's hard to make the checkboxes on the Add tab activate (touch)

I recorded a video of the real?app running on my phone, not really good quality but gives an idea of the rendering:

As we can see, it's still very nice, and I'm sure the little problems will be fixed soon.

You can find the source code of that application on BitBucket: Buxfer Mobile

Next time, I'll try another promising mobile framework: jQuery Mobile.

Filed under: IT, Programming 1 Comment

Save your screenshots to a file in Python

Python allows you to quickly build useful applications.
Let say you're running the old Windows XP and need to take screenshots of your screen, directly saving the picture.
You might usually open Paint, paste, save (choosing the format you want to save as).
Well, fast enough, but could be improved isn't it?

The following piece of code grabs the image from the clipboard and directly prompts you where to save the file.
Depending on the filename you choose, it will automatically apply the correct compression (bmp/png/jpeg...) thanks to the Python Image Library (PIL).

In addition to the libraries bundled with Python you only need to install PIL, either from PIL or from PILLOW.

I personally chose pillow:

$ pypm install pillow
The following packages will be installed into "%APPDATA%\Python" (2.7):
Hit: [pypm-free.activestate.com] pillow 1.7.6
Installing pillow-1.7.6
Fixing script %APPDATA%\Python\Scripts\pilconvert.py
Fixing script %APPDATA%\Python\Scripts\pildriver.py
Fixing script %APPDATA%\Python\Scripts\pilfile.py
Fixing script %APPDATA%\Python\Scripts\pilprint.py

You are now ready to run the script:

import os
from PIL import ImageGrab # from PIL or PILLOW
from Tkinter import Tk
from tkFileDialog import asksaveasfile
import tkMessageBox
import subprocess

if __name__=='__main__':
    # hide the Tk window
    root = Tk()
    # grab the image from the clipboard
    myimage = ImageGrab.grabclipboard()
    # quit if it's not an image
    if myimage is None:
        msg = "The clipboard does not contain an image."
        tkMessageBox.showwarning("Error", msg)
    # choose where to save the file
    fout = asksaveasfile(mode='w', defaultextension=".png")
    # quit if the user canceled saving the file
    if fout is None:
    # finally, save the file (extension will dictate the compression)
        output = fout.name
    except Exception, e:
        msg = "Error: %s" % e
        tkMessageBox.showerror("Error", msg)
        filePath = os.path.abspath(output)
        #tkMessageBox.showinfo("Saved", filePath)
        subprocess.Popen(r'explorer /select,"'+filePath+'"')

To use it, simply hit the "Print Scrn" key and run the script.
Running the script is not that faster than starting Paint so you could create a shortcut to the desktop and create a Shortcut Key to the shortcut.

For example to set a shortcut to "Ctrl + Alt + P":

Now simply hit "Print Scrn", "Ctrl + Alt + P" and choose where to save the screenshot, that's it!

Filed under: IT, Programming 1 Comment

Run Django from a VM and access it from the host

If you try to run Django development mode from a Virtual Machine and access the website from the host, you need to specify the global IP address in the "runserver" command.

For example if your VM IP address is (in NAT mode):

You should run the server by calling (you can change the port):

python manage.py runserver


Now you need to connect to the website specifying the IP address like that:

Both from the VM:

And the Host:

The server running on Linux is much faster than the one running on Windows 🙂
Filed under: IT, Linux, Programming No Comments

Package a Python Qt (PySide) application for Windows (.exe)

That's fairly easy to package a Python Qt (PySide) application for Windows (and even easier on Linux with cxfreeze).

Let see two different ways of doing so.


Python Qt4 recipe: QSingleApplication (PySide)

Thanks to Renato Filho who helped me in this thread on the Qt Forums, I made a simple QSingleApplication class for PySide that allows you to be sure your program will be started only once.

In addition to start the application only once, we can send the arguments of the later calls of your program to the first (and only remaining) instance.

The following video summarizes the features:

Page 1 sur 212