def main(): client = OscUdpClient("10.0.0.188", 8000) interface = SimpleGraphicalInterface(640, 300, client, "3D meetup #7") select_msg = osc_message("/Prez") def prev_slide(): global CURR if CURR > 0: CURR -= 1 bundle = osc_bundle([select_msg, osc_message('/Slide' + str(CURR))]) client.send(bundle) def next_slide(): global CURR if CURR < LAST: CURR += 1 bundle = osc_bundle([select_msg, osc_message('/Slide' + str(CURR))]) client.send(bundle) interface.add_button(50, 50, "PREV", ButtonOptions(background="#5555ff", foreground="#ffffff", font=('halvetica', 52)), command=prev_slide) interface.add_button(350, 50, "NEXT", ButtonOptions(background="#55AA55", foreground="#ffffff", font=('halvetica', 52)), command=next_slide) interface.loop()
def make_button(self, text: str, options: ButtonOptions = ButtonOptions(), address=None, non_osc_content=None, osc_content=None, command=None): options_dict = {arg: val for arg, val in options._asdict().items() if val is not None} if address is not None: if non_osc_content is None: button = tk.Button(self.tk_root, text=text, cnf=options_dict, command=lambda: self.client.send(osc_message(address))) else: button = tk.Button(self.tk_root, text=text, cnf=options_dict, command=lambda: self.client.send(osc_message(address, non_osc_content))) elif osc_content is not None: button = tk.Button(self.tk_root, text=text, cnf=options_dict, command=lambda: self.client.send(osc_content)) elif command is not None: button = tk.Button(self.tk_root, text=text, command=command, cnf=options_dict) else: raise Exception() return button
def make_scale(self, label: str, init_val, min_val, max_val, options: ScaleOptions = ScaleOptions(), address: str = None, command=None): options_dict = {arg: val for arg, val in options._asdict().items() if val is not None} if address is not None: scale = tk.Scale(self.tk_root, label=label, from_=min_val, to=max_val, cnf=options_dict, command=lambda val: self.client.send(osc_message(address, [num_val(val)]))) elif command is not None: scale = tk.Button(self.tk_root, label=label, from_=min_val, to=max_val, command=command, cnf=options_dict) else: raise Exception() scale.set(init_val) return scale
def next_slide(): global CURR if CURR < LAST: CURR += 1 bundle = osc_bundle([select_msg, osc_message('/Slide' + str(CURR))]) client.send(bundle)
def prev_slide(): global CURR if CURR > 0: CURR -= 1 bundle = osc_bundle([select_msg, osc_message('/Slide' + str(CURR))]) client.send(bundle)