Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!usr/bin/python
- #test
- import pygtk
- pygtk.require ('2.0')
- import gtk
- import random
- class Gtest:
- def __init__(self):
- self.window1 = gtk.Window(gtk.WINDOW_TOPLEVEL)
- #creo window1
- self.window1.connect("delete_event", self.delete_event)
- self.window1.connect("destroy", self.destroy)
- #due metodi che vengono applicati a window1
- self.window1.set_resizable(True)
- self.window1.set_title("ariccchime")
- self.window1.set_default_size(400, 400)
- #attributi di window1
- self.button = gtk.Button("cliccami")
- #crea un bottone
- self.button.connect("clicked", self.cliccato)
- #attributi e segnali del bottone
- self.fix = gtk.Fixed()
- self.fix.put(self.button, 15, 25)
- self.window1.add(self.fix)
- #non aggiungere window1.add(button) perche' Fixed ci pensa da solo
- #self.window1.add(self.button)
- self.window1.show_all()
- #mostra window1 e il bottone
- def cliccato(self, widget, data=None):
- self.button.set_label("mi sposto")
- self.fix.put(self.button, random.randrange(0, 400), random.randrange(0, 400))
- def delete_event(self, widget, event, data=None):
- return False
- def destroy(self, widget, data = None):
- return gtk.main_quit()
- def main(self):
- gtk.main()
- if __name__ == "__main__":
- test = Gtest()
- test.main()
Add Comment
Please, Sign In to add comment