Python中刷新标签
我在 gnome 面板中创建小程序。所有代码都很好。但面板中的信息是静态的。但需要及时刷新此信息。 1秒或5秒...
这是Python代码的一部分:
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import sys
import gobject
import gtk
import pygtk
import gnomeapplet
import time
import urllib2
pygtk.require('2.0')
def applet_factory(applet, iid):
label = gtk.Label("Simple text")
applet.add(label)
applet.show_all()
print('Factory started')
if __name__ == '__main__': # testing for execution
print('Starting factory')
gnomeapplet.bonobo_factory('OAFIID:SampleApplet_Factory',
gnomeapplet.Applet.__gtype__,
'Sample Applet', '0.1',
applet_factory)
我需要在时间间隔内刷新“简单文本”标签。怎么做到的?
I creating applet in gnome panel. All code is good. But info in panel is static. But need refresh this info in time. 1 secon or 5 second...
Here is part of python code:
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import sys
import gobject
import gtk
import pygtk
import gnomeapplet
import time
import urllib2
pygtk.require('2.0')
def applet_factory(applet, iid):
label = gtk.Label("Simple text")
applet.add(label)
applet.show_all()
print('Factory started')
if __name__ == '__main__': # testing for execution
print('Starting factory')
gnomeapplet.bonobo_factory('OAFIID:SampleApplet_Factory',
gnomeapplet.Applet.__gtype__,
'Sample Applet', '0.1',
applet_factory)
I need refresh "simple text" label in time interval. How did that?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
怎么样...:
如果您还需要将文本设置为不同的内容,
thelabel.set_text('something else')
即可实现。What about...:
If you also need to set the text to something different,
thelabel.set_text('something else')
will do that.