pygtk Glade GUI freezes

Thread Solved

Join Date: May 2006
Posts: 2
Reputation: JoeM is an unknown quantity at this point 
Solved Threads: 0
JoeM JoeM is offline Offline
Newbie Poster

pygtk Glade GUI freezes

 
0
  #1
May 3rd, 2006
Hello!! I'm really new to python and pygtk and Glade, I'm sorry I'm still on the dark side using Windows 2000 :-(
What I'm trying to do is a simple Testing Program Simulator, that means that I will press a button and then I'm supposed to show a cross or a checkmark after simulating a test. Actually there are 4 tests.

So what I tried to do is to use a thread to run some for loops and time.sleep(1) for some seconds inside each for loop.

Then a textbox changes and an image appears.

The problem is that the program SOMETIMES works as it should, but some other times the GUI freezes and the images don't get loaded.

Sometimes the program seems to keep on running while the GUI freezes, some other times the program execution seems to freeze and the GUI freezes. Sometimes if I press ctrl + C in the console the program seems to go out of some hidden loop and then the GUI unfreezes.

I'm really frustrated, I already read like 5 examples for using threads and I can't find my mistake. Could somebody help me please???

Here's my code:

  1.  
  2. import pygtk
  3. import gtk
  4. import gtk.glade
  5. import time
  6. import threading
  7.  
  8. bandera1 = 0
  9.  
  10. class Sequence(threading.Thread):#subclass Thread
  11. def __init__(self):#make it possible to pass the time in seconds that we want the timer to run
  12.  
  13. threading.Thread.__init__(self)#call the Thread's constructor
  14.  
  15. def run(self):#define what we want our Timer thread to do
  16.  
  17. for i in range(0,4):
  18. time.sleep(1)#time.sleep(self.runTime)#have it sleep for runTime seconds
  19. print '0'
  20.  
  21. GUI.TarjetaProbada.set_from_file('C:\Documents and
  22.  
  23. Settings\practicantes\Escritorio\PracticasPython\GUIs\GUISimple\pixmaps\CPU.JPG')
  24. GUI.TextoPrueba1.set_markup('<big><big><big>Prueba de voltajes del Microcontrolador</big></big></big>')
  25.  
  26. for i in range(0,4):
  27. time.sleep(1)
  28. GUI.ImagenPrueba1.set_from_file('C:\Documents and
  29.  
  30. Settings\practicantes\Escritorio\PracticasPython\GUIs\GUISimple\pixmaps\check mark_Green.bmp')
  31. print '1'
  32.  
  33. GUI.TextoPrueba2.set_markup('<big><big><big>Prueba de voltajes del Regulador</big></big></big>')
  34. for i in range(0,4):
  35. time.sleep(1)
  36. GUI.ImagenPrueba2.set_from_file('C:\Documents and
  37.  
  38. Settings\practicantes\Escritorio\PracticasPython\GUIs\GUISimple\pixmaps\check mark_Green.bmp')
  39. print '2'
  40.  
  41. GUI.TextoPrueba3.set_markup('<big><big><big>Prueba de Polaridad en Diodo</big></big></big>')
  42. for i in range(0,4):
  43. time.sleep(1)
  44. GUI.ImagenPrueba3.set_from_file('C:\Documents and
  45.  
  46. Settings\practicantes\Escritorio\PracticasPython\GUIs\GUISimple\pixmaps\cross mark_RED.bmp')
  47. print '3'
  48.  
  49.  
  50. GUI.TextoPrueba4.set_markup('<big><big><big>Prueba de funcionamiento del IrDA</big></big></big>')
  51. for i in range(0,4):
  52. time.sleep(1)
  53. GUI.ImagenPrueba4.set_from_file('C:\Documents and
  54.  
  55. Settings\practicantes\Escritorio\PracticasPython\GUIs\GUISimple\pixmaps\check mark_Green.bmp')
  56. print '4'
  57.  
  58.  
  59. def botonazo(self):
  60.  
  61. GUI.ExplicacionPrueba.set_markup('<big><big><big><big><big><big>Iniciando Prueba del
  62.  
  63. CPU</big></big></big></big></big></big>')
  64.  
  65. for i in range(0,4):
  66.  
  67. t = Sequence()
  68.  
  69. global bandera1
  70. print 'bandera1 = ' + str(bandera1)
  71. #t.run()
  72. t.start()
  73. #t.join()
  74.  
  75.  
  76.  
  77.  
  78. class GUIPruebasAutomatizadas:
  79. def __init__(self):
  80.  
  81. self.GUI = gtk.glade.XML('guiejecucionpruebas.glade')
  82. self.VentanaPrincipal = self.GUI.get_widget('VentanaGUIPruebasAutomatizadas')
  83.  
  84.  
  85. self.vbox5 = self.GUI.get_widget('vbox5')
  86.  
  87. self.TarjetaProbada = self.GUI.get_widget('ImagenProbando')
  88.  
  89. self.Boton = self.GUI.get_widget('BotonIniciarPrueba') #this is a button widget in the glade GUI
  90. self.Boton.connect('clicked',botonazo)
  91.  
  92. self.ExplicacionPrueba = self.GUI.get_widget('ExplicacionPrueba')
  93. #self.ExplicacionPrueba.connect()
  94.  
  95. self.TextoPrueba1 = self.GUI.get_widget('TextoPrueba1') #This are all textboxes widgets in the glade GUI
  96. self.TextoPrueba2 = self.GUI.get_widget('TextoPrueba2')
  97. self.TextoPrueba3 = self.GUI.get_widget('TextoPrueba3')
  98. self.TextoPrueba4 = self.GUI.get_widget('TextoPrueba4')
  99.  
  100. self.ImagenPrueba1 = self.GUI.get_widget('ImagenPrueba1') #this are Images widgets in the glade GUI
  101. self.ImagenPrueba2 = self.GUI.get_widget('ImagenPrueba2')
  102. self.ImagenPrueba3 = self.GUI.get_widget('ImagenPrueba3')
  103. self.ImagenPrueba4 = self.GUI.get_widget('ImagenPrueba4')
  104.  
  105.  
  106. gtk.gdk.threads_init()
  107.  
  108.  
  109. GUI=GUIPruebasAutomatizadas()
  110.  
  111. print 'contando!!!!'
  112.  
  113. gtk.threads_enter()
  114. gtk.main()
  115. gtk.threads_leave()
Reply With Quote Quick reply to this message  
Join Date: Oct 2004
Posts: 3,947
Reputation: vegaseat is just really nice vegaseat is just really nice vegaseat is just really nice vegaseat is just really nice vegaseat is just really nice 
Solved Threads: 914
Moderator
vegaseat's Avatar
vegaseat vegaseat is offline Offline
DaniWeb's Hypocrite

Re: pygtk Glade GUI freezes

 
0
  #2
May 3rd, 2006
My experience with pyGTK, I can not get it to work with Windows XP. The Linux folks have no problems. Before you go completely nuts with an unstable product, I would recommend switching to the wxPython GUI.

Just my opinion!
May 'the Google' be with you!
Reply With Quote Quick reply to this message  
Reply

This thread has been marked solved.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the Python Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC