views:

31

answers:

0

I have a timer in a PyGTK app, and it works fine --- until I maximize the window; then the timer stops firing. Has anyone experienced this? What can be done about it? Here's a code sample:

import gtk, gobject

files = ["C:/images/test1.jpg", "C:/images/test2.jpg", "C:/images/test3.jpg"]

win = gtk.Window()
win.set_title("Slideshow")

img_iter = iter(files)
img = gtk.image_new_from_file(img_iter.next())

win.add(img)

def next_image():
    global img, img_iter
    win.remove(img)
    try:
        img = gtk.image_new_from_file(img_iter.next())
    except:
        img_iter = iter(files)
        img = gtk.image_new_from_file(img_iter.next())
    win.add(img)
    img.show()
    return True

win.connect("destroy", gtk.main_quit)
win.show_all()
timer_id = gobject.timeout_add(5000, next_image)

gtk.main()

Other pertinent info: I'm using Python 2.6.5 and the latest PyGTK on Windows XP. When I try it on Ubuntu Lucid with Python 2.6.5 and PyGTK 2.17.0, it works fine.


Solved:

It turns out it was only incidental to maximizing the image. When the image exceeds the size of the window, the next image won't replace it. The timer kept firing just fine.

The reason it seemed to work on Ubuntu is that I have a larger screen on that computer!