In MatDeck, programming is commonly done using MatDeck Script with a atmosphere reminiscent of C++. However, due to the increasing popularity of Python, especially among newcomers, MatDeck has been enriched with a new feature of programming in Python. MatDeck’s framework allows simultaneous text editing, script language coding (including both: MatDeck Script and Python), GUI capabilities, and data visualization. Beginners in programming may prefer Python for their first steps. However, if a greater processing speed is required the option to execute MatDeck documents and Script codes at almost C++ speed using “Build And Run Exe” option still remains. This where maximum computational speed is needed, there also exists the possibility to write low level processing procedures in C++ language and then add them in as plug-ins.
Here, you will find an example which illustrates how Python code is written and executed in MatDeck documents. Further, through the use of examples, it is illustrated how to exchange variables between MatDeck Script and Python, and further specific scenarios regarding Python programming in MatDeck.
Python scripts are written within MatDeck documents using Python keywords and syntax in the regular Code Editor in text mode is separated by using the tags #py…###. It should be made clear that you can also have a special MatDeck document which contains only Python code. Variables defined in MatDeck Script can be exchanged to Python for further processing, and returned back. There is a type match for MatDeck variables: boolean, integer, double, complex, string, vector which is interpreted as a Python list. Python tuple variable is transferred back to MatDeck as vector. Use of graphics, GUI and widgets make programming more fun and interactive for many people. Python, as well as MatDeck, has many graphical options even within standard distributions. The Python graphics can be used in MatDeck. However, graphic objects created in Python cannot be embedded or accessed in MatDeck documents. They are fully separated as Python objects, which can be manipulated only from Python.