from gtk import * rows=9 cols=4 win = GtkWindow() box = GtkVBox() table = GtkTable(rows, cols, FALSE) text = GtkText() close = GtkButton("close") button_strings=['hypot(','e',',','clear','log(','log10(','pow(','pi','sinh(','cosh(','tanh(','sqrt(','asin(', 'acos(','atan(','(','sin(','cos(','tan(',')','7','8','9','/','4','5','6','*','1','2','3','-', '0','.','=','+' ] button = map(lambda i:GtkButton(button_strings[i]), range(rows*cols)) def main(): win.set_usize(300, 350) win.connect("destroy", mainquit) win.set_title("Scientific Calculator") win.add(box) box.show() text.set_editable(FALSE) text.set_usize(300,1) text.show() text.insert_defaults(" ") box.pack_start(text) table.set_row_spacings(5) table.set_col_spacings(5) table.set_border_width(0) box.pack_start(table) table.show() for i in range(rows*cols) : y,x = divmod(i, cols) table.attach(button[i], x,x+1, y,y+1) button[i].show() close.show() box.pack_start(close) win.show() mainloop() main()