Path: csiph.com!usenet.pasdenom.info!news.etla.org!news.stack.nl!newsfeed.xs4all.nl!newsfeed3.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.011 X-Spam-Evidence: '*H*': 0.98; '*S*': 0.00; 'tkinter': 0.07; '"__main__":': 0.09; '__name__': 0.09; 'function,': 0.09; 'subject:using': 0.09; 'def': 0.12; 'clause.': 0.16; 'from:addr:mrabarnett.plus.com': 0.16; 'from:addr:python': 0.16; 'from:name:mrab': 0.16; 'key)': 0.16; 'message- id:@mrabarnett.plus.com': 0.16; 'subject:Tkinter': 0.16; 'subject:skip:m 10': 0.16; 'subject:when': 0.16; 'tk()': 0.16; 'wrote:': 0.18; 'bit': 0.19; 'module': 0.19; 'import': 0.22; 'header:User-Agent:1': 0.23; 'script.': 0.24; 'header:In-Reply- To:1': 0.27; 'code': 0.31; 'file': 0.32; 'skip:m 30': 0.32; 'run': 0.32; 'skip:# 10': 0.33; 'problem': 0.35; 'subject:with': 0.35; 'but': 0.35; 'so,': 0.37; 'to:addr:python-list': 0.38; 'does': 0.39; 'to:addr:python.org': 0.39; 'hope': 0.61; 'full': 0.61; 'header:Reply-To:1': 0.67; 'reply-to:no real name:2**0': 0.71; 'therefore': 0.72; 'wave': 0.74; 'email addr:rocketmail.com': 0.84; 'reply-to:addr:python.org': 0.84; 'skip:w 60': 0.84; 'subject:Unwanted': 0.84 X-CM-Score: 0.00 X-CNFS-Analysis: v=2.1 cv=TZ6v63gh c=1 sm=1 tr=0 a=0nF1XD0wxitMEM03M9B4ZQ==:117 a=0nF1XD0wxitMEM03M9B4ZQ==:17 a=0Bzu9jTXAAAA:8 a=7AxPfEIvyrUA:10 a=_m9kpv5NzyQA:10 a=ihvODaAuJD4A:10 a=OUOv7kDek9cA:10 a=8nJEP1OIZ-IA:10 a=EBOSESyhAAAA:8 a=8AHkEIZyAAAA:8 a=8WJwYSwzlFoA:10 a=LtGpxU-LAAAA:8 a=U_9AHKU_utBSuqWhRn0A:9 a=dmGtQrVN4fNPVWBM:21 a=LM61agIm-NA2x0zy:21 a=wPNLvfGTeEIA:10 a=eL4mtSqiQiEA:10 X-AUTH: mrabarnett:2500 Date: Mon, 29 Apr 2013 18:03:10 +0100 From: MRAB User-Agent: Mozilla/5.0 (Windows NT 5.1; rv:17.0) Gecko/20130328 Thunderbird/17.0.5 MIME-Version: 1.0 To: python-list@python.org Subject: Re: Unwanted window spawns when using Tkinter with multiprocessing. References: <7df67006-2176-42cb-a8ce-95a72339e7e2@googlegroups.com> In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list Reply-To: python-list@python.org List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 84 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1367254992 news.xs4all.nl 15966 [2001:888:2000:d::a6]:48380 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:44508 On 29/04/2013 16:31, alternative00@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) > 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) frame.pack() fenetre.mainloop()