Thought I'd put together a small example to show what I mean:

import pygtk
pygtk.require("2.0")
import gtk
import sys
import time

def do_stuff():
    time.sleep(5)
    print 'brian'    
####################################
# >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> handles
####################################
class handles:
    def on_login_window_destroy(event):
        sys.exit(1)
        
####################################
# >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> define main
####################################
class LoginApp: 
    def __init__(self):
        # set the glade file
        self.builder = gtk.Builder()
        self.builder.add_from_file("login.glade")
        self.window = self.builder.get_object("login_window") 
        self.builder.connect_signals(handles.__dict__)
        self.server = self.builder.get_object("server")
        self.info = self.builder.get_object("info")
        self.window.show()
        
        
    def __getitem__(self,key):
        # provide link to widgets
        return self.builder.get_object(key)

####################################
# >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> run application
####################################
if __name__ == '__main__':
    ghs = LoginApp() 
    do_stuff()
    gtk.main()

The window outline appears but no inside until after 5 sec when the full window 
takes shape my name then appears.

What I want is the full window appearing at the beginning and then 5 sec later 
my name appears.

Make sense?

Brian

-----Original Message-----
From: Michael Urman [mailto:[email protected]] 
Sent: Wednesday, 23 June 2010 12:46 p.m.
To: Brian Rowlands (Greymouth High School)
Cc: [email protected]
Subject: Re: [pygtk] Updating a window

On Tue, Jun 22, 2010 at 18:33, Brian Rowlands (Greymouth High School)
<[email protected]> wrote:
> The issue I have is that the outline of the window appears with the inside
> blank until do_stuff() completes when the window is fully defined.
>
> If I have:
>
> gtk.main()
> do_stuff()
>
> then the window appears fine but nothing gets done.
>
> Don’t know if there is a command to update a window.
>
> Probably simple. If not, a reference/pointer would be appreciated.

The right answer really depends on what sort of things you are doing
inside do_stuff. If it's work that makes sense to move piecewise to
signal handlers, then do that. If it's a batch of work with convenient
locations to do event processing (say every time through a loop), call
gtk.main_iteration() from time to time, possibly within a while
gtk.events_pending().

Welcome to event-based programming!
-- 
Michael Urman
_______________________________________________
pygtk mailing list   [email protected]
http://www.daa.com.au/mailman/listinfo/pygtk
Read the PyGTK FAQ: http://faq.pygtk.org/

Reply via email to