Update a Gtk.ProgressBar from another thread or process

后端 未结 2 1092
挽巷
挽巷 2021-01-03 11:11

I have a GUI with a progressbar. It should show the progress of the work a second thread does. I would like to have something like an event the thread can send to the GUIs p

2条回答
  •  Happy的楠姐
    2021-01-03 11:33

    Your implementation is correct. You are processing the threaded commands, sharing the feedback in a Queue, and updating the progressbar from the main loop via the GLib.timeout_add().

    Initially, this may seem like a complex way to do a simple progressbar update, but it is one of the only ways to spawn a child process and track the progress, all the while respecting the Gtk main loop.

提交回复
热议问题