Python Forum
python3 + gtk3 image sequence
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
python3 + gtk3 image sequence
#1
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()
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  [GI] Error when I close the interface Glade/GTK3/ Charles25 2 743 Jun-16-2020, 07:02 PM
Last Post: Charles25
  Problem with Gtk3 and GLArea gsohler 0 1,007 Aug-12-2019, 07:33 AM
Last Post: gsohler
  Help - GTK3 + Pango: Printing data as table format scandido 0 1,915 Jan-26-2018, 06:03 PM
Last Post: scandido
  Python minesweeper game gtk3 get label value after click lukassz 0 2,014 Mar-25-2017, 08:14 PM
Last Post: lukassz

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020