Create Dock Area Profiles from the BEC IPython Client¶
Goal
Save, modify, and switch Dock Area profiles from the BEC IPython client.
This tutorial creates the same alignment_scan and motor_check profiles as
Dock Area Profiles, but uses BEC IPython commands instead of toolbar
actions as in the previous tutorial.
For a shorter task guide that only covers adding widgets and choosing their dock placement, see Add Widgets to a Dock Area.
Before you start¶
Open BEC with Terminal + Dock, as shown in
01 Open BEC.
Start with a Dock Area containing a ScanControl and a Waveform widgets. This is the layout created in
06 Create Your First GUI.
1. Save the current layout¶
Save the current Dock Area as alignment_scan:
gui.bec.save_profile("alignment_scan", quick_select=True)
The profile is saved and included in the toolbar quick selector.
2. Add widgets for the second layout¶
Add a second Waveform to the right of the first one:
wf2 = gui.bec.new(
gui.available_widgets.Waveform,
where="right",
relative_to="Waveform",
)
wf2.plot(device_x="samx", device_y="bpm4i")
Add a PositionerBox below the first Waveform and set it to samx:
pos_samx = gui.bec.new(
gui.available_widgets.PositionerBox,
where="bottom",
relative_to="Waveform",
)
pos_samx.set_positioner("samx")
Add another PositionerBox below the second Waveform and set it to samy:
pos_samy = gui.bec.new(
gui.available_widgets.PositionerBox,
where="bottom",
relative_to="Waveform_0",
)
pos_samy.set_positioner("samy")
Place widgets relative to existing widgets
The relative_to argument accepts an existing widget reference or a widget name. Use the name shown on the dock tab,
for example "Waveform", "ScanControl", or "PositionerBox".
If the same widget type appears multiple times in the same layout, Dock Area starts indexing those names. The first
widget keeps the base name without an index, and the next ones use indexed names such as "Waveform_0" and
"Waveform_1".
3. Save the second profile¶
Save the modified Dock Area as motor_check:
gui.bec.save_profile("motor_check", quick_select=True)
4. Switch between profiles¶
Load the first profile:
gui.bec.load_profile("alignment_scan")
Load the second profile:
gui.bec.load_profile("motor_check")
What you have learned
You used BEC IPython commands to save, modify, and switch Dock Area profiles.
Next step¶
Use Script GUI Interactions when you need a reusable script that combines Python analysis and GUI plotting.