Foros del Web » Programando para Internet » Python »

wx.sound y boton

Estas en el tema de wx.sound y boton en el foro de Python en Foros del Web. tengo este codigo import wx class ventana(wx.Frame): def __init__(self,parent): wx.Frame.__init__(self,parent) self.Show() self.boton=wx.Button(self,label="inicio",pos=(290, 290)) self.entrada=wx.TextCtrl(self, pos=(200,250)) self.boton2=wx.Button(self,label="escribir",pos=(2 00,200)) self.boton.Bind(wx.EVT_BUTTON,self.onboton) def onboton(self,event): sonido=wx.Sound("hola buenos dias.wav") sonido.Play(wx.SOUND_SYNC) sonido.Stop() ...
  #1 (permalink)  
Antiguo 25/04/2011, 21:28
 
Fecha de Ingreso: diciembre-2010
Mensajes: 162
Antigüedad: 13 años, 4 meses
Puntos: 1
Pregunta wx.sound y boton

tengo este codigo

import wx

class ventana(wx.Frame):
def __init__(self,parent):
wx.Frame.__init__(self,parent)
self.Show()

self.boton=wx.Button(self,label="inicio",pos=(290, 290))
self.entrada=wx.TextCtrl(self, pos=(200,250))
self.boton2=wx.Button(self,label="escribir",pos=(2 00,200))

self.boton.Bind(wx.EVT_BUTTON,self.onboton)
def onboton(self,event):
sonido=wx.Sound("hola buenos dias.wav")
sonido.Play(wx.SOUND_SYNC)
sonido.Stop()
app=wx.App()
ventana(None)
app.MainLoop()

la idea es que al clickear el boton reproduzca la frase hola buenos dias, pero quisiera que lo reproduzca una sola vez y cuando clickee de vuelta no reproduzca la frase.como hago?
  #2 (permalink)  
Antiguo 25/04/2011, 21:35
Avatar de razpeitia
Moderador
 
Fecha de Ingreso: marzo-2005
Ubicación: Monterrey, México
Mensajes: 7.321
Antigüedad: 19 años, 1 mes
Puntos: 1360
Respuesta: wx.sound y boton

Código Python:
Ver original
  1. import wx
  2.  
  3. class ventana(wx.Frame):
  4.     def __init__(self,parent):
  5.         wx.Frame.__init__(self,parent)
  6.        
  7.         self.flag = True
  8.        
  9.         self.boton=wx.Button(self,label="inicio",pos=(290,290))
  10.         self.entrada=wx.TextCtrl(self, pos=(200,250))
  11.         self.boton2=wx.Button(self,label="escribir",pos=(200,200))
  12.         self.boton.Bind(wx.EVT_BUTTON,self.onboton)
  13.        
  14.         self.Show()
  15.        
  16.     def onboton(self,event):
  17.         if(self.flag):
  18.             sonido=wx.Sound("hola buenos dias.wav")
  19.             sonido.Play(wx.SOUND_SYNC)
  20.             sonido.Stop()
  21.             self.flag = False
  22. app=wx.App()
  23. ventana(None)
  24. app.MainLoop()

Un simple flag?

Etiquetas: Ninguno
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 16:19.