We have developed an unofficial open source toolkit for “mappView - Compound Widgets”. Toolkit is written with Python.
Main idea came because we are currently lacking the graphical editor for editing compound widgets and we bumped into a task where editing widgets graphically was needed…
Python scripts basically transfer the “widgets” information between compound widgets library and autogenerated mappView content → like described in our help:
[B&R Online Help]
Scripts have been “wrapped” to automation studio sample project and moved to GitHub. Please find it from following link:
First Off awesome idea @markus.mustonen, thanks for implementing this and welcome to the community!
I have two things to note maybe something to expand the script with.
#1 I have multiple WidgetLib’s and they all have their own unique name but the script expects the default WidgetLib so it didn’t run. I changed the WidgetsDir path and now it’s running but I’m getting an error.
#2 Error in reading the attributes
Exception has occurred: KeyError
'id'
File "C:\projects\IIOT\AS\Logical\Scripts\CompoundWidgetsToolkit\ReadWidgetsToVisu.py", line 24, in extract_compound_widget_attributes
"id": root.attrib["id"],
File "C:\projects\IIOT\AS\Logical\Scripts\CompoundWidgetsToolkit\ReadWidgetsToVisu.py", line 211, in create_content_from_widgets
attributes = extract_compound_widget_attributes(LayoutPath + '\\' + LayoutFile)
File "C:\projects\IIOT\AS\Logical\Scripts\CompoundWidgetsToolkit\ReadWidgetsToVisu.py", line 289, in <module>
create_content_from_widgets(WidgetsDir, FindFilePrefix, VisuRootDir)
KeyError: 'id'
I didn’t see any restrictions AS4 vs. AS6 and based on the basic structure of xml content files they should be the same.
Hello @marcel.voigt ,
Because this was my first post, I checked the issue asap.
There was some minor bug in the script, so it didn’t work as I had planned.
Please download and import the updated toolkit “CompoundWidgetsToolkit_V1.0.2.zip”.
This version accepts also library name in the settings, so it is more flexible in real life.
Hopefully this will fix your issue
@markus.mustonen Thanks for reacting so quickly and fixing the bug and adding the parameter!
Unfortunately I ran into a new error
Exception has occurred: UnboundLocalError
local variable 'LayoutID' referenced before assignment
File "C:\projects\IIOT\AS\Logical\Scripts\CompoundWidgetsToolkit\ReadWidgetsToVisu.py", line 217, in create_content_from_widgets
createMappViewWidgetsFolder(pages_path,LayoutID)
File "C:\projects\IIOT\AS\Logical\Scripts\CompoundWidgetsToolkit\ReadWidgetsToVisu.py", line 291, in <module>
create_content_from_widgets(WidgetsDir, FindFilePrefix, VisuRootDir)
UnboundLocalError: local variable 'LayoutID' referenced before assignment
BUT I can tell why it happens!
I didn’t have local layouts under the Visualization, I only had global layouts.
Simply adding a layout to the local folder fixed that issue and the script ran fine.
It created content for each of the 6 compound widgets I have in that one library which is absolutely awesome!.
Actually I have a suggestion to maybe avoid the layout issue all together.
Instead of creating a page so you can then create the content under it, why not create an
“Area Content” package for the compound widgets.
Thank you, enjoy the holidays and say Hei to Joulupukki for me
I actually have another suggestion.
Now that you have the WidgetLib name as parameter maybe name the page or area content package after the WidgetLib. That way in case you have multiple like I do it keeps them separated by library.
Hi @markus.mustonen, I find this toolkit very useful. I think there are some tips for improvement and extension. It would be great to upload it to BR or any other GitHub repository. This way, everything can be tracked, and users will always be able to download the latest version. Just an idea. Thank you for your contribution and I wish you a nice holiday time
Hi @kovarj ,
Thank’s for the encouraging feedback.
I realized this same thing yesterday. Right place for this “toolkit” would be gitHub. I will publish this there in near future, so it will be easier to share and track changes.
I will also add the link to this same thread, when ready.
Hello @kovarj , now scripts can be found from GitHub…
There is entire demo project available for easier testing (and development) of the scripts for the community users.
I also added “how to” - video to scripts folder, so it is easier to see how toolkit it is supposed to work.
Cheers