[Kst] branches/work/kst/portto4/kst

Joshua Netterfield drmrshdw at gmail.com
Wed Aug 31 21:48:30 UTC 2011


SVN commit 1250641 by joshuanetterfield:

Adds scripting functionality to Kst.
PyKst scripts can control and share data with a kst session.

ABOUT PYKST
===============================
(The following information is also available inside the svn tree at pyKst/README)

Currently python scripting is implemented. If you are interested in adding Kst support to
other languages, see below.

PyKst (available inside the svn tree at pyKst) is, at the time of writing, not stable
enough for serious use. For the time being, do not write scripts with it except to
test and to send feedback.

Scripting does not introduce any new dependencies to Kst, but PyKst  will not run
without certain libraries.

PyKst is tested on Python 2.6 and does not work with Python 3.x.

PyKst needs NumPy 1.6 and does not work with NumPy 1.5. If it is very important
that it should work with NumPy 1.5, modify pykstpp.py to work with the old
API (and submit these changes to kst!!) or send an email to the devel list.

PyKst currently is not portable as pykstpp.py contains C++ code which is
compiled upon first use. It should, instead, create a dynamic library at
Kst compile time. Also, it does not detect the location of the Qt library or
include files, so to get it to compile you might have to modify pykstpp.py.

Please email the Kst list with feature requests and bug reports. I am not able to work on
scripting as much as I have had the chance to do in the past two weeks because of
high school, but can certainly try to help with relatively minor fixes.

The fastest way to get started is to take a look at the examples inside the svn tree
at pyKst/

Documentation is available for now at hen.astro.utoronto.ca/pyKst or inside the
svn tree at pyKst/doc.

DEVELOPPER INFORMATION
===============================
(The following information is also available inside the svn tree at README.kstScript)

Kst implements a client-server interface for scripting. Scripts interacts with a running kst session.

This server is implemented in scriptserver.cpp.

Upon receiving a socket message from QLocalSocket, ScriptServer parses it. ScriptServer implements a map
between command strings and ScriptServer member functions. 

These commands include "newVector()", "getPlotList()", etc.

To edit a vector, you would call "beginEdit(Vector Name)". This would open an "interface". One interface
is DialogScriptInterface which simply allows a script to control a hidden dialog. Where speed is important,
other (hard-coded) interfaces are created. To close the interface, one would call "endEdit()".

ScriptServer also implements a very minimalistic language providing:

  - if statements in the form:

    if(...)
    fi()

  - variables in the form:
    $a=blah
    setText($a)

  - macros in the form:
    newMacro(a,d=c)
    setText($a)
    setColor($d)
    endMacro()

    Note that 'c' is not a default argument: they initialize a and d so you can run a macro while writing it.
    newMacro(...) runs the macro while it is being written. newMacro_(...) does not)

Note that kstScript (that is, the simple language ScriptServer understands) never uses quotes. It is therefore
important that extra spacing is not added. Comments are also not supported. I feel that it is not worth improving
this 'language'. If someone should have time, a port to javascript would certainly be better.

You can use tests/kstcontrol to write kstScript macros. A list of possible commands is shown inside kstcontrol on the
right hand side. To make macros permanent (i.e., load on start of kst) add them to the file "kstScript.txt".
kstcontrol outputs macros you create to stdout on endMacro().

Writing macros is preferred over implementing them directly in a language (say, python) because the underlying API is
not guaranteed to be consistent and macros allow multiple languages to all have similar functionality with better code
reuse.

To get a feel for how they are written, please see kstScript.txt.

