Oct-24-2016, 08:43 PM
Can anyone explain why the following code isn't working as I expect? What I expect is a soccer ball png image would appear in the upper left corner and make several small moves until it was in the upper right corner. What happens is it displays in the UL, then in the UR without the interim moves.
#!/usr/bin/python3 import gi gi.require_version('Gtk', '3.0') from gi.repository import Gtk, Gdk, GObject import time #-------------------------------------------------------------------- class MWin(Gtk.Window): def __init__(self): Gtk.Window.__init__(self) self.set_default_size(800,600) #set window size self.set_border_width(5) self.fixed = Gtk.Fixed() #add fixed container to window self.add(self.fixed) self.ExitButton = Gtk.Button(label=" Exit ") self.fixed.put(self.ExitButton,10,600-100) self.ExitButton.connect("clicked", self.exit_button_clicked) self.SoccerBall = Gtk.Image() self.SoccerBall.set_from_file("/usr/local/bin/graphics/soccerball.png") self.fixed.put(self.SoccerBall,1,1) self.DiagButton = Gtk.Button(label=" Dialog ") self.fixed.put(self.DiagButton,180,600-100) self.DiagButton.connect("clicked", self.ButtonClicked) def exit_button_clicked(self, widget): exit() def ButtonClicked (self, widget): self.SoccerBall.show() self.PtrJ = 0 while self.PtrJ < 10 : time.sleep(0.3) self.PtrJ += 1 self.fixed.move(self.SoccerBall,self.PtrJ*60,1) self.SoccerBall.show() return #--------------------------------------------------------------------------------------- MainWin = MWin() MainWin.show_all() Gtk.main()