On 29/04/2013 16:31, alternativ...@rocketmail.com wrote:
My full code is :
#Import
from tkinter import *
import wave
import winsound
import multiprocessing
#Initialisation
fenetre=Tk()
frame = Frame(fenetre, width=200, height=100)
instance = 'Instance'
#Fonctions
def key(event):
instance = 'Instance'
hitkey = event.char
instance = multiprocessing.Process(target=player, args=(hitkey,))
instance.start()
def player(hitkey):
winsound.PlaySound(hitkey + '.wav',
winsound.SND_FILENAME|winsound.SND_NOWAIT|winsound.SND_ASYNC)
#TK
frame.focus_set()
frame.bind("<Key>", key)
frame.pack()
fenetre.mainloop()
The problem is that I don't know where to put that clause.
I hope this helps:
#Import
from tkinter import *
import wave
import winsound
import multiprocessing
#Fonctions
def key(event):
instance = 'Instance'
hitkey = event.char
instance = multiprocessing.Process(target=player, args=(hitkey,))
instance.start()
def player(hitkey):
winsound.PlaySound(hitkey + '.wav',
winsound.SND_FILENAME|winsound.SND_NOWAIT|winsound.SND_ASYNC)
if __name__ == "__main__":
# This part will be run if the file is run as the main script.
#
# The multiprocessing module will import this file to run the
# "player" function, but __name__ won't be "__main__" when it does
# so, therefore this bit of code won't be run.
#Initialisation
fenetre = Tk()
frame = Frame(fenetre, width=200, height=100)
instance = 'Instance'
#TK
frame.focus_set()
frame.bind("<Key>", key)
frame.pack()
fenetre.mainloop()
--
http://mail.python.org/mailman/listinfo/python-list