def show(self, *a): if self.background is None: self.realize() self.background = SVGWidget(self, self.args.image, init_hilighted=True) self.c.add(self.background) self.add(self.c) Generator(SVGEditor(self.background)) OSDWindow.show(self, *a) self.move(*self.compute_position())
def __init__(self): svg = SVGEditor(file("images/binding-display.svg").read()) background = SVGEditor.get_element(svg, "background") self.label_template = SVGEditor.get_element(svg, "label_template") self.line_height = int(float(self.label_template.attrib.get("height") or 8)) self.char_width = int(float(self.label_template.attrib.get("width") or 8)) self.full_width = int(float(background.attrib.get("width") or 800)) self.full_height = int(float(background.attrib.get("height") or 800)) profile = Profile(TalkingActionParser()).load("test.sccprofile") boxes = [] box_bcs = Box(0, self.PADDING, Align.TOP, "bcs") box_bcs.add("BACK", Action.AC_BUTTON, profile.buttons.get(SCButtons.BACK)) box_bcs.add("C", Action.AC_BUTTON, profile.buttons.get(SCButtons.C)) box_bcs.add("START", Action.AC_BUTTON, profile.buttons.get(SCButtons.START)) boxes.append(box_bcs) box_left = Box(self.PADDING, self.PADDING, Align.LEFT | Align.TOP, "left", min_height = self.full_height * 0.5, min_width = self.full_width * 0.2) box_left.add("LEFT", Action.AC_TRIGGER, profile.triggers.get(profile.LEFT)) box_left.add("LB", Action.AC_BUTTON, profile.buttons.get(SCButtons.LB)) box_left.add("LGRIP", Action.AC_BUTTON, profile.buttons.get(SCButtons.LGRIP)) box_left.add("LPAD", Action.AC_PAD, profile.pads.get(profile.LEFT)) boxes.append(box_left) box_right = Box(self.PADDING, self.PADDING, Align.RIGHT | Align.TOP, "right", min_height = self.full_height * 0.5, min_width = self.full_width * 0.2) box_right.add("RIGHT", Action.AC_TRIGGER, profile.triggers.get(profile.RIGHT)) box_right.add("RB", Action.AC_BUTTON, profile.buttons.get(SCButtons.RB)) box_right.add("RGRIP", Action.AC_BUTTON, profile.buttons.get(SCButtons.RGRIP)) box_right.add("RPAD", Action.AC_PAD, profile.pads.get(profile.RIGHT)) boxes.append(box_right) box_abxy = Box(4 * self.PADDING, self.PADDING, Align.RIGHT | Align.BOTTOM, "abxy") box_abxy.add("A", Action.AC_BUTTON, profile.buttons.get(SCButtons.A)) box_abxy.add("B", Action.AC_BUTTON, profile.buttons.get(SCButtons.B)) box_abxy.add("X", Action.AC_BUTTON, profile.buttons.get(SCButtons.X)) box_abxy.add("Y", Action.AC_BUTTON, profile.buttons.get(SCButtons.Y)) boxes.append(box_abxy) box_stick = Box(4 * self.PADDING, self.PADDING, Align.LEFT | Align.BOTTOM, "stick") box_stick.add("STICK", Action.AC_STICK, profile.stick) boxes.append(box_stick) w = int(float(background.attrib.get("width") or 800)) h = int(float(background.attrib.get("height") or 800)) root = SVGEditor.get_element(svg, "root") for b in boxes: b.calculate(self) # Set ABXY and Stick size & position box_abxy.height = box_stick.height = self.full_height * 0.25 box_abxy.width = box_stick.width = self.full_width * 0.3 box_abxy.y = self.full_height - self.PADDING - box_abxy.height box_stick.y = self.full_height - self.PADDING - box_stick.height box_abxy.x = self.full_width - self.PADDING - box_abxy.width self.equal_width(box_left, box_right) self.equal_height(box_left, box_right) for b in boxes: b.place_marker(self, root) for b in boxes: b.place(self, root) file("out.svg", "w").write(svg.to_string())
def on_profile_changed(self, daemon, filename): profile = Profile(TalkingActionParser()).load(filename) Generator(SVGEditor(self.background), profile)