Welcome to our new forum
All users of the legacy CODESYS Forums, please create a new account at account.codesys.com. But make sure to use the same E-Mail address as in the old Forum. Then your posts will be matched. Close

How to read structure in CodeSys using pythong script?

SashaSasha
2017-10-06
2017-10-09
  • SashaSasha - 2017-10-06

    Hi all,

    I have some question about python for CodeSys:

    1. How can I read all structure without knowledge of fields inside this structure using python?

    2. Does CodeSys has some alternatives for tkFileDialog library? How can I create some dialog boxes for opening/clothing files?

     
  • mkeller - 2017-10-09

    Hi SashaSasha.

    SashaSasha hat geschrieben:
    1. How can I read all structure without knowledge of fields inside this structure using python?

    What do you mean with "read all structure..."? Read the online value through Monitoring or finding and reading the DUT objects?

    SashaSasha hat geschrieben:
    2. Does CodeSys has some alternatives for tkFileDialog library? How can I create some dialog boxes for opening/clothing files?

    Look in the Scripting API documenation for the interface/class which contains methods to open dialogs.

    Here some example code:```

    print("Now, the user can select files and directories")
    res = system.ui.open_file_dialog("Choose multiple files:", filter="Text files (.txt)|.txt|Image Files(.BMP;.JPG;.GIF)|.BMP;.JPG;.GIF|All files (.)|.", filter_index = 0, multiselect=True)
    print("The user did choose: '%s'" % str(res)) # res is a tuple as multiselect is true.

    ```
    BR
    Martin

     

Log in to post a comment.