gtk TextView widget doesn't update during function

℡╲_俬逩灬. 提交于 2019-12-08 11:46:20

问题


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.


回答1:


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?



来源:https://stackoverflow.com/questions/577302/gtk-textview-widget-doesnt-update-during-function

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!