通过滚动窗口读取输入文本?
我使用 pyGTK 创建了一个滚动窗口。当我在滚动窗口中键入一些文本时,该键入的文本必须写入文件中。我有一个可以写入文件的函数。但是,当我在滚动窗口中输入一些文本时,必须调用该函数。如果有人向我建议解决方案,那将非常有帮助。
I have created a scrolled window using pyGTK. When I type some text in the scrolled window,that typed text must be written in a file. I have a function which could write to the file. But as and when I go typing some text into the scrolled window that function must be called. If anyone suggest me the solution that would be very helpufull.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果您键入文本,您应该订阅文本区域的更改事件,然后计划并执行将文本保存到文件的函数,例如每 1 秒一次,这样当您键入文本时,文本就会自动保存。或者您可以有一个后台线程来监视该控件的状态并定期保存它,延迟 1 秒,这样。我认为线程方式更正确
You should subscribe to change event of text area were you type text and then schedule and execution of function that saves the text to file say each 1 second, so as you type your text would automatically saved. or you could have a background thread that monitors state of that control and save-s it regularly with 1 second delay so that. I think thread way is more correct