gtk TextView widget doesn't update during func

2019-06-08 15:26发布

I'm new to GUI programming with python and gtk, so this is a bit of a beginners question. I have a function that is called when a button is pressed which does various tasks, and a TextView widget which I write to after each task is completed. The problem is that the TextView widget doesn't update until the entire function has finished. I need it to update after each task.

标签: python gtk pygtk
1条回答
我想做一个坏孩纸
2楼-- · 2019-06-08 15:50

After each update to the TextView call

while gtk.events_pending():
  gtk.main_iteration()

You can do your update through a custom function:

def my_insert(self, widget, report, text):

  report.insert_at_cursor(text)
  while gtk.events_pending():
    gtk.main_iteration()

From the PyGTK FAQ: How can I force updates to the application windows during a long callback or other internal operation?

查看更多
登录 后发表回答