Ver Mensaje Individual
  #2 (permalink)  
Antiguo 09/10/2012, 15:56
Avatar de razpeitia
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.