Re: Best way to busy-wait in Python 3 / Gtk+ 3?



On 6 October 2012 15:48, Filip Lamparski <matka poohatka gmail com> wrote:
However, the thumbnail loading process takes a long time, so I want to put
it into another process, with the GUI displaying a spinner or a progress
bar until the loading finishes.

Sorry, I don't use Python much, but in C you'd start a thread to do
the load and then have that call g_idle_add() when it finished.
Meanwhile the main thread stays just handling inputs and repaints, but
you display some sort of busy indicator until the idle callback fires.
Something like:

on_load_button_click:
  busy = True
  update_view
  start worker thread

worker thread:
  load thumbnail
  g_idle_add (thumbnail_done, thumbnail)

thumbnail_done (thumbnail)
  busy = False
  set thumbnail
  update_view

John



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]