Foros del Web » Programando para Internet » Python »

Error con destroy

Estas en el tema de Error con destroy en el foro de Python en Foros del Web. hola alguien me podria ayudar tengo el siguiente codigo saca fotos en segundos junto con un segundero me saca la foto y el segundero bien ...
  #1 (permalink)  
Antiguo 09/10/2012, 11:41
 
Fecha de Ingreso: julio-2007
Mensajes: 6
Antigüedad: 16 años, 8 meses
Puntos: 0
Pregunta Error con destroy

hola alguien me podria ayudar tengo el siguiente codigo saca fotos en segundos junto con un segundero me saca la foto y el segundero bien el problema esque no se destruye la venta de la camara pero el segundero si, nose que me falta ayuda soy nueva:

Código Python:
Ver original
  1. import cv
  2. import time
  3. from Tkinter import *
  4. from threading import Timer
  5.  
  6. ventana = Tk()
  7. ventana.title("Botones")
  8. ventana.geometry("350x50+500+150")
  9.  
  10. def foto_seg():
  11.  
  12.  def stream():
  13.    global camara
  14.    global frame
  15.    frame = cv.QueryFrame(camara)
  16.    cv.ShowImage("camara", frame)
  17.    cv.MoveWindow("camara", 600, 320)
  18.    cv.SaveImage("testing.png", frame)
  19.  stream()
  20.  
  21.  def contador(texto):
  22.   def count():
  23.     global counter
  24.     counter += -1
  25.     texto.config(text=str(counter))
  26.     texto.after(1000, count)    
  27.   count()
  28.  
  29.  global istime
  30.  while (istime):
  31.    stream()
  32.    cv.WaitKey(15)
  33.    istime -= 1
  34.  
  35.  seg = Tk()
  36.  seg.geometry("350x50+700+350")
  37.  seg.title("Captura")
  38.  Label(seg, text="Tomando foto en  ....",
  39.         fg = "black", font = "Verdana 10 bold").pack()
  40.  texto = Label(seg, fg="red", font = "Verdana 16 bold")
  41.  contador(texto)
  42.  texto.pack()
  43.  
  44.  for x in range(0, 60):
  45.    seg.update()
  46.    time.sleep(0.07)
  47.  
  48.  seg.destroy() 
  49.  time.sleep(5)
  50.  
  51. boton = Button(ventana, text="Iniciar", width=10, command=foto_seg).pack()
  52. boton = Button(ventana, text="Exit", width=10, command=sys.exit).pack()
  53.  
  54. istime = 10
  55. frame = None
  56. counter = 5
  57. camera = None
  58. camara = cv.CaptureFromCAM(0)
  59. cv.SetCaptureProperty(camara, cv.CV_CAP_PROP_FRAME_HEIGHT, 480/2)
  60. cv.SetCaptureProperty(camara, cv.CV_CAP_PROP_FRAME_WIDTH, 640/2)
  61. cv.NamedWindow("camara", cv.CV_WINDOW_AUTOSIZE)
  62.  
  63.  
  64. cv.DestroyAllWindows("camara")
  65. cv.ShowImage("camara", frame)
  66. ventana.mainloop()


Me sale este error nose como solucionarlo

invalid command name "40594240callit"
while executing
"40594240callit"
("after" script)


Gracias
  #2 (permalink)  
Antiguo 09/10/2012, 15:56
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: Error con destroy

Intenta con esto:
Código Python:
Ver original
  1. # -*- coding: utf-8 -*-
  2. import cv
  3. import time
  4. from Tkinter import *
  5. from threading import Timer
  6.  
  7. ventana = Tk()
  8. ventana.title("Botones")
  9. ventana.geometry("350x50+500+150")
  10.  
  11. def foto_seg():
  12.  
  13.  def stream():
  14.    global camara
  15.    global frame
  16.    frame = cv.QueryFrame(camara)
  17.    cv.ShowImage("camara", frame)
  18.    cv.MoveWindow("camara", 600, 320)
  19.    cv.SaveImage("testing.png", frame)
  20.  stream()
  21.  
  22.  def contador(texto):
  23.   def count():
  24.     global counter
  25.     counter += -1
  26.     texto.config(text=str(counter))
  27.     texto.after(1000, count)    
  28.   count()
  29.  
  30.  global istime
  31.  while (istime):
  32.    stream()
  33.    cv.WaitKey(15)
  34.    istime -= 1
  35.  
  36.  seg = Tk()
  37.  seg.geometry("350x50+700+350")
  38.  seg.title("Captura")
  39.  Label(seg, text="Tomando foto en  ....",
  40.         fg = "black", font = "Verdana 10 bold").pack()
  41.  texto = Label(seg, fg="red", font = "Verdana 16 bold")
  42.  contador(texto)
  43.  texto.pack()
  44.  
  45.  for x in range(0, 60):
  46.    seg.update()
  47.    time.sleep(0.07)
  48.  
  49.  seg.destroy()  
  50.  time.sleep(5)
  51.  
  52. boton = Button(ventana, text="Iniciar", width=10, command=foto_seg).pack()
  53. boton = Button(ventana, text="Exit", width=10, command=lambda:ventana.destroy()).pack()
  54.  
  55. istime = 10
  56. frame = None
  57. counter = 5
  58. camera = None
  59. camara = cv.CaptureFromCAM(0)
  60. cv.SetCaptureProperty(camara, cv.CV_CAP_PROP_FRAME_HEIGHT, 480/2)
  61. cv.SetCaptureProperty(camara, cv.CV_CAP_PROP_FRAME_WIDTH, 640/2)
  62. cv.NamedWindow("camara", cv.CV_WINDOW_AUTOSIZE)
  63.  
  64. cv.DestroyAllWindows("camara")
  65. cv.ShowImage("camara", frame)
  66. ventana.mainloop()
Y me dices si te sirve por que ya no pude reproducir el bug después de la primera ejecución.
  #3 (permalink)  
Antiguo 10/10/2012, 07:54
 
Fecha de Ingreso: julio-2007
Mensajes: 6
Antigüedad: 16 años, 8 meses
Puntos: 0
Respuesta: Error con destroy

hola, me sigue saliendo lo mismo, gracias

Etiquetas: import
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:38.