Dear all,

I have a problem with the following program. When I push the button
the program shows the dialog window but doesn't show the labels whithin
the dialog. This labels are shown when the sleep(10) function ends.

Why "events_pending" loop doesn't work? What can I do?

------------------------- start
#!/usr/bin/env python

from gtk import *
import time
from gnome.ui import *

class ClassProgram:
     window = GnomeApp('threads.py', 'Thread Test')
     window.set_position(WIN_POS_CENTER)

     def __init__(self):
         print "<:ClassProgram>"
         self.mainGui()

     def mainGui(self):
         self.crea_main_window()
         mainloop()

     def destroy(self, *args):
         mainquit()

     def cb_dialog(self, _widget):
         dialog = UIDialog()
         print "sleeping 10 ..."
         time.sleep(10)
         dialog.active_button(TRUE)

     def crea_main_window(self, *args):
         self.window.connect("destroy", self.destroy)
         # allow_shrink, allow_grow, auto_shrink
         self.window.set_policy(0, 0, 0)
         self.window.set_usize(800, 600)
         self.window.set_uposition(200, 200)

         boton = GtkButton("push me!")
         boton.connect("clicked", self.cb_dialog)

         self.window.set_contents(boton)
         self.window.show()

class UIDialog:
     def __init__(self):
         print "<:UIDialog>"
         win = GtkDialog()
         win.set_position (WIN_POS_CENTER)
         win.set_policy(FALSE, FALSE, TRUE)
         win.set_modal(TRUE)
         win.set_title("Dialog")
         win.set_usize(400, 350)

         win.vbox.set_border_width(5)

         win.action_area.set_spacing(30)
         self.button = GtkButton("ok")
         self.button.connect("clicked", win.destroy)
         self.button.set_sensitive(FALSE)
         win.action_area.pack_start(self.button)

         label1 = GtkLabel("Label 1")
         label2  = GtkLabel("Label 3")

         win.vbox.pack_start(label1)
         win.vbox.pack_start(label2)

         win.show_all()

         while events_pending():
             mainiteration(TRUE)

     def active_button(self, bool):
         self.button.set_sensitive(bool)

if __name__ == '__main__': ClassProgram()

------------------------ end


--
--------------------------------------------------------
Javier Rom�n Espinar <[EMAIL PROTECTED]>

            Linux Mobile System 1.0
           http://linuxmobile.sf.net
--------------------------------------------------------


_______________________________________________
pygtk mailing list   [EMAIL PROTECTED]
http://www.daa.com.au/mailman/listinfo/pygtk
Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/

Reply via email to