Cómo implementar treads en Glade ?????

Marco Antonio Islas Cruz markuz en islascruz.org
Vie Abr 11 01:53:36 CEST 2008


Que tal omar, espero que estos enlaces te sirvan.

http://www.islascruz.org/html/index.php/Blog/SingleView/id/PyGTK-y-Threads

http://www.google.com/search?q=threads+in+pygtk

On Thu, 2008-04-10 at 22:49 +0000, omar alberto wrote:
> 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
-- 
<--Linux... Because I'm Free-->
Marco Antonio Islas Cruz
"Markuz"
Linux User #280229
markuz en islascruz.org
markuz en unixmexico.org
markuz en linuxpozarica.com
marco.islas en gmail.com
islacruz en yahoo.com
http://www.islascruz.org
http://sourceforge.net/projects/gpkg/
http://www.linuxpozarica.com
------------ próxima parte ------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 189 bytes
Desc: This is a digitally signed message part
URL: <http://mail.python.org/pipermail/python-es/attachments/20080410/b500479d/attachment.pgp>
------------ próxima parte ------------
_______________________________________________
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