Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 113233
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T02:40:12+00:00 2026-05-11T02:40:12+00:00

in my python program to upload a file to the internet, im using a

  • 0

in my python program to upload a file to the internet, im using a GTK progress bar to show the upload progress. But the problems that im facing is that the progress bar does not show any activity until the upload is complete, and then it abruptly indicates upload complete. im using pycurl to make the http requests…my question is – do i need to have a multi-threaded application to upload the file and simultaneously update the gui? or is there some other mistake that im making?

Thanks in advance!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. 2026-05-11T02:40:13+00:00Added an answer on May 11, 2026 at 2:40 am

    I’m going to quote the PyGTK FAQ:

    You have created a progress bar inside a window, then you start running a loop that does some work:

    while work_left:     ...do something...     progressbar.set_fraction(...) 

    You will notice that the window doesn’t even show up, or if it does the progress bar stays frozen until the end of the task. The explanation is simple: gtk is event driven, and you are stealing control away from the gtk main loop, thus preventing it from processing normal GUI update events.

    The simplest solution consists on temporarily giving control back to gtk every time the progress is changed:

    while work_left:     ...do something...     progressbar.set_fraction(...)     while gtk.events_pending():         gtk.main_iteration() 

    Notice that with this solution, the user cannot quit the application (gtk.main_quit would not work because of new loop [gtk.main_iteration()]) until your heavy_work is done.

    Another solution consists on using gtk idle functions, which are called by the gtk main loop whenever it has nothing to do. Therefore, gtk is in control, and the idle function has to do a bit of work. It should return True if there’s more work to be done, otherwise False.

    The best solution (it has no drawbacks) was pointed out by James Henstridge. It is taking advantage of python’s generators as idle functions, to make python automatically preserve the state for us. It goes like this:

    def my_task(data):     ...some work...     while heavy_work_needed:         ...do heavy work here...         progress_label.set_text(data) # here we update parts of UI         # there's more work, return True         yield True     # no more work, return False     yield False  def on_start_my_task_button_click(data):     task = my_task(data)     gobject.idle_add(task.next) 

    The ‘while’ above is just an example. The only rules are that it should yield True after doing a bit of work and there’s more work to do, and it must yield False when the task is done.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 98k
  • Answers 98k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer I'm pretty certain that this is just an application of… May 11, 2026 at 7:34 pm
  • Editorial Team
    Editorial Team added an answer IOC configuration should be off to the side. It doesn't… May 11, 2026 at 7:34 pm
  • Editorial Team
    Editorial Team added an answer You can use something like Hibernate to accomplish this This… May 11, 2026 at 7:34 pm

Related Questions

I have a bunch of C files that are generated by a collection of
I am stuck with a fairly complex Python module that does not return useful
I want a Python program to import a list of words from a text
I'd like to have a python program alert me when it has completed its

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.