SPE IDE - Stani's Python Editor

Wednesday, February 17, 2010

I started to develop SPE when I was still using Windows back in 2002. By using Python and wxPython, I hoped SPE would run smoothly on all platforms. That was wishful thinking. Luckily the community stepped in: Linux users started sending me patches and Mac users collected money to buy me a Mac Mini. Many years ago I go I switched to Ubuntu and at that moment I've felt the joy not having chosen a technology which locks you up in one platform.

Later I started developing Phatch (Photo Batch Processor) and used my experience of SPE to polish if for Linux, Mac OS X and Windows. I took care of distributing it well on Linux by getting it in the major repositories (Debian, Ubuntu, Fedora, Arch, Suse, ...). Unfortunately I lacked the time for proper distribution on Mac OS X and Windows. I am happy to announce that is going to change.

Together with Nadia Alramli (other Phatch developer) we've dived deeper in the subject of developing and distributing cross-platform applications. Our conclusion is that is it takes more time to research than to implement the code. Therefore we are eager to share our knowledge during our talk at Pycon to save you from hair-pulling behaviour. We have learnt that Python solves 90% of the cross-platform problems for you, but that the remaining 10% could be tricky. In our talk we will point the finger on several painful issues and offer solutions, hoping that they will save you time and frustration.

We prepared the talk by writing a paper (outline here), which is far more extensive than the 30 min of talk will allow us. We designed the talk to give you a good overview and to get you started. I have send the paper for review to some people I highly respect. These were some reactions:

"It's a pity I can not attend PyCon. Anyway, the subjects you are describing in the paper are seldom analyzed in such depth, and I believe the whole community will benefit from your presentation. Most interesting of all, correctly packaging and distributing an app on multiple platforms can be a deep nightmare and what you have on your paper is a beautiful example of how to avoid the most hair-pulling mistakes in doing it." Andrea Gavana (wxPython)

We will use wxPython as an example GUI toolkit, but the principles are valid for other toolkits as well. Our target audience are programmers who have already some experience on one platform but are wondering how things could be implemented on other platforms. Making your application cross-platform is the most efficient way to scale your user base.

Rather than making any bullet point slides, we did our best to make the slides visually entertaining. So even if our voices would suddenly mute, you have at least something nice to look at. As the author of SPE I made sure that all code slides have a pretty syntax highlight. Combining Pygments with Inkscape rocks!

Wednesday, May 20, 2009

At the last Libre Graphics Meeting I met Igor Novikov, who is the lead developer of sK1. sK1 is a vector graphics editor, just like Inkscape but with a different focus. While Inkscape is oriented to the SVG format and is ideal for web design, sK1 targets professional designers from the prepress world. So sK1 supports CMYK, multiple pages and separating colour plates. To quote wikipedia:

sK1 is an open-source illustration program for the Linux platform that can substitute professional proprietary software like CorelDRAW or Adobe Illustrator. Unique project features are CorelDRAW formats importers, tabbed multidocument interface, Cairo-based engine, color management etc.

The multipage feature is very handy for designing booklets with vector graphics or presentations, which you could project with impressive (former keyjnote). Under the hood Inkscape and sK1 share Uniconvertor, for importing, exporting and converting vector graphics. Uniconvertor was developed by the sK1 team. (sK1 is a fork of the Skencil project.) Another difference from Inkscape, is that sK1 itself is developed mostly in python. So you could in a way it use as a python library.

sK1 is being developed under Mandriva and it is hard to install on Ubuntu (especially for graphic designers). I noticed that Vladimir Osintsev was preparing a package for Ubuntu. I contacted him and invited him to work together on it within the Debian Python Package Team. So hopefully sK1 will become available in Debian and Ubuntu (from Karmic).

As some of you can't wait and like to use sK1 with the current Ubuntu releases, I decided to add sK1 for Jaunty and Intrepid to my PPA:

deb http://ppa.launchpad.net/stani/ppa/ubuntu jaunty main

To add the key of my PPA to your system, type the following in a terminal (replace jaunty with your ubuntu version):

Disclaimer: this is the development version of sK1 and the packages have not been tested by a critical mass. In case you have problems, you should report them on the sK1 forums. The packaging is not perfect yet. For example there will be no entry in the start menu. This will be fixed in a next release. I've sent Igor from sK1 the necessary files to resolve this issue. So for now start sK1 by typing "sk1" in the run dialog (Alt+F2) or in a terminal.

As a final remark: you need to remove your ~/.sk1 folder, otherwise sK1 might have troubles starting up.

Monday, April 6, 2009

I'm working on AR, a python library for Blender, which might be interesting for ARchitects. It targets primarily Blender python scripters, not Blender end users. However non pythoneers might be interested in the library as well, as some side products are end user friendly.

