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:

import pygtk
import gtk
import gtk.glade
import time
import threading

bandera1 = 0
class Sequence(threading.Thread):#subclass Thread
	def __init__(self):#make it possible to pass the time in seconds that we want the timer to run
		threading.Thread.__init__(self)#call the Thread's constructor
	def run(self):#define what we want our Timer thread to do
		for i in range(0,4):
			time.sleep(1)#time.sleep(self.runTime)#have it sleep for runTime seconds
		print '0'

		GUI.TarjetaProbada.set_from_file('C:\Documents and 

		GUI.TextoPrueba1.set_markup('<big><big><big>Prueba de voltajes del Microcontrolador</big></big></big>')
		for i in range(0,4):
		GUI.ImagenPrueba1.set_from_file('C:\Documents and 

Settings\practicantes\Escritorio\PracticasPython\GUIs\GUISimple\pixmaps\check mark_Green.bmp')
		print '1'
		GUI.TextoPrueba2.set_markup('<big><big><big>Prueba de voltajes del Regulador</big></big></big>')
		for i in range(0,4):
		GUI.ImagenPrueba2.set_from_file('C:\Documents and 

Settings\practicantes\Escritorio\PracticasPython\GUIs\GUISimple\pixmaps\check mark_Green.bmp')
		print '2'
		GUI.TextoPrueba3.set_markup('<big><big><big>Prueba de Polaridad en Diodo</big></big></big>')
		for i in range(0,4):
		GUI.ImagenPrueba3.set_from_file('C:\Documents and 

Settings\practicantes\Escritorio\PracticasPython\GUIs\GUISimple\pixmaps\cross mark_RED.bmp')
		print '3'
		GUI.TextoPrueba4.set_markup('<big><big><big>Prueba de funcionamiento del IrDA</big></big></big>')
		for i in range(0,4):
		GUI.ImagenPrueba4.set_from_file('C:\Documents and 

Settings\practicantes\Escritorio\PracticasPython\GUIs\GUISimple\pixmaps\check mark_Green.bmp')
		print '4'

def botonazo(self):

	GUI.ExplicacionPrueba.set_markup('<big><big><big><big><big><big>Iniciando Prueba del 

	for i in range(0,4):
		t = Sequence()
		global bandera1
		print 'bandera1 = ' + str(bandera1)

class GUIPruebasAutomatizadas:
	def __init__(self):
		self.GUI = gtk.glade.XML('guiejecucionpruebas.glade')
		self.VentanaPrincipal = self.GUI.get_widget('VentanaGUIPruebasAutomatizadas')
		self.vbox5 = self.GUI.get_widget('vbox5')
		self.TarjetaProbada = self.GUI.get_widget('ImagenProbando')
		self.Boton = self.GUI.get_widget('BotonIniciarPrueba') #this is a button widget in the glade GUI
		self.ExplicacionPrueba = self.GUI.get_widget('ExplicacionPrueba')
		self.TextoPrueba1 = self.GUI.get_widget('TextoPrueba1') #This are all textboxes widgets in the glade GUI
		self.TextoPrueba2 = self.GUI.get_widget('TextoPrueba2')
		self.TextoPrueba3 = self.GUI.get_widget('TextoPrueba3')
		self.TextoPrueba4 = self.GUI.get_widget('TextoPrueba4')
		self.ImagenPrueba1 = self.GUI.get_widget('ImagenPrueba1') #this are Images widgets in the glade GUI
		self.ImagenPrueba2 = self.GUI.get_widget('ImagenPrueba2')
		self.ImagenPrueba3 = self.GUI.get_widget('ImagenPrueba3')
		self.ImagenPrueba4 = self.GUI.get_widget('ImagenPrueba4')



print 'contando!!!!'


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!

This question has already been answered. Start a new discussion instead.