Python Forum

Full Version: python3 + gtk3 image sequence
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hello, I tried to show some images in a sequence, when click a button show the first image and after one second show the next image, I tried the next code, but only show me the last image.

#!/usr/bin/python3
import os
import time
import gi
gi.require_version('Gtk', '3.0')
from gi.repository import Gtk, Gdk


class GridWindow(Gtk.Window):
    def __init__(self):
        Gtk.Window.__init__(self, title="NEOTECH")
        self.grid = Gtk.Grid()
        self.add(self.grid)        
        self.btnStartTest=Gtk.Button("Iniciar Prueba")
        self.btnStartTest.connect("clicked",self.StartTest)        
        self.image = Gtk.Image()
        self.image.set_from_file("logo-NeoTech.png")
        self.grid.add(self.btnStartTest)
        self.grid.attach(self.image,0,1,1,1)
        

    def StartTest(self,widget):
        self.image.set_from_file("gato3.jpg")
        time.sleep(2)
        self.image.set_from_file("gato4.jpg")
        print("fin")
        

win = GridWindow()
win.set_position(Gtk.WindowPosition.CENTER)
win.set_default_size(1000,480)
win.set_type_hint(Gdk.WindowTypeHint.MENU)
win.connect("delete-event", Gtk.main_quit)
win.show_all()
Gtk.main()