Saturday, 15 January 2011

variables - Python: How can I make my gtk window move slowly -



variables - Python: How can I make my gtk window move slowly -

i gtk window move middle of screen left side of screen. not @ once, slowly. here code:

#!/usr/bin/python termcolor import * import os import pygtk import gtk 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 new thought") button1.connect("clicked", new_file) button2 = gtk.button("view thought") button2.connect("clicked", view_file) button3 = gtk.button("delete 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()

take note fact line says:

window.move(x,y)

is line of code create window move. loop needed this, this:

loop = 1 while loop == 1: x = 100 y = 100 #here x , y values change, moving window animation x = x-1 y = y-1 window.move(x,y)

i totally wrong, , there simpler way that have on looked. feedback appreciated. stackoverflow:)

use repeated timeout via gobject.timeout_add(interval, callback, ...your.data...) , "movement" there. more details see pygtk2 tutorial

also note pygtk2 getting old , new way things utilize introspection bindings via gintrospect.

python variables window pygtk

No comments:

Post a Comment