Including Mission Editor in layout save

Hello,

I’m trying to extend the functionality of “layout save” to also save Mission Editor, since it only saves the console and map windows at the moment.

modules/lib/win_layout.py holds the functionality for “layout save” in win_layout.save_layout, which saves all the windows that are stored in the global var window_list. Console and Map get stored in this list by calling the win_layout.set_layout function, so I’m using that function to store Mission Editor. This works just fine, but when I execute “layout save” and win_layout.save_layout is called, Mission Editor is no longer in window_list.

I’m wondering if anyone has any ideas on what could be happening or if there is a better way to approach this.

Thank you!

I’d need to see your patch to try to find the bug. Can you create a branch for it and link the branch?

I’m just experimenting at the moment, but here’s what I have so far:

hi Stephanie,
You patch is missing a few key elements. To see what is needed I’d look at the example in the mavproxy_map folder.
This was the commit that added layout support to the map:


The key elements are:

  • in the parent code (which runs in mission_editor.py for you and in mp_slipmap.py for map) you need a set_layout() function which is called when a user does “layout load”. That needs to send the layout object to the thread that runs the actual UI elements by putting it in the queue
  • in the parent code you need to receive layout information from the UI and pass that to the win_layout module, so it can save the layout. This call also sets up the callback so the layout module can ask for a new layout
  • in the UI code (mp_slipmap_ui.py and missionEditorFrame.py) you need to periodically send the layout to the parent so it knows about layout changes
  • also in the UI code you need to receive layouts from the parent and act on them by using set_wc_window_layout

If you don’t have all 4 elements then it won’t work. Some key things in your patch:

  • your UI code is calling set_layout(). That makes no sense, as it is in the wrong thread.
  • you are missing the first 3 items from above list

I hope this helps!

Thank you, that helped a lot.
I was able to get it working and submitted a PR here: https://github.com/ArduPilot/MAVProxy/pull/789