# MappView Compound widgets toolkit

**URL:** <https://community.br-automation.com/t/mappview-compound-widgets-toolkit/5287>\
**Category:** How-To & Wikis\
**Tags:** mapp-view, toolkit\
**Created:** [December 20, 2024, 4:02pm UTC](https://community.br-automation.com/t/mappview-compound-widgets-toolkit/5287 "2024-12-20T16:02:44Z")\
**Posts on this page:** 14\
**Page:** 1

<div class="post-metadata">

**Author:** ![markus.mustonen](https://avatars.discourse-cdn.com/v4/letter/m/FF8800/32.png) [@markus.mustonen](https://community.br-automation.com/u/markus.mustonen)\
**Post date:** [December 20, 2024, 4:02pm UTC](https://community.br-automation.com/t/mappview-compound-widgets-toolkit/5287/1 "2024-12-20T16:02:44Z")

</div>

Hello all!

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](https://help.br-automation.com/#/en/4/visualization%2Fmappview%2Fengineering%2Flv_customwidgets%2Flv_customwidgets_compound%2Flv_customwidgets_compound_edit%2Flv_customwidgets_compound_widget.html)]

Scripts have been “wrapped” to automation studio sample project and moved to GitHub. Please find it from following link:

> **[GitHub - mustonenm/mvCoWidgetsTools: B&R toolkit for editing mappView compound widgets...](https://github.com/mustonenm/mvCoWidgetsTools)**
>
> B&R toolkit for editing mappView compound widgets in graphical editor

Cheers 🙂

---

<div class="post-metadata">

**Author:** ![marcel.voigt](https://dub1.discourse-cdn.com/brcommunity/user_avatar/community.br-automation.com/marcel.voigt/32/97_2.png) [@marcel.voigt](https://community.br-automation.com/u/marcel.voigt)\
**Post date:** [December 20, 2024, 4:56pm UTC](https://community.br-automation.com/t/mappview-compound-widgets-toolkit/5287/2 "2024-12-20T16:56:34Z")

</div>

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

```auto
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.

Any ideas?

---

<div class="post-metadata">

**Author:** ![markus.mustonen](https://avatars.discourse-cdn.com/v4/letter/m/FF8800/32.png) [@markus.mustonen](https://community.br-automation.com/u/markus.mustonen)\
**Post date:** [December 20, 2024, 6:52pm UTC](https://community.br-automation.com/t/mappview-compound-widgets-toolkit/5287/3 "2024-12-20T18:52:34Z")

</div>

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 🙂

 ![WhatsNew_Settings_JSON_V1_0_2](https://europe1.discourse-cdn.com/brcommunity/original/2X/d/d61e46f5741fc6a77e2f3f8260bd47647f7d30e3.jpeg)

Cheers  
Markus

---

<div class="post-metadata">

**Author:** ![marcel.voigt](https://dub1.discourse-cdn.com/brcommunity/user_avatar/community.br-automation.com/marcel.voigt/32/97_2.png) [@marcel.voigt](https://community.br-automation.com/u/marcel.voigt)\
**Post date:** [December 20, 2024, 7:21pm UTC](https://community.br-automation.com/t/mappview-compound-widgets-toolkit/5287/4 "2024-12-20T19:21:35Z")

</div>

@markus.mustonen Thanks for reacting so quickly and fixing the bug and adding the parameter!

Unfortunately I ran into a new error

```auto
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.

#mapp-view are you seeing this…

---

<div class="post-metadata">

**Author:** ![markus.mustonen](https://avatars.discourse-cdn.com/v4/letter/m/FF8800/32.png) [@markus.mustonen](https://community.br-automation.com/u/markus.mustonen)\
**Post date:** [December 20, 2024, 7:40pm UTC](https://community.br-automation.com/t/mappview-compound-widgets-toolkit/5287/5 "2024-12-20T19:40:39Z")

</div>

@marcel.voigt You’re welcome and thank’s for the great feedback.

I will be checking for the improvements after the 🎅 holidays.

I am just glad that you could find this “toolkit” usefull 🙂

---

<div class="post-metadata">

**Author:** ![marcel.voigt](https://dub1.discourse-cdn.com/brcommunity/user_avatar/community.br-automation.com/marcel.voigt/32/97_2.png) [@marcel.voigt](https://community.br-automation.com/u/marcel.voigt)\
**Post date:** [December 20, 2024, 7:45pm UTC](https://community.br-automation.com/t/mappview-compound-widgets-toolkit/5287/6 "2024-12-20T19:45:14Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![markus.mustonen](https://avatars.discourse-cdn.com/v4/letter/m/FF8800/32.png) [@markus.mustonen](https://community.br-automation.com/u/markus.mustonen)\
**Post date:** [December 20, 2024, 7:57pm UTC](https://community.br-automation.com/t/mappview-compound-widgets-toolkit/5287/7 "2024-12-20T19:57:17Z")

</div>

Good point, I will check what I can do…

Have a nice holidays also,  
I will forward your greetings to Korvatunturi … 🎁

---

<div class="post-metadata">

**Author:** ![kovarj](https://dub1.discourse-cdn.com/brcommunity/user_avatar/community.br-automation.com/kovarj/32/537_2.png) [@kovarj](https://community.br-automation.com/u/kovarj)\
**Post date:** [December 21, 2024, 9:14am UTC](https://community.br-automation.com/t/mappview-compound-widgets-toolkit/5287/8 "2024-12-21T09:14:03Z")

</div>

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 🙂

---

<div class="post-metadata">

**Author:** ![markus.mustonen](https://avatars.discourse-cdn.com/v4/letter/m/FF8800/32.png) [@markus.mustonen](https://community.br-automation.com/u/markus.mustonen)\
**Post date:** [December 21, 2024, 6:12pm UTC](https://community.br-automation.com/t/mappview-compound-widgets-toolkit/5287/9 "2024-12-21T18:12:00Z")

</div>

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.

Have a nice holidays also 🙂

---

<div class="post-metadata">

**Author:** ![kovarj](https://dub1.discourse-cdn.com/brcommunity/user_avatar/community.br-automation.com/kovarj/32/537_2.png) [@kovarj](https://community.br-automation.com/u/kovarj)\
**Post date:** [December 21, 2024, 7:39pm UTC](https://community.br-automation.com/t/mappview-compound-widgets-toolkit/5287/10 "2024-12-21T19:39:12Z")

</div>

I have plans to test your toolkit and advertise it. Hope that you are ready to be popular 😀

---

<div class="post-metadata">

**Author:** ![markus.mustonen](https://avatars.discourse-cdn.com/v4/letter/m/FF8800/32.png) [@markus.mustonen](https://community.br-automation.com/u/markus.mustonen)\
**Post date:** [December 21, 2024, 8:15pm UTC](https://community.br-automation.com/t/mappview-compound-widgets-toolkit/5287/11 "2024-12-21T20:15:50Z")

</div>

If you test and find this usefull, I’m just really glad. Feel free to advertise… 😁

Along with the fame comes the “bug list” , I also hope I’m ready 😆

---

<div class="post-metadata">

**Author:** ![Kolma](https://dub1.discourse-cdn.com/brcommunity/user_avatar/community.br-automation.com/kolma/32/373_2.png) [@Kolma](https://community.br-automation.com/u/Kolma)\
**Post date:** [December 23, 2024, 11:56am UTC](https://community.br-automation.com/t/mappview-compound-widgets-toolkit/5287/12 "2024-12-23T11:56:45Z")

</div>

Thank you @markus.mustonen for a great idea. I will also try to see how it works and let you know!

---

<div class="post-metadata">

**Author:** ![markus.mustonen](https://avatars.discourse-cdn.com/v4/letter/m/FF8800/32.png) [@markus.mustonen](https://community.br-automation.com/u/markus.mustonen)\
**Post date:** [December 23, 2024, 5:03pm UTC](https://community.br-automation.com/t/mappview-compound-widgets-toolkit/5287/13 "2024-12-23T17:03:54Z")

</div>

@Kolma You are welcome, can’t wait for the feedback 🫡

---

<div class="post-metadata">

**Author:** ![markus.mustonen](https://avatars.discourse-cdn.com/v4/letter/m/FF8800/32.png) [@markus.mustonen](https://community.br-automation.com/u/markus.mustonen)\
**Post date:** [December 30, 2024, 2:24pm UTC](https://community.br-automation.com/t/mappview-compound-widgets-toolkit/5287/14 "2024-12-30T14:24:00Z")

</div>

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 🙂
