Evaluate a Python expression (Kylix ready)
WARNING !!! The evaluation of an expression works only for arithmetic expressions
and not for instructions ! The use of variables and functions is of course allowed
but constructs like for, def, class, print, import... are not allowed.
Use Exec... instead (like ExecStrings).
- Create a new Form
- Drop a TMemo (or a TRichEdit)
- Drop a TPythonGUIInputOutput for displaying Python's messages
- Drop a TMemo for the source code
- Drop a TPythonEngine
- Connect the attribute IO of the TPythonEngine to the TPythonGUIInputOutput.
- Connect the attribute Output of TPythonGUIInputOutput to the TRichEdit.
- Drop a TButton and call it "Evaluate script"
- Double-click on the button and add:
That's all !
- Compile and execute.
- Write in the Memo1: print 2+2
- Click on the Execute button
- You should see in the Output window: 4
Comments (0)
You don't have permission to comment on this page.