Unwanted window spawns when using Tkinter with multiprocessing.
Dave Angel
davea at davea.name
Sun Apr 28 19:10:17 EDT 2013
On 04/28/2013 06:23 PM, alternative00 at rocketmail.com wrote:
> Sorry for my bad english.
>
> Here's my code :
>
> def key(event):
>
> instance = 'Instance'
> touche = 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)
>
> 'key' is the tkinter function wich gets the pressed key.
> 'player' is the function playing a specific wav file depending on wich key is pressed, that's why its argument is 'hitkey'. It uses the winsound module.
>
> What spawns new windows is theorically the multiprocessing line of code, even if it's inside the 'key' function.
>
Do you have an
if __name__ == "__main__":
clause in your main script? Are you bypassing the gui event loop on the
secondary process? Otherwise, it's your code that's launching the extra
window.
And what OS are you running on?
--
DaveA
More information about the Python-list
mailing list