One of the features I have been working on is DWG support for Blender. It uses the DXF scripts of Blender under the hood, so it is limited to their abilities. Probably export will work better than import.

In case you want to use this plugin for Blender, you need to install my ar package first. It has been tested both on Linux and Windows. (Mac Os X might work as well.) Afterwards read the tutorial for further instructions. You can use my DWG conversion python module also outside Blender.

Are you an architect and coding with Python in Blender? I'd love to hear from you, not just because of this blog post. Just send me an email: spe.stani.be # gmail.com

Tuesday, March 31, 2009

Would it not be nice if IPython could run inside the Blender terminal in such way that it will remember the namespace history in between sessions? Why IPython? It gives you auto completion, deep reloads, object introspection, input history, access to your operating system commands with python variables, auto indent, ... In case you are not convinced, read this tutorial, reference or watch these screencasts on showmedo.

Most Linux distributions ship IPython in their repositories. For example installing on Ubuntu is as easy as:

$ sudo apt-get install ipython

Getting IPython on Windows or Mac is simple if you have setuptools installed:

$ easy_install IPython

Windows users should install pyreadline as well for autocompletion. Check first in a terminal if IPython is correctly installed:

__author__ = "Stani (SPE Python IDE)"__url__ = ["pythonide.stani.be", "www.blender.org", "www.python.org"]__bpydoc__ = """\This only works if you started Blender from a terminal.Otherwise Blender will freeze. The IPython console willappear in the terminal. The namespace will be persistentbetween console sessions within one Blender session.

Press Ctrl-D to pause the IPython session and return to Blender."""

# -*- coding: UTF-8 -*-

# ar - ARchitecture library# Copyright (C) 2009 www.stani.be## This program is free software: you can redistribute it and/or modify# it under the terms of the GNU General Public License as published by# the Free Software Foundation, either version 3 of the License, or# (at your option) any later version.## This program is distributed in the hope that it will be useful,# but WITHOUT ANY WARRANTY; without even the implied warranty of# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the# GNU General Public License for more details.## You should have received a copy of the GNU General Public License# along with this program. If not, see http://www.gnu.org/licenses/

Make sure you start Blender from a terminal and not from the start menu, as IPython will run in the terminal. You can start the IPython terminal from the Script window in Blender. (Scripts > System > Ipython (Terminal) ) Just like in my previous blog post, each time a Python statement is entered, the Blender window is updated. So you can move a cube and see the result, if you type:

In [1]: cube = bpy.data.objects['Cube']

In [2]: cube.LocX = -1

When you want to return to Blender, press Ctrl-D. If you restart later the IPython terminal, it will remember any commands you have typed or any variables you have declared (like cube in the example).

IPython has a different prompt which makes it easy to go back to previous input statements or output values:

In [1]: a=1

In [2]: print a1

In [3]: aOut[3]: 1

In [4]: exec _i2 # execute second command1

In [5]: exec In[2:4] # execute multiple previous commands1

In [6]: b=_3 # third ouput value

In [7]: a==bOut[7]: True

If you prefer a standard python prompt (>>>), just enter '%doctest_mode':

In [1]: %doctest_mode*** Pasting of code with ">>>" or "..." has been enabled.Exception reporting mode: PlainDoctest mode is: ON

As shown in the last example auto completion works even for import statements.

Altough the Blender window updates itself, the Blender user interface is still irresponsive when running an IPython session. In a future blog post I'll show how to run IPython inside the Blender window in such way that the user interface stays fully responsive.

Friday, March 27, 2009

A while ago I blogged about my winning coin design. As an architect and artist I have switched some years ago to free software. A lot of so called experts would tell me that is impossible. They need Photoshop, Illustrator, Maya, ... on a fancy Macbook. However if I look to what they produce, I see no problem in making that with Gimp, Inkscape, Blender, ... even on an underpowered netbook. I did mainly this blogpost to proof not only that they are wrong, but also to showcase a design, which they even wouldn't be able to make with any proprietary software.

The reactions were overwhelming both from the free software world and outside. The Dutch architecture site did a competition for who could read all the names of the architects. I've been told the design featured in a popular Dutch comic Fokke & Sukke. (Anyone has a reference to this?) Rem Koolhaas was happy he was number one. Also typography sites showed a lot of interest. The Ministry of Finance promoted the coin on national Dutch television with this clip. (Unfortunately I was not involved in the production of the clip, otherwise it would have been 'Blendered'.) The more this kind of success stories pop up, the more people will be convinced to switch to free software.

Last month a French television crew of Avenue de l'Europe (FR3) came to interview me about the coin. They are making a documentary about the 10 years existence of the euro. They chose my design as one of the most remarkable in the history of the euro. As the documentary is about the total history of the euro, I will probably get not more than one minute or maybe just some seconds. The emission is tomorrow 28/3 at 18h30 at FR3: http://info.france3.fr/avenue-europe

