The KNODA scripting tutorial

Horst Knorr

Version 0.0.3

Abstract

KNODA, or more exactly the hk_classes library, has an integrated Python interpreter. For further information about Python see http://www.python.org. This tutorial will not teach Python, it will only show the hk_classes/python interface. This tutorial is by no means complete, it only exists now because the final documentation hasn't been written yet.

The examples in this tutorial are based on the tables as described in the KNODA tutorial.


Table of Contents

1. The various actions
2. General object methods- the class hk_visible
3. Data sensitive methods
Objects of type hk_dsvisible - the class hk_datasource
Objects of type hk_dsdatavisible - the class hk_column
Objects of type hk_presentation - forms and reports
Handling forms
Handling reports
4. using hk_classes as a Python module
hk_drivermanager
hk_connection
hk_database
5. Tips and tricks
How to display the data
How to execute a query
How to create a table
How to create a calculated value field
How to use the last inserted value as a default for the next row that will be inserted
How to define macros
How to format numbers
How to print rows in alternating colours
How to set the focus in a form
How to react on pressed keys
How to load a file content into a field using a filedialog
How to add or modify data, copy data between 2 datasources etc.
How to load a subform

List of Figures

2.1. Geometry specific methods
2.2. Look and Feel methods
2.3. Miscelleanous methods
2.4. Predefined colour names
3.1. hk_classes overview
3.2. description of the most important classes
3.3. hk_datasource methods
3.4. hk_column data methods
3.5. hk_column type methods
3.6. hk_dsdatavisible methods
5.1. hk_column type methods

List of Examples

1.1. Hello world-program
2.1. Changing colour and position
3.1. rowposition
3.2. find a specific column
3.3. Read data
3.4. Write data
3.5. Search data
3.6. Read data
3.7. Write data
3.8. Search data
3.9. displaying a form
3.10. displaying a report
3.11. reportdata onprint
4.1. Python module basics
5.1. Show data
5.2. Execute a "SELECT" query
5.3. Execute an action query
5.4. create table
5.5. calculated values
5.6. default values
5.7. Macro example
5.8. Macro example (part II)
5.9. Formatting a number
5.10. Printing alternate colours
5.11. Setting the taborder
5.12. Setting the taborder for a specific field
5.13. Reacting on keyboard input
5.14. Loading a file content into a field
5.15. Copy data from an existing datasource to an existing table in the same database
5.16. Copy data from an existing datasource to an existing table in different databases (also different server backends)
5.17. Copy data from an existing datasource to a new table
5.18. Load a subform