I am trying to create an OSC msg handler, using pyosc, which can listen to incoming multitoggle messages from TouchOSC.
The multitoggle is a grid of toggleswitches. The incoming messages are in the form "/1/multitoggle1/5/8" or "/1/multitoggle1/x/y" where x and y are integers corresponding to the grid position.
server.addMsgHandler( "/1/multitoggle1/5/8", toggle_callback ) works fine but I need the 5 and the 8 to be arguments read in the handler so I can get at them without having to add a separate handler for each individual toggle.
s.addMsgHandler( "/1/multitoggle1/", toggle_callback ) does not seem to work.
It is a similar problem to this one but I can't implement the implied solution.
I had the same problem and this was my solution:
for x in range(1,9):
for y in range(1,6):
s.addMsgHandler("/Channels/toggleChannels/"+`y`+"/"+`x`, toggleChannels)
def toggleChannels(addr,tags,data,source):
split = addr.split("/")
x = split.pop()
y = split.pop()
I registered all handlers but used only one callback, worked great