In the preparation emails for the interview, I felt they were more interested in the design than in free software. So in order to give some publicity, I wore an Ubuntu T-shirt for the interview. As a location I chose the Fablab in Amsterdam. (They are still looking for people experienced with (graphical) free software or writing 3d printer drivers. If you want to help out, contact alex*waag.org). I guess the television crew really have never heard about free software design, because one of them asked me if I went for holiday in South Africa recently when she saw my Ubuntu T-shirt.

Monday, March 23, 2009

Blender did not provide an interactive shell by default in the past. This changed a bit with the Interactive Python Console of Campbell Barton (aka ideasman42), which is accessible from the script window (Scripts > System > Interactive Python Console). Unfortunately this console does not support copy&paste, word wrapping, prompts, ...

I wrote a quick script in case you want to interact with Blender from a real Python console. Save it in your Blender home scripts folder (~/.Blender/scripts) as "terminal.py".

__author__ = "Stani (SPE Python IDE)"__url__ = ["pythonide.stani.be", "www.blender.org", "www.python.org"]__bpydoc__ = """\This only works if you started Blender from a terminal.Otherwise Blender will freeze. The Python console willappear in the terminal. The namespace will be persistentbetween console sessions within one Blender session.

Press Ctrl-D to quit."""

# -*- coding: UTF-8 -*-

# ar - ARchitecture library# Copyright (C) 2009 www.stani.be## This program is free software: you can redistribute it and/or modify# it under the terms of the GNU General Public License as published by# the Free Software Foundation, either version 3 of the License, or# (at your option) any later version.## This program is distributed in the hope that it will be useful,# but WITHOUT ANY WARRANTY; without even the implied warranty of# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the# GNU General Public License for more details.# # You should have received a copy of the GNU General Public License# along with this program. If not, see http://www.gnu.org/licenses/

To use it, you need to start Blender from a terminal (with compiz turned off):

$ blender -w

This is very important, otherwise Blender will be blocked waiting for input at an invisible terminal. The terminal console can be started from the script window: Scripts > System > Terminal. The modules 'Blender' and 'bpy' are preloaded into the console, so you don't need to import them manually. Each time a Python statement is entered, the Blender window is updated. So you can move a cube and see the result, if you type:

>>> cube = bpy.data.objects['Cube']>>> cube.LocX = -1

You can quit the interactive console by pressing Ctrl-D. You can restart the terminal as many times as you wish and automagically all your local variables will be kept (such as 'cube' in the example).

The disadvantage is that the Blender window itself becomes unresponsive. For example you can not rotate the view during a Python console session. Also it would be much nicer to use IPython instead of the standard Python shell. However in a future blog post I'll have good news, if you want IPython integration inside Blender.

Sunday, March 8, 2009

PantoGraph is a prototype for a vector rendering engine, developed in python by Severn Clay Studio. This can be nice for architectural presentations. It is still beta, which means it gets quite slow for heavy drawings.

The ability to use simple closed, convex volumes to do a boolean “cut-away”

Control over lineweight and color for:

Silhouette

Crease

Mesh

Hidden lines

Curves

A simple GUI that allows the saving of pens and pen settings

It can be loaded as a python script from Blender. Don't bother with the installation instructions on the Pantograph homepage (like fiddling with your PYTHONPATH), as I wrote the following install script which takes care of everything (at least in Ubuntu Intrepid). Open a new text file with the name 'install_pantograph' and copy the following content inside:

Make the script executable, with right click (properties>permissions) in the file browser or from the terminal:

$ chmod +x install_pantograph

And run the script in the terminal as you will need to give your password to install the dependencies.

$ ./install_pantograph

After that you can access the pantograph renderer from the script window in Blender. First try it out with the default cube scene, before you let it crunch your heavy drawings.If you want follow the progress of the render, you can better disable compiz and start Blender from a terminal, where the progress will be shown:

Wednesday, October 29, 2008

IntroductionThe Dutch Ministry of Finance organized an architecture competition for which a selected group of architectural offices (unstudio, nox, ...) and artists were invited, including myself. The goal of the competition was not to design a building, but the new 5 euro commemorative coin with the theme 'Netherlands and Architecture'. The winner will be rewarded with a nice price, but most of all with the honor: his design will be realized and will be a legal coin within the Netherlands.

I approached the subject 'Netherlands and Architecture' from two points of view. On one hand I paid tribute to the rich Dutch architecture history and on the other hand to the contemporary quality of Dutch architecture. These form also the two sides of my coin. Traditionally the front of the coin needs to portray the queen, while the back side displays the value of the coin.

Front sideWhen someone looks closely (click above on picture to enlarge) to my portrait of the queen, it becomes clear that her portrait is constructed with names of important Dutch architects. On the outside the names are clearly readable, while they slowly get smaller to the center. Under a magnifying glass all names are readable, but not with only the human eye. It is fascinating to see how an old medium like a coin can be in this way a 'compact disc' of information.

