Cómo implementar treads en Glade ?????
omar alberto
omar_alberto_h en yahoo.es
Vie Abr 11 00:49:22 CEST 2008
Hola quisiera que alguien me pudiera orientar ya que quiero utilizar threads en una aplicacion.
#!/usr/bin/env python
import sys
import time
import threading
try:
import pygtk
#tell pyGTK, if possible, that we want GTKv2
pygtk.require("2.0")
except:
#Some distributions come with GTK2, but not pyGTK
pass
try:
import gtk
import gtk.glade
except:
sys.exit(1)
class vamos(threading.Thread):
def __init__(self, value):
threading.Thread.__init__(self)
self.nombre = value
def run(self):
print "Contador Tiempo ",self.nombre
segundos=0
minutos=0
horas=0
total=i=0
while i <=100:#pongo este valor como ejemplo
time.sleep(1)
segundos+=1
if segundos== 60:
minutos+=1
segundos=0
if minutos==60:
horas+=1
minutos=0
print "Segundos :"+str(segundos)+"-----------Minutos:"+str(minutos)+"-------------Horas:"+str(horas)
#now we have both gtk and gtk.glade imported
#Also, we know we are running GTK v2
class appgui(vamos):
def __init__(self):
"""
In this init we are going to display the main
serverinfo window
"""
self.total=0
gladefile="internet.glade"
windowname="ventanaprincipal"
self.wTree=gtk.glade.XML (gladefile,windowname)
dic = { "on_comenzar_clicked" : self.button_comenzar_clicked ,"on_ventanaprincipal_destroy" : (gtk.main_quit) }
self.wTree.signal_autoconnect (dic)
return
#####CALLBACKS
def button_comenzar_clicked(self,widget):
vamos("OK ").start()
# we start the app like this...
app=appgui()
gtk.main()
cuando hago clic en un boton se debe disparar un thread que termina luego de cierto tiempo Deben haber por lo menos unos cuatro
______________________________________________
¿Con Mascota por primera vez? Sé un mejor Amigo. Entra en Yahoo! Respuestas http://es.answers.yahoo.com/info/welcome
_______________________________________________
Lista de correo Python-es
http://listas.aditel.org/listinfo/python-es
FAQ: http://listas.aditel.org/faqpyes
Más información sobre la lista de distribución Python-es