CODESYS - the IEC 61131-3 automation software
https://forum.codesys.com/

How to read structure in CodeSys using pythong script?
https://forum.codesys.com/viewtopic.php?f=18&t=8206
Page 1 of 1

Author:  SashaSasha [ Fri Oct 06, 2017 8:49 am ]
Post subject:  How to read structure in CodeSys using pythong script?

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?

Author:  M.Keller [ Mon Oct 09, 2017 3:08 pm ]
Post subject:  Re: How to read structure in CodeSys using pythong script?

Hi SashaSasha.

SashaSasha wrote:
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 wrote:
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 IScriptUI which contains methods to open dialogs.

Here some example code:
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

Page 1 of 1 All times are UTC+01:00
Powered by phpBB® Forum Software © phpBB Limited
https://www.phpbb.com/