I want to import win32gui and win32api in CoDeSys. At importing the win32gui and win32api modules, the CoDeSys shows "ImportError: No module named win32api, win32gui".
The Pywin32 Plug-in package was installed in Python installation folder. And all of the modules of Pywin32, inc. win32gui and win32api, can be imported and works well in Python 2.7 environment. I try to import the win32gui and win32api under CoDeSys v3, because i want to access some CoDeSys diagnose windows. Then i find that it does't works. I have also try to change the path of CoDeSys Python workspace, even attempt to directly give the path of module file. But unfortunately, all trying failed.
Interesting is import win32con in CoDeSys no problem. I find that, the different are: win32con module is a file with ".py" extension, but win32gui and win32api are ".pyd" file.
So question:
Can CoDeSys Python platform support importing model with ".pyd" extension? There are some way or ideas to resolve this problem?
Regards.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
hhz hat geschrieben:
So question:
Can CoDeSys Python platform support importing model with ".pyd" extension? There are some way or ideas to resolve this problem?
No, you can't import modules with ".pyd" file extension. CODESYS integrates IronPython V2.7 and not CPython V2.7.
M.Keller hat geschrieben:
Hi hhz.
No, you can't import modules with ".pyd" file extension. CODESYS integrates IronPython V2.7 and not CPython V2.7.
You can use other Python modules with CODESYS but you have to check if the requirements can be solved. For more information please look at the FAQ of IronPython and the other documentation.
That is what i guess. But fortunately, I have found another way to call the sec. Python scripting by CoDeSys and run it out of CoDeSys in Python 2.7 + Pywin32 environment simultaneously. So that the problem resolved.
M.Keller hat geschrieben:
You said something about accessing some CODESYS diagnose windows. For what reason? What is your use case for using win32api and win32gui?
For example, When CoDeSys open the old profil project, there is a update diagnose windows shown with selection-options, confirm button, Information text etc. In this case the update process can be continued only when the windows closed with OK-confirm (and/or plus some option change ). Another example is at exporting/importing project. Python scripting was used to control menu and start the export process :
But there is no chance to directly give the export file path and name by Python in CoDeSys (e.g. as arguments), because there are more then one diagnose windows shown one by one after export command executed.
In this case, i think, may be i can use Python API (Pywi32 Plugin) to access the diagnose windows and control they (like as AutoIt do) .
BR.
HHZ
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
M.Keller hat geschrieben:
Hi hhz.
What kind of work is the python script doing? Are you testing your software or do you want to automate recurring work?
BR
Martin
the python, which run out of CoDeSys, observes the shown CoDeSys diagnose windows and answer/confirm according to the preset settings. the goal is not to test the software but just to control it. The background is that I want to open a old project and update it. in this case a update diagnose windows will be shown, and I did not find a way to answer the windows and continue the update process.
Have you any idea, how to automatically open and update a old project with new CoDeSys Version (or profil version)? May be shall a generate a separate Title for this Question.
BR.
hhz
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
hhz hat geschrieben:
Have you any idea, how to automatically open and update a old project with new CoDeSys Version (or profil version)? May be shall a generate a separate Title for this Question.
Did you use the methods projects.open(...) and device.update(...) from the Scripting API? The upgrade of the project with a new profile is normally triggered by changes which require the new profile. For example, you add an object which supports additional options with the new profile.
BR
Martin
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi,
I want to import win32gui and win32api in CoDeSys. At importing the win32gui and win32api modules, the CoDeSys shows "ImportError: No module named win32api, win32gui".
The Pywin32 Plug-in package was installed in Python installation folder. And all of the modules of Pywin32, inc. win32gui and win32api, can be imported and works well in Python 2.7 environment. I try to import the win32gui and win32api under CoDeSys v3, because i want to access some CoDeSys diagnose windows. Then i find that it does't works. I have also try to change the path of CoDeSys Python workspace, even attempt to directly give the path of module file. But unfortunately, all trying failed.
Interesting is import win32con in CoDeSys no problem. I find that, the different are: win32con module is a file with ".py" extension, but win32gui and win32api are ".pyd" file.
So question:
Can CoDeSys Python platform support importing model with ".pyd" extension? There are some way or ideas to resolve this problem?
Regards.
Hi hhz.
No, you can't import modules with ".pyd" file extension. CODESYS integrates IronPython V2.7 and not CPython V2.7.
FAQ of IronPython and the other documentation.
You said something about accessing some CODESYS diagnose windows. For what reason? What is your use case for using win32api and win32gui?
BR
Martin
Hi Keller,
thanks for your answer.
That is what i guess. But fortunately, I have found another way to call the sec. Python scripting by CoDeSys and run it out of CoDeSys in Python 2.7 + Pywin32 environment simultaneously. So that the problem resolved.
For example, When CoDeSys open the old profil project, there is a update diagnose windows shown with selection-options, confirm button, Information text etc. In this case the update process can be continued only when the windows closed with OK-confirm (and/or plus some option change ). Another example is at exporting/importing project. Python scripting was used to control menu and start the export process :
But there is no chance to directly give the export file path and name by Python in CoDeSys (e.g. as arguments), because there are more then one diagnose windows shown one by one after export command executed.
In this case, i think, may be i can use Python API (Pywi32 Plugin) to access the diagnose windows and control they (like as AutoIt do) .
BR.
HHZ
Hi hhz.
What kind of work is the python script doing? Are you testing your software or do you want to automate recurring work?
BR
Martin
Hi Keller,
the python, which run out of CoDeSys, observes the shown CoDeSys diagnose windows and answer/confirm according to the preset settings. the goal is not to test the software but just to control it. The background is that I want to open a old project and update it. in this case a update diagnose windows will be shown, and I did not find a way to answer the windows and continue the update process.
Have you any idea, how to automatically open and update a old project with new CoDeSys Version (or profil version)? May be shall a generate a separate Title for this Question.
BR.
hhz
Hi hhz.
Did you use the methods projects.open(...) and device.update(...) from the Scripting API? The upgrade of the project with a new profile is normally triggered by changes which require the new profile. For example, you add an object which supports additional options with the new profile.
BR
Martin