GTK+ Forums

Discussion forum for GTK+ and Programming. Ask questions, troubleshoot problems, view and post example code, or express your opinions.
It is currently Fri Nov 21, 2014 5:45 pm

All times are UTC




Post new topic Reply to topic  [ 3 posts ] 
Author Message
 Post subject: Problems getting progressbar to show progress during running
PostPosted: Thu May 15, 2008 2:00 pm 
Offline
Familiar Face

Joined: Thu May 08, 2008 9:50 am
Posts: 8
I have a problem with a progressbar. I want, for every file I look into, for the bar to show some progress, so that while you wait for the program to finish, the whole time can see the bar moving. When I implement it, all that happens is that the bar gets filled first after the program's finished. How do I make it show during the process?

self.progressbar = gtk.ProgressBar()
self.progressbar.show()

self.step = 1/len(list)

for file in list:
self.x += self.step
#do smth with file
self.progressbar.set_fraction(self.x)


Top
 Profile  
 
 Post subject:
PostPosted: Thu May 15, 2008 3:35 pm 
Offline
Never Seen the Sunlight

Joined: Wed Sep 21, 2005 12:07 am
Posts: 563
Location: Portland, OR USA
You want to allow the GUI to get updated... as it's waiting for idle time to do so.

Code:
for file in list:
    self.x += self.step
    self.progressbar.set_fraction(self.x)
    while gtk.events_pending(): gtk.main_iteration()

_________________
Micah Carrick - Forum Administrator
http://www.micahcarrick.com


Top
 Profile  
 
 Post subject:
PostPosted: Fri May 16, 2008 8:27 am 
Offline
Familiar Face

Joined: Thu May 08, 2008 9:50 am
Posts: 8
Thanks a lot! Now it works smoothly :)


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC


Who is online

Users browsing this forum: Yahoo [Bot] and 3 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group