I would like to play a sound every time a custom button is pressed. The button is calling a server.action to update a custom field on an order and will be use to inform a user that the order is ready to be delivered. I would like to use pyglet with this simple script:
#!/usr/bin/env python
import pyglet
wavfile = '/home/effe/theetone.wav' sound = pyglet.media.load(wavfile) core = pyglet.media.Player() core.queue(sound) core.play()
But is not working when I use a python expression on server.actions.
ValueError: opcode IMPORT_NAME not allowed (u"import pyglet\n\nwavfile = '/home/effe/theetone.wav'\nsound = pyglet.media.load(wavfile)\ncore = pyglet.media.Player()\ncore.queue(sound)\ncore.play()")
Seems I can't declare an import (import pyglet) on python expression field and even if I put the import line on my module seems not to works. Where am I wrong?