Python Forum
[pygtk] fixed.move not working as expected
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[pygtk] fixed.move not working as expected
#1
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()
Reply


Messages In This Thread
[pygtk] fixed.move not working as expected - by DennisT - Oct-24-2016, 08:43 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  [PyGUI] Creating hot spots in PyGTK DrakeSoft 1 1,642 Aug-01-2022, 04:35 PM
Last Post: Axel_Erfurt
  [PyGTK] How to center text on multi-line buttons? Lomax 3 4,297 Jan-23-2021, 03:23 PM
Last Post: Lomax
  [PyGTK] Creating Book Table ramazanemreosmanoglu 3 1,884 Oct-27-2020, 06:47 PM
Last Post: Axel_Erfurt
  [Tkinter] Scroll bar height is not fixed with Text widget MeeranRizvi 2 15,530 Feb-06-2017, 12:24 PM
Last Post: MeeranRizvi

Forum Jump:

User Panel Messages

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