talljosh: Flowchart Python

Visual programming in Python.


 About Flowchart Python

I have had the idea of creating some sort of programming language that relied on creating a visual flowchart rather than parsing a text file for several years now.  Only recently did I realised that with Python it is very easy to do.

Flowchart Python is essentially the Python programming language in visual form.  You write a program by setting up a flowchart.  When you run the flowchart, the software compiles to python byte-code, so that you can easily import modules you write in Flowchart Python into standard Python programs.  Flowchart Python does make a few additions to standard Python, which I intend to outline on this page when I get around to it.


 I have released version 1 of the program under the GNU General Public License.  The source code is available here:



In order to run the code, you will need the following:

  • Python 2.4 standard distribution (including Tkinter)
  • Pygame 1.7

Programming with Flowchart Python

Programs in Flowchart Python are fairly easy to understand, with program flow following the direction of the arrows.  Here are a few pointers to get you started:

The image to the left shows a placeholder, or pass block.  Similar to the pass statement in Python, a pass block doesn't actually do anything during program execution, but it serves to keep a position within the program structure.  Pass blocks are useful because you can substitute another block type in the place of a pass block.  Simply choose substitute from the modify menu.

This image shows an exec block.  During execution an exec block will run whatever instructions it contains as standard Python code.  Typically, you would use it for function calls, assignment statements, and built-in statements (eg. pass, del, print, yield, raise, import).  While you can use an exec block for compound statements (eg. if, while, for, try), this should be avoided because flowchart elements are provided for these purposes.

Other useful pointers include:

  • spacebar zooms the view to the selected block.
  • ctrl+mouse drag pans and zooms
  • alt+mouse drag pans only
  • loop escape block - exits the loop (a bit like the break command).
  • procedure - defines a procedure. Procedures can have multiple input and output routes, and do not return anything.
  • bottleneck - from multiple strands of execution, the same thing(s) will be run, then the original strand will be resumed.
  • group - allows you to group blocks and give explanatory comments.

Key Additions to Python

Flowchart Python makes a few additions to the Python programming language.  These are:

  • Every Flowchart Python program automatically imports the sys module.
  • Flowchart Python defines two special system variables, __strand__ and __strand_stack__, which keep track of which strand of program execution is being followed.  You should never need to read or modify either of these variables, and modifying them will produce undefined results.
  • Procedures.  A procedure is like a function, but can be entered by any number of routes, and may split the program flow along any number of exit routes.  For example, the image below shows a call to a ficticious procedure which divides the program flow depending on whether a is greater than, equal to, or lesser than b.