How to load a file content into a field using a filedialog
Prev | Chapter 5. Tips and tricks | Next

## How to load a file content into a field using a filedialog

Put the following code into the on_click action of a button:

Example 5.14. Loading a file content into a field

    filename=hk_this.show_filedialog()
    file=open(filename)
    data=file.read()
    datafield=hk_thisform.get_pyvisible("datafield")
    datafield.set_value(data)

This example lets the user select a file(line 1) and load its content (line 2 and 3) into a field (line 4 and 5).

Prev | Up | Next
How to react on pressed keys | Home | How to add or modify data, copy data between 2 datasources etc.