#!/usr/cogent/bin/gamma /* Example: Packing Widgets using Tables. * Another useful way to control widget layout is * with tables. This example packs three buttons * into a table. */ /* Initialize Cogent interprocess communication.*/ init_ipc("a", "aq"); /* Make a simple function for the buttons to call. */ function print_out (label) { princ(string(label," was pressed.\n")); } /* Create a window.*/ window = new(GtkWindow); window.set_border_width(20); window.set_default_size(200,100); window.set_title("Table Packing Example"); /* Make a 2 X 2 table, set row and column spacings, * and add it to the window. */ table = new(GtkTable); table.n_rows = 2; table.n_columns = 2; table.set_col_spacings(30); table.set_row_spacings(10); window.add(table); /* Make a button and put it in the upper left cell * of the table. */ button1 = new(GtkButton); button1.label = "Button 1"; button1.signal("clicked",#print_out(button1.label)); table.attach_defaults(button1, 0, 1, 0, 1); /* Make another button for the upper right cell.*/ button2 = new(GtkButton); button2.label = "Button 2"; button2.signal("clicked",#print_out(button2.label)); table.attach_defaults(button2, 1, 2, 0, 1); /* Make a "Quit" button that spans both bottom cells * of the table. */ button_q = new(GtkButton); button_q.label = "Quit"; button_q.signal("clicked",#gtk_main_quit()); table.attach_defaults(button_q, 0, 2, 1, 2); /* Show everything and enter the GTK main processing loop.*/ window.show_all(); gtk_main();
Copyright © 1995-2010 by Cogent Real-Time Systems, Inc. All rights reserved.