# another gui import pygtk import gtk import pango import time def addtext(TV,text): #add to gtk.TextView buf = TV.get_buffer() it = buf.get_iter_at_mark(buf._get_insert()) buf.insert(it,text) #addtext # gui class class gui3: ### construction __init__ is crucial def __init__(self,x,y): # x,y sets position self.width = 1000 self.height = 360 self.window = gtk.Window(gtk.WINDOW_TOPLEVEL) # window object self.window.resize(self.width,self.height) ### window closing behavior: self.window.connect("destroy",lambda w: gtk.main_quit()) ### boxes for arranging the gui "widgets" mainbox = gtk.VBox(False,10) self.window.add(mainbox) # add window to mainbox box1 = gtk.HBox(False,10) box0 = gtk.HBox(False,10) ## why sometimes no 'self.'??? ### Create gui "widgets" self.Bt = [gtk.Button("OK"), gtk.Button("Not OK"), gtk.Button("So So"), gtk.Button("Bad Day")] self.delay = [0,0,0,0] # delay between clicks self.entry = gtk.Entry(40) # text entry/display ### adjust sizes of buttons for button in self.Bt: button.set_size_request(60,20) ### pack buttons into boxes box0.pack_start(self.Bt[0],True,True,5) box0.pack_start(self.Bt[1],True,True,5) box1.pack_start(self.Bt[2],True,True,5) box1.pack_start(self.Bt[3],True,True,5) ### pack everything into mainbox: mainbox.pack_start(box0,True,True,5) mainbox.pack_start(box1,True,True,5) mainbox.pack_start(self.entry,True,True, 20) ### connect widgets with "call-back" functions i = 0 while i