0

同じ URL から新しいフレームを取得するために Gtk.Image を自動更新する方法は? 画像 now.jpeg は 1 秒あたり 1 フレームです。Python スクリプトをロードすると、更新された画像ではなく最初のフレームのみが表示されます。

import os
import urllib2
from gi.repository import Gtk
from gi.repository.GdkPixbuf import Pixbuf

def quit_event(widget, event):
    os.remove(imgname)
    Gtk.main_quit()

imgname = 'now.jpeg'
url = 'http://192.168.1.11/'+imgname

response = urllib2.urlopen(url)
with open(imgname, 'wb') as img:
    img.write(response.read())

image = Gtk.Image()
pb = Pixbuf.new_from_file(imgname)
image.set_from_pixbuf(pb)

window = Gtk.Window()
window.connect('delete-event', quit_event)
window.add(image)
window.show_all()

Gtk.main()
4

1 に答える 1