Python:如何使我的gtk窗口缓慢移动

Python:如何使我的gtk窗口缓慢移动,python,variables,window,pygtk,Python,Variables,Window,Pygtk,我希望我的gtk窗口从屏幕的中间移动到屏幕的左侧。不是一下子,而是慢慢地。这是我的密码: #!/usr/bin/python from termcolor import * import os import pygtk import gtk from qjfunctions import * import time pygtk.require('2.0') SaveDir = "/home/marc/QuickJotTexts" # main starts here window =

我希望我的gtk窗口从屏幕的中间移动到屏幕的左侧。不是一下子,而是慢慢地。这是我的密码:

#!/usr/bin/python
from termcolor import *
import os
import pygtk
import gtk
from qjfunctions import *
import time
pygtk.require('2.0')
SaveDir = "/home/marc/QuickJotTexts"

# main starts here    
window = gtk.Window(gtk.WINDOW_TOPLEVEL)
window.set_position(gtk.WIN_POS_CENTER)
window.set_size_request(400, 400)
window.move(x,y)
window.set_title("QuickJot")

#####IMAGES#####
settings = gtk.Image()
settings.set_from_file("settings.png")
settings.show()
info = gtk.Image()
info.set_from_file("info.png")
info.show()

#####BUTTONS####
button1 = gtk.Button("Create A New Thought")
button1.connect("clicked", new_file)
button2 = gtk.Button("View A Thought")
button2.connect("clicked", view_file)
button3 = gtk.Button("Delete A Thought")
button3.connect("clicked", delete_file)
button4 = gtk.Button()
button4.add(settings)
button4.connect("clicked", setting_menu)
button5 = gtk.Button()
button5.add(info)
button5.connect("clicked", info_menu)

fixed = gtk.Fixed()
fixed.put(button1, 125, 140)
fixed.put(button2, 148, 175)
fixed.put(button3, 143, 210)
fixed.put(button4, 350, 10)
fixed.put(button5, 305, 10)

window.add(fixed)
window.show_all()

reminder()
gtk.main()
请注意这一事实,其中的行表示:

window.move(x,y)
是使窗口移动的代码行。 这可能需要一个循环,比如:

loop = 1
while loop == 1:
x = 100
y = 100
#here is where the x and y values will change, slowly moving the window like an animation
x = x-1
y = y-1
window.move(x,y)
我可能完全错了,可能有一种更简单的方法可以做到这一点,我已经看得太多了。如有反馈,将不胜感激。
感谢StackOverflow:)

通过
gobject.timeout\u添加(间隔,回调,…您的.data…)
重复超时,并在那里执行“移动”。有关更多详细信息,请参阅


还要注意的是,pygtk2正在变老,新的方法是通过gintrospect使用内省绑定