18 lines
4.4 KiB
Text
18 lines
4.4 KiB
Text
version=pmwiki-1.0.5
|
|
newline=²
|
|
text=!!! GtkTable quick example²²* can be used to display tables or matrix,²* far more easy to use than GtkTreeView widget²²[[include:Main/CodeTable]]<?php²²define('SIZE_X', 10);²define('SIZE_Y', 3);²²# WIDGET HIERARCHY²$window = new GtkWindow();²² //Creating our GtkTable² // note that the homogeneous property defaults to false.² $table = new GtkTable(SIZE_X, SIZE_Y, false);²² # labels² for($i = 0 ; $i < SIZE_X ; $i++){² for($j = 0 ; $j < SIZE_Y ; $j++){² $label = new GtkLabel($i . ':' . $j);² $table->attach($label, $i, $i+1, $j, $j+1, Gtk::EXPAND, Gtk::EXPAND);² }² }²²# SETTINGS²//Title of the window²$window->set_title("GtkTable usage demonstration");²//Initial placement of the window ²$window->set_position(Gtk::WIN_POS_CENTER);²//Connecting the "destroy" signal²$window->connect_simple('destroy', array('Gtk', 'main_quit'));²²²//Let's define the spacing between columns and rows to 10 pixels²$table->set_row_spacings(10);²$table->set_col_spacings(10);² ²²// ASSEMBLY²//Adding the table to the window²$window->add($table);²²$count = 0;²²foreach($table->get_children() as $child){² $count++;²² # set a random color² if($count %2 == 0)² $color = 'red';² else² $color = 'green';²² $child->modify_fg(Gtk::STATE_NORMAL, $label->get_colormap()->alloc_color($color));²²}²²²²//Make everything in the window visible²$window->show_all();²//Main loop²Gtk::main();²?>[[include:Main/CodeTableEnd]]²²²²
|
|
time=1157626101
|
|
diff:1157624719:1157624719:=1,49c1²< !!! GtkTable quick example²< ²< * can be used to display tables or matrix,²< * far more easy to use than GtkTreeView widget²< ²< [[include:Main/CodeTable]]<?php²< ²< define('SIZE_X', 5);²< define('SIZE_Y', 5);²< ²< //Creating the window that will hold our example program²< $window = new GtkWindow();²< //Title of the window²< $window->set_title("GtkTable usage demonstration");²< //Initial placement of the window ²< $window->set_position(Gtk::WIN_POS_CENTER);²< //Connecting the "destroy" signal²< $window->connect_simple('destroy', array('Gtk', 'main_quit'));²< ²< //Creating our GtkTable²< // note that the homogeneous property defaults to false.²< $table = new GtkTable(SIZE_X, SIZE_Y, false);²< ²< //Let's define the spacing between columns and rows to 10 pixels²< $table->set_row_spacings(10);²< $table->set_col_spacings(10);²< ²< //Adding the table to the window²< $window->add($table);²< ²< ²< for($i = 0 ; $i < SIZE_X ; $i++){²< for($j = 0 ; $j < SIZE_Y ; $j++){²< $label = new GtkLabel($i . ':' . $j);²< $label->²< $table->attach($label, $i, $i+1, $j, $j+1, Gtk::EXPAND, Gtk::EXPAND);²< }²< }²< ²< ²< ²< //Make everything in the window visible²< $window->show_all();²< //Main loop²< Gtk::main();²< ?>[[include:Main/CodeTableEnd]]²< ²< ²< ²---²> Describe GtkTable here.²\ No newline at end of file²
|
|
author=Marc Quinton
|
|
author:1157624719=Marc Quinton
|
|
host:1157624719=143.196.162.107
|
|
name=CodeSnippets.GtkTable
|
|
host=143.196.162.107
|
|
agent=Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.7.5) Gecko/20041217
|
|
rev=3
|
|
diff:1157624834:1157624719:=9c9²< define('SIZE_Y', 3);²---²> define('SIZE_Y', 5);²34a35²> $label->²
|
|
author:1157624834=Marc Quinton
|
|
host:1157624834=143.196.162.107
|
|
diff:1157626101:1157624834:=8c8²< define('SIZE_X', 10);²---²> define('SIZE_X', 5);²11c11²< # WIDGET HIERARCHY²---²> //Creating the window that will hold our example program²13,26d12²< ²< //Creating our GtkTable²< // note that the homogeneous property defaults to false.²< $table = new GtkTable(SIZE_X, SIZE_Y, false);²< ²< # labels²< for($i = 0 ; $i < SIZE_X ; $i++){²< for($j = 0 ; $j < SIZE_Y ; $j++){²< $label = new GtkLabel($i . ':' . $j);²< $table->attach($label, $i, $i+1, $j, $j+1, Gtk::EXPAND, Gtk::EXPAND);²< }²< }²< ²< # SETTINGS²33,34c19,23²< ²< ²---²> ²> //Creating our GtkTable²> // note that the homogeneous property defaults to false.²> $table = new GtkTable(SIZE_X, SIZE_Y, false);²> ²39,40d27²< ²< // ASSEMBLY²44,55d30²< $count = 0;²< ²< foreach($table->get_children() as $child){²< $count++;²< ²< # set a random color²< if($count %2 == 0)²< $color = 'red';²< else²< $color = 'green';²< ²< $child->modify_fg(Gtk::STATE_NORMAL, $label->get_colormap()->alloc_color($color));²56a32,36²> for($i = 0 ; $i < SIZE_X ; $i++){²> for($j = 0 ; $j < SIZE_Y ; $j++){²> $label = new GtkLabel($i . ':' . $j);²> $table->attach($label, $i, $i+1, $j, $j+1, Gtk::EXPAND, Gtk::EXPAND);²> }²
|
|
author:1157626101=Marc Quinton
|
|
host:1157626101=143.196.162.107
|