Pular para o conteúdo

Side panels in Python Backend for Cantor: Help and Variable Management

In last weeks I developed some new features to python backend for Cantor. In this post I will write about two of their: the help and the variable management, implemented as panels.

python_backend_help_panel python_backend_variable_management

 Help Panel on left; Variable Management Panel on right

Help panel

Help panel shows the help output in a separated panel, facilitating the consult of this information. To use it, simply use help command as in python interactive mode, as in example below:


Below a bigger help output, from a python module:


In previous picture, did you see some change in variable management panel?

Variable Management panel

Variable management panel is a great feature provide by Cantor, but until now just Octave backend had it. This feature show the variables defined in the session, their values, and allow some interesting functions to manipulate these variables.

You can define a lot of variables in python session and these variables will be shown in the panel. See:


In previous picture, I defined a integer variables x and y, a string a, and two modules: numpy and scipy, this last as sc. All this values are shown in panel.

Now I will change some values defined previously and will add some others:


See, now I defined a variable aa by the concatenation of two a‘s; the value of a is now aa; div is the division of y by x. I have a 2-dimensional matrix mtr defined by matrix function from numpy module; a python class HelloWorldClass and a object hello.

I can change the value of some these variable manipulating their values in the panel. For example, I can rewrite the x variable from 35 to 350, clicking in value column and typing 350.

But the more interesting features are provide by the buttons bellow this panel. These buttons load python scripts to run some feature. There are: add variable, load variables from a file, save variables to a file and clear all variables in the session.

Add variable is quite simple: a dialog is open and you type the variable and their value:

python_backend_variable_management_usecase4Save/Load use shelve module to save and load the variables of the session. But, it is important to say, this feature don’t save all the variables because shelve module have some limitations. For example, I saved this session to a file named “python_session.txt”. The python code loaded is:


After save, I will clear the session. The python code loaded is:

python_backend_variable_management_usecase6And, finally, I will load the variables. The python code loaded ans the variable panel is show below:



It is working now but I need some more tests, in special the save/load python objects defined by user and modules.

I would like to see some feedback from you. The code is hosted in python-backend branch from Cantor repository, so you can test it.

2 comentários em “Side panels in Python Backend for Cantor: Help and Variable Management”

  1. Hi @Sudhir, you are welcome!

    Really I do not have experience in develop KDE using Python. This backend use Python/C API and it is developed in C++ and Qt. It have a bit of Python code, but it is used only in user environment, not in python backend code properly.

Deixe um comentário

O seu endereço de e-mail não será publicado. Campos obrigatórios são marcados com *