python-osc icon indicating copy to clipboard operation
python-osc copied to clipboard

how can I put the received message to GUI?

Open zingshowba opened this issue 3 years ago • 1 comments

I'm a python probie, I'm trying to put the message that I send from my phone to GUI, or use the message as an order to execute some command. But I CANT get the message out, please help me out.

import PySimpleGUI as sg from pythonosc.dispatcher import Dispatcher from pythonosc.osc_server import BlockingOSCUDPServer

ip = "192.168.0.108" port = 1337

def print_handler(address, *args): print(f"{address}: {args}")

def default_handler(address, *args): print(f"DEFAULT {address}: {args}") print(f":{args}")

dispatcher = Dispatcher() dispatcher.map("/something/*", print_handler) dispatcher.set_default_handler(default_handler)

trying to get the msg and print it out But it didn't work

msg = dispatcher.set_default_handler(print_handler)

print(f"testing{msg}")

server = BlockingOSCUDPServer((ip, port), dispatcher)

server.serve_forever()

layout = [[sg.Text('MetaBorder')], [sg.Text(size=(20,1), font= "Any 15", key="-OUT-")], [sg.Button("获取数据"), sg.Button("退出")] ]

window = sg.Window("Metaborder", layout, keep_on_top=True)

while True: event, values = window.read(timeout=1000) if event is None or event == "退出": break window["-OUT-"].update(msg)

window.close()

zingshowba avatar Feb 23 '22 16:02 zingshowba

have you found the way to put OSC message to Label (GUI) ?

rizaru22 avatar Dec 28 '22 12:12 rizaru22