Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #44508

Re: Unwanted window spawns when using Tkinter with multiprocessing.

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 <python@mrabarnett.plus.com>
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 <python@mrabarnett.plus.com>
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> <c3e24fc5-e593-4e69-bb57-5bd78dd3c6f2@googlegroups.com>
In-Reply-To <c3e24fc5-e593-4e69-bb57-5bd78dd3c6f2@googlegroups.com>
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 <python-list.python.org>
List-Unsubscribe <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.1156.1367254991.3114.python-list@python.org> (permalink)
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

Show key headers only | View raw


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>", 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()

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Unwanted window spawns when using Tkinter with multiprocessing. alternative00@rocketmail.com - 2013-04-28 11:33 -0700
  Re: Unwanted window spawns when using Tkinter with multiprocessing. Dave Angel <davea@davea.name> - 2013-04-28 17:18 -0400
  Re: Unwanted window spawns when using Tkinter with multiprocessing. alternative00@rocketmail.com - 2013-04-28 15:23 -0700
    Re: Unwanted window spawns when using Tkinter with multiprocessing. Dave Angel <davea@davea.name> - 2013-04-28 19:10 -0400
  Re: Unwanted window spawns when using Tkinter with multiprocessing. alternative00@rocketmail.com - 2013-04-28 16:40 -0700
    Re: Unwanted window spawns when using Tkinter with multiprocessing. Dave Angel <davea@davea.name> - 2013-04-28 20:24 -0400
    Re: Unwanted window spawns when using Tkinter with multiprocessing. Chris Angelico <rosuav@gmail.com> - 2013-04-29 13:03 +1000
  Re: Unwanted window spawns when using Tkinter with multiprocessing. alternative00@rocketmail.com - 2013-04-29 08:31 -0700
    Re: Unwanted window spawns when using Tkinter with multiprocessing. MRAB <python@mrabarnett.plus.com> - 2013-04-29 18:03 +0100
  Re: Unwanted window spawns when using Tkinter with multiprocessing. alternative00@rocketmail.com - 2013-04-29 10:32 -0700
    Re: Unwanted window spawns when using Tkinter with multiprocessing. Chris Angelico <rosuav@gmail.com> - 2013-04-30 03:45 +1000
  Re: Unwanted window spawns when using Tkinter with multiprocessing. alternative00@rocketmail.com - 2013-04-29 11:44 -0700
    Re: Unwanted window spawns when using Tkinter with multiprocessing. Chris Angelico <rosuav@gmail.com> - 2013-04-30 08:00 +1000
  Re: Unwanted window spawns when using Tkinter with multiprocessing. alternative00@rocketmail.com - 2013-04-29 18:17 -0700
    Re: Unwanted window spawns when using Tkinter with multiprocessing. Dave Angel <davea@davea.name> - 2013-04-29 22:05 -0400
  Re: Unwanted window spawns when using Tkinter with multiprocessing. alternative00@rocketmail.com - 2013-04-30 05:22 -0700
    Re: Unwanted window spawns when using Tkinter with multiprocessing. Dave Angel <d@davea.name> - 2013-04-30 08:30 -0400
  Re: Unwanted window spawns when using Tkinter with multiprocessing. alternative00@rocketmail.com - 2013-04-30 05:31 -0700

csiph-web