Interchanging hierarchical schematics at Eeschema

Readme for PyKicadSchematic-ID_Interchanger_RevC.py

Purpose: Interchanger tool for Kicad schematic pages.
Version: Alpha Version 
from 28th February 2013 
Written for Python 3.1. 
Author: Bernd Wiebus alias DL1EIC 
E-Mail: bernd.wiebus@gmx.de 
GNU-GPL NO WARRANTY!

Case of Application:
If the schematic is printed or plotted, the sequence of the subsheets will represent the sequence of the print and sheet numbering. But sometimes, it would be better to rearrange the sequence, just for better oversight. But it cannot changed by the program.
But the schematic file itsself (Mainschematic.sch) can be manipulated.
 
Basic treatment:
Oben this file with a texteditor. At the end of the file you will find sequences contained between "$Sheet" and "$EndSheet". This are the subsheets of the next deeper layer, and there sequence represent the sequence of the subsheets and therefore the sequence of numbering and printing, too.
With the texteditor, you can change the sequence by copy/cut and paste, which solves the problem discussed before. 
The subscheets eventually will contain subsheets of deeper hierarchical layers. This deeper layers will move together with the moving of the layers as containers, too. If you want to change the sequences at this deeper hierarchical layers, you have to edit the containing subsheets.

Script:
It is an stand alone Python 3 script and has nothing to do with the kicad-python interface.
The script can alter the sequence of the "$Sheet/$EndSheet" blocks, and therefore the sequence of subsheets, numbering and printing.
First you have to save the schematic and close EEschema.
Then start the skript "PyKicadSchematic-ID_Interchanger_RevC.py" and choose your schematic.
The script will list all found subsheets.
If you see non, there would be none found (by error, or because there are just non).
Choose the subsheet to be moved by a single left mouseclick.
Now with a single left mouseclick choose the position, before you will insert this subsheet.
If you want to move a subsheet to the last place, first move it to the place next to last, and then move the last to the position before next to last.
Now save the schematic. It will safed to the same folder as "Mainschematic.sch" but with the name "MainschematicChanged.sch".
Now rename the files manually and start EEschema again with "Mainschematic.sch".

Testet with: Eeschema Version: (2013-02-27 BZR 3976)-testing
Build: wxWidgets 2.8.10 (no debug,Unicode,compiler with C++ ABI 1002,GCC 4.4.5,wx containers,compatible with 2.6)
Platform: Linux 2.6.32-5-686 i686, 32 bit, Little endian, wxGTK
Boost version: 1.53.0

The script should run without problems at Windows or Linux, if Python3 is installed.
Python3 is common at most linux distributions by package. Windows User might find some clues at this discussion (German):
http://www.mikrocontroller.net/topic/280970#new
more information about Python: http://en.wikipedia.org/wiki/Python_%28programming_language%29 

Problems:
If you get an error message: "ImportError: No module named tkinter"
so you tried wrongly with Python 2.x instead of Python 3.
If nothing happens, at most cases, you have tried with Python 2.x instead of Python 3, too.

Good luck!
Bernd Wiebus alias dl1eic