The tension between what is readable and what not, is also a metaphor how time shapes history. Some big names of the past, might be smaller names in the future and vice versa. To reflect this idea, I chose to order the architects not alphabetically or chronologically but in a new way: I used the internet as a seismograph and ordered the architects by the number of hits on the internet.

Of course this order changes over time and as such this is another time stamp on the coin besides the number '2008'. Only the first 109 architects fitted on the coin, so that was immediately the selection. Apparently becoming famous goes exponentially:

In order to achieve the image I developed my own single-line font system. I let the line width change within the same character in order to evoke an underlying picture:

Back side

Nowadays Dutch architecture is famous for its strong conceptual approach. This translates itself in the fact that there are not only a lot of books about Dutch architects, but also by Dutch architects.

On the back side of the coin I treated the edge of the coin as a book shelve. The books rise as buildings towards the center. Through their careful placement they combine to outline the Netherlands, while birds’ silhouettes suggest the capitals of all the provinces. The following scheme reveals the process:

One of the issues was how many books to take: many thin books or fewer thick books. With one very thick book you would only get a circle. To get the best approximation of the Netherlands you would need books of only one page, which is not optimal either. Therefore I needed to find the optimum between these two extremes which you can see in the scheme below. On the left you see the approximation of the Netherlands, in the middle you see the 'skyline' of the books and on the right you see the difference between the 'skyline' of the books and of the border line of the Netherlands:

The following is the idea sketch for the birds. Each bird flies above the capital of each Dutch province. In the final coin these random birds are replaced with a bird which is typical for that province.

TechnologyThe whole design was done for 100% with free software. The biggest part consists of custom software in Python, of course within the SPE editor. For the visual power I used PIL and pyCairo. From time to time also Gimp, Inkscape and Phatch helped quite a bit. All the developing and processing was done on GNU/Linux machines which were running Ubuntu/Debian. In the end I had to collaborate closely on location together with the technicians of the Royal Dutch Mint (coin factory). So all the last bits were done on my Asus Eee PC. (I am still wondering why Asus doesn't offer Ubuntu on its netbooks.) The Eee laptop took a bit longer (30 seconds instead of 3 seconds to generate a whole coin), but did the job just fine. For looking up the number of hits on the internet, I rediscovered Yahoo, which provides a much better api for automatic querying than its competitors. Of course the jury judged only the design and not the software used as others used Maya, Illustrator, ...

And the winner is...I am proud to announce that I won the competition! So soon 350.000 Dutch people will use the fruits of free software. I would have loved to release the coin under the GPL, which could maybe solve the financial crisis. However for obvious reasons I was not allowed to do that. There will be also special editions for collectors which can be bought world wide: a massive silver edition for € 30,95 and a massive gold edition for € 194,95. They will be probably sold out quickly as these are real collectors items. The coin is released in all Dutch post offices to the public the same day as the Intrepid Ibex: 30th October 2008.

Here are some scans of the real coin:

The coin will be advertised 20 times on prime time on Dutch television with a nice video clip (will be available soon) and advertisements will run in several newspapers. Today was the official launch of the coin, with from left to right: myself, Secretary of State for Finance De Jager, the Chief government Architect Liesbeth van der Pol and Master of the Mint Maarten Brouwer...

Wednesday, June 11, 2008

If you need to give presentations with your laptop and you are running Ubuntu Hardy, you might find that the gnome-display-properties (System>Preferences>Screen Resolution) do not work out of the box. So it is impossible to connect a beamer unless you clone. The same is true for a dual screen setup with Compiz.

There is however a very easy trick to solve this. I have tested it with an Asus Eee PC 701 4G and with my Ati Radeon X600 desktop system. I am now enjoying running dual screen with all the 3d desktops enabled.

The problem is that the default screen size configuration is too small, which does not allow you to place too screens next to each other. On the other hand Compiz can not handle texture sizes bigger than 2048x2048, which means for example two monitors of 1024x768. If you want to use bigger resolution, it is still possible, but you will need to turn off compiz and will loose the 3d effects.

Monday, March 31, 2008

wxPython ships by default with the wx.MediaCtrl for very basic playback of music or videos. As I would like to do more advanced video manipulation, I was curious if I could use Gstreamer directly in wxPython to create my own pipelines. It was surprisingly easy.For those who don't know Gstreamer, I quote the website (http://www.gstreamer.org):

GStreamer is a library that allows the construction of graphs of media-handling components, ranging from simple playback to complex audio (mixing) and video (non-linear editing) processing. Applications can take advantage of advances in codec and filter technology transparently.

There are python bindings for it, of which the documentation can be found on http://pygstdocs.berlios.deI would also suggest to read these introductions to gstreamer & python: