Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env python
- import gtk,os,random
- class WIN:
- def __init__(self):
- self.CODE=""
- self.win=gtk.Window()
- self.win.connect("destroy", lambda w:gtk.main_quit())
- self.win.show()
- self.vbox=gtk.VBox()
- self.win.add(self.vbox)
- self.win.connect("key-press-event", self.closeme)
- self.win.connect("key-press-event", self.code)
- for i in range(0,5):
- filename="/usr/share/dict/words"
- file=open(filename,'r')
- file_size=os.stat(filename)[6]
- file.seek((file.tell()+random.randint(0,file_size-1))%file_size)
- file.readline()
- line=file.readline()
- self.button=gtk.Button(line)
- self.button.connect("clicked", self.Title_Changer, line)
- self.vbox.pack_start(self.button)
- self.win.show_all()
- def Title_Changer(self, widget, title):
- self.win.set_title(title)
- def closeme(self, widget, event):
- if event.keyval == gtk.keysyms.Escape:
- gtk.main_quit()
- def code(self, widget, event):
- if event.keyval == gtk.keysyms.i:
- self.CODE="i"
- else:
- self.CODE=self.CODE + chr(event.keyval)
- print self.CODE
- if self.CODE == "idqd":
- self.CODE=''
- self.alert()
- def alert(self):
- msgbox = gtk.MessageDialog(self.win,gtk.DIALOG_DESTROY_WITH_PARENT,gtk.MESSAGE_WARNING,gtk.BUTTONS_CLOSE, "You Win" )
- msgbox.run()
- msgbox.destroy()
- mainapp=[]
- for i in range(1,4):
- mainapp.append(WIN())
- gtk.main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement