Cantor backend selection screen
In 2013 I developed a Python 2 backend for Cantor, a project funded in part by Google Summer of Code. Now this backend is available in Cantor released in KDE 4.12.
Cantor is a mathematical/scientific programming software, a frontend providing IDE features (syntax highlighting, tab-complete, variables management, and more) and a advanced terminal. Cantor support a lot of mathematical engines like Octave, Sage, Maxima, Kalgebra, Qualculate, R, Scilab (developed by me too), and now, Python 2. You can see Cantor as a Matlab-like software, but it uses other mathematical environment/software as programming language.
This post I will do a “feature tour” in Python 2 backend to show Cantor software for scientific python developers community.
Initial Screen – Syntax Highlighting and Tab Complete
Cantor initial screen
After select the Python 2 backend, Cantor will show the initial screen. This window have a big widget for the Python 2 terminal, and two side panels – one to show the Python 2 help and the other to variables management.
Let’s see some commands inputs in the terminal:
Cantor is highlighting the Python 2 syntax and, in side panel, you can see the variables created.
Now, let’s create new variables with similar names to test the tab complete. See the picture below:
Tab complete for variables
After create variables variable_x, variable_y e variable_var, we can write in terminal var and type tab key twice – Cantor will show the variables and functions with the same piece of word. Tab complete is available for module functions too.
Tab complete for module functions
Cantor show error messages in terminal too. Next figure show a import error:
You can save the terminal state or just the input commands and their outputs in a file. Cantor allows upload/download a terminal example for a remote server. You can explore this features in “File” menu.
Cantor shows Python help from help command in a side panel. The picture below shows the help for complex class:
Cantor uses Qt/KDE technologies, so you can change the window format moving the side panels. Next picture show the window with the variables management in the left side and the help panel in the right side.
Panels in different sides
Variables management panel
Variables management panel shows the variables created in Cantor session, showing their labels and values. The panel have some additional functions too, in buttons bottom the widget. These functions are, from left to right, Add variable, Load variables, Save variables, and Clear all variables.
Add variable just open a pop-up window to input a label and a value to a variable.
Load variables and Save variables uses shelve module to data persistence. When the buttons are clicked, Cantor loads scripts to, in first case, read and load variables to the session, and, in second case, save the python dictionary in a file. The figures below show this operations:
The function Clear all variables delete each variable from Python dictionary. The code is below:
Code for graphic creation using matplotlib
Graphic loaded in Cantor
The figures below show the graphic loaded in Cantor worksheet. When a session is exported, the graphic will be exported too. This feature can be configured to create the graphics in a new window – this is the default option.
Conclusion and Future
This is the first stable version of Python 2 support in Cantor. It is working good, but you can see the bug presence in some parts of software.
I would like to see some feedbacks from mathematical/scientific programming python community. I am not a “pythonist”, so the python community can find bugs and strange behaviours in the software better than me. I would like to see some feature suggestions too.
For the next version, Python 2 backend will have support to script editor – unfortunately, I can not develop it for this release.
If you are interested in the backend development, my blog have a set of posts (in Portuguese and English) about it. You can download the source code in Cantor repository – the license is GPLv2. And you can submit a bug report in KDE bugzilla.
And you can contact me in comments area below or in my mail address filipe at kde.org.