To give a language the ability to communicate with kst, implement functions which use QLocalSocket to communicate with
ScriptServer. Refer to pykst whose source is available in pykst/pykst.py and pykst/pykstpp.py.


 A             README.kstScript  
 M  +1 -1      cmake/CMakeLists.txt  
 M  +1 -1      cmake/modules/KstMacros.cmake  
 M  +1 -1      cmake/src/kst/CMakeLists.txt  
 M  +1 -4      config.h  
 A             pyKst (directory)  
 A             pyKst/README  
 A             pyKst/bonjourMonde.py  
 A             pyKst/failsafetm.py  
 A             pyKst/ksnspire.py  
 A             pyKst/kstOwl.py  
 A             pyKst/pykst.py  
 A             pyKst/vectors.py  
 M  +3 -0      src/images/images.qrc  
 A             src/images/kstScript.txt  
 M  +2 -1      src/kst/kst.pro  
 M  +3 -0      src/libkst/coredocument.cpp  
 M  +2 -0      src/libkst/coredocument.h  
 M  +40 -0     src/libkst/datavector.cpp  
 M  +14 -11    src/libkst/datavector.h  
 M  +19 -1     src/libkst/editablevector.cpp  
 M  +6 -0      src/libkst/editablevector.h  
 M  +16 -2     src/libkst/matrix.cpp  
 M  +2 -0      src/libkst/matrix.h  
 M  +1 -0      src/libkst/object.cpp  
 M  +3 -1      src/libkst/object.h  
 U             src/libkst/objectstore.cpp  
 M  +130 -4    src/libkst/vector.cpp  
 M  +8 -0      src/libkst/vector.h  
 M  +15 -3     src/libkst/vectorfactory.cpp  
 M  +5 -0      src/libkstapp/application.cpp  
 M  +5 -0      src/libkstapp/arrowpropertiestab.cpp  
 M  +33 -0     src/libkstapp/axistab.cpp  
 M  +2 -0      src/libkstapp/builtingraphics.cpp  
 A             src/libkstapp/buttonitem.cpp   [License: GPL (v2+)]
 A             src/libkstapp/buttonitem.h   [License: GPL (v2+)]
 M  +32 -0     src/libkstapp/contenttab.cpp  
 M  +2 -0      src/libkstapp/contenttab.h  
 M  +40 -2     src/libkstapp/contenttab.ui  
 M  +6 -0      src/libkstapp/csddialog.cpp  
 M  +12 -0     src/libkstapp/curvedialog.cpp  
 M  +9 -0      src/libkstapp/datadialog.cpp  
 M  +2 -0      src/libkstapp/datadialog.h  
 M  +1 -0      src/libkstapp/datasourcedialog.h  
 M  +1 -1      src/libkstapp/datawizard.cpp  
 M  +3 -0      src/libkstapp/dialog.cpp  
 M  +2 -0      src/libkstapp/dialog.h  
 A             src/libkstapp/dialogscriptinterface.cpp   [License: GPL (v2+)]
 A             src/libkstapp/dialogscriptinterface.h   [License: GPL (v2+)]
 M  +7 -0      src/libkstapp/dimensionstab.cpp  
 M  +12 -0     src/libkstapp/dimensionstab.ui  
 M  +3 -0      src/libkstapp/editmultiplewidget.cpp  
 M  +6 -0      src/libkstapp/equationdialog.cpp  
 M  +1 -1      src/libkstapp/eventmonitordialog.cpp  
 M  +1 -1      src/libkstapp/exportgraphicsdialog.cpp  
 M  +16 -3     src/libkstapp/filltab.ui  
 M  +2 -0      src/libkstapp/filterfitdialog.cpp  
 M  +13 -0     src/libkstapp/histogramdialog.cpp  
 M  +18 -0     src/libkstapp/imagedialog.cpp  
 M  +3 -0      src/libkstapp/imagetab.ui  
 M  +2 -0      src/libkstapp/labelcreator.cpp  
 M  +9 -0      src/libkstapp/labelcreator.ui  
 M  +3 -0      src/libkstapp/labelpropertiestab.cpp  
 M  +11 -1     src/libkstapp/labelpropertiestab.ui  
 M  +3 -3      src/libkstapp/labelrenderer.h  
 A             src/libkstapp/labelscriptinterface.cpp   [License: GPL (v2+)]
 A             src/libkstapp/labelscriptinterface.h   [License: GPL (v2+)]
 M  +13 -0     src/libkstapp/labeltab.cpp  
 M  +16 -6     src/libkstapp/labeltab.ui  
 M  +6 -0      src/libkstapp/layouttab.cpp  
 M  +12 -0     src/libkstapp/layouttab.ui  
 M  +12 -2     src/libkstapp/legendtab.ui  
 M  +5 -3      src/libkstapp/libkstapp.pro  
 A             src/libkstapp/lineedititem.cpp   [License: GPL (v2+)]
 A             src/libkstapp/lineedititem.h   [License: GPL (v2+)]
 M  +2 -0      src/libkstapp/mainwindow.h  
 M  +25 -0     src/libkstapp/markerstab.cpp  
 M  +5 -1      src/libkstapp/markerstab.ui  
 M  +34 -0     src/libkstapp/matrixdialog.cpp  
 M  +2 -0      src/libkstapp/matrixdialog.h  
 M  +12 -0     src/libkstapp/matrixtab.ui  
 M  +9 -0      src/libkstapp/overridelabeltab.ui  
 U             src/libkstapp/plotaxis.cpp  
 M  +3 -0      src/libkstapp/powerspectrumdialog.cpp  
 M  +19 -6     src/libkstapp/rangetab.cpp  
 M  +2 -0      src/libkstapp/scalardialog.h  
 M  +6 -0      src/libkstapp/scalartab.ui  
 A             src/libkstapp/scriptinterface.cpp   [License: GPL (v2+)]
 A             src/libkstapp/scriptinterface.h   [License: GPL (v2+)]
 A             src/libkstapp/scriptserver.cpp   [License: GPL (v2+)]
 A             src/libkstapp/scriptserver.h   [License: GPL (v2+)]
 M  +2 -2      src/libkstapp/stringdialog.cpp  
 M  +2 -0      src/libkstapp/stringdialog.h  
 A             src/libkstapp/stringscriptinterface.cpp   [License: GPL (v2+)]
 A             src/libkstapp/stringscriptinterface.h   [License: GPL (v2+)]
 M  +2 -0      src/libkstapp/stroketab.cpp  
 M  +21 -2     src/libkstapp/stroketab.ui  
 M  +11 -1     src/libkstapp/themedialog.ui  
 M  +8 -4      src/libkstapp/vectordialog.cpp  
 M  +2 -0      src/libkstapp/vectordialog.h  
 M  +3 -0      src/libkstapp/vectortab.ui  
 M  +3 -2      src/libkstapp/viewitem.h  
 M  +4 -0      src/libkstapp/viewitemdialog.cpp  
 M  +1 -0      src/libkstapp/viewitemdialog.h  
 A             src/libkstapp/viewitemscriptinterface.cpp   [License: GPL (v2+)]
 A             src/libkstapp/viewitemscriptinterface.h   [License: GPL (v2+)]
 M  +4 -2      src/widgets/colorpalette.cpp  
 M  +14 -7     src/widgets/curveappearance.cpp  
 M  +20 -2     src/widgets/curveappearance.ui  
 M  +42 -7     src/widgets/curveplacement.cpp  
 M  +6 -3      src/widgets/curveplacement.ui  
 M  +4 -0      src/widgets/datarange.cpp  
 M  +6 -0      src/widgets/datarange.ui  
 M  +6 -0      src/widgets/datasourceselector.cpp  
 M  +14 -1     src/widgets/fftoptions.cpp  
 M  +7 -1      src/widgets/matrixselector.cpp  
 M  +1 -0      src/widgets/matrixselector.h  
 M  +1 -1      src/widgets/scalarselector.cpp  
 M  +1 -1      src/widgets/stringselector.cpp  
 M  +26 -1     src/widgets/vectorselector.cpp  
 A             tests/kstcontrol (directory)  
 A             tests/kstcontrol/KstControl.pro  
 A             tests/kstcontrol/KstControl.pro.user  
 A             tests/kstcontrol/KstControl.pro.user.2.2pre5  
 A             tests/kstcontrol/Makefile  
 A             tests/kstcontrol/cwidget.cpp   [License: UNKNOWN]
 A             tests/kstcontrol/cwidget.h   [License: UNKNOWN]
 A             tests/kstcontrol/cwidget.ui  
 A             tests/kstcontrol/main.cpp   [License: UNKNOWN]


http://websvn.kde.org/?view=rev&revision=1250641


More information about the Kst mailing list