#!/usr/bin/env python3 """Make Wander and Ballyhoo one at a time in shows/test.qxw. Their two buttons go into a solo frame, Movement, where they already sit on the top row of the movers pads, so starting one stops the other, as the colour sets do. padcontroller/layer.py follows the same rule. python3 scripts/shows/mover_movement_solo.py Run it once on a show with Wander and Ballyhoo on the top row; it stops if the solo frame is already there. QLC+ has to reopen the show to see it. """ from __future__ import annotations import re from mover_bank import NO_FUNCTION, ROOT, appearance SHOW = ROOT / "shows" / "test.qxw" BUTTONS = ("Wander", "Ballyhoo") SIZE = 90 def main() -> None: xml = SHOW.read_text() if 'Caption="Movement"' in xml: raise SystemExit(f"{SHOW.relative_to(ROOT)} already has the Movement solo frame") wid = max(int(i) for i in re.findall(r' ID="(\d+)"', xml.split("")[1]) if int(i) != NO_FUNCTION) + 1 found = [re.search(rf' \n', xml, re.S).group(0) for caption in BUTTONS] body = "" for i, button in enumerate(found): xml = xml.replace(button, "", 1) # Inside the frame each sits at its place in the row, one level deeper. moved = re.sub(r'X="\d+" Y="\d+"', f'X="{SIZE * i}" Y="0"', button, count=1) body += "".join(" " + line if line else line for line in moved.splitlines(keepends=True)) frame = (f' \n' + appearance(" ") + f' \n' ' True\n True\n' ' False\n False\n' ' False\n False\n False\n' + body + ' \n') strobe = re.search(r'