コード例 #1
0
 /**
  * @name __construct()
  * @return GtkComboBox
  */
 public function __construct()
 {
     // Cria o model
     $this->__widgets['model'] = new GtkListStore(Gobject::TYPE_STRING, Gobject::TYPE_PHP_VALUE);
     // Cria o combo
     parent::__construct($this->__widgets['model']);
     // Cria o render
     $this->__widgets['render'] = new GtkCellRendererText();
     parent::set_model($this->__widgets['model']);
     parent::pack_start($this->__widgets['render']);
     parent::set_attributes($this->__widgets['render'], "text", 0);
 }
コード例 #2
0
ファイル: combobox.php プロジェクト: amitjoy/php-gtk
$title->set_size_request(-1, 60);
$vbox->pack_start($title, 0, 0);
// the selection
$list = array('item 1', 'item 2', 'item 3', 'item 4');
$vbox->pack_start($hbox = new GtkHBox(), 0, 0);
$hbox->pack_start(new GtkLabel('Select: '), 0, 0);
// Create a combobox
$combobox = new GtkComboBox();
// Create a model
if (defined("GObject::TYPE_STRING")) {
    $model = new GtkListStore(GObject::TYPE_STRING);
} else {
    $model = new GtkListStore(Gtk::TYPE_STRING);
}
// Set up the combobox
$combobox->set_model($model);
// note 1
$cellRenderer = new GtkCellRendererText();
// note 2
$combobox->pack_start($cellRenderer);
$combobox->set_attributes($cellRenderer, 'text', 0);
// note 3
// Stuff the choices in the model
foreach ($list as $choice) {
    $model->append(array($choice));
}
// Set up a hbox to contain the combobox as well as the Submit button
$hbox->pack_start($combobox, 0, 0);
$hbox->pack_start(new GtkLabel('  '), 0, 0);
$hbox->pack_start($button = new GtkButton('Submit'), 0, 0);
$button->set_size_request(60, 24);
コード例 #3
0
<?php

// FIXED by Christian on 2006-03-06
$cmb = new GtkComboBox();
$mod = new GtkListStore(Gtk::TYPE_STRING);
$cmb->set_model($mod);
$mod->append(array("one"));
$mod->append(array("two"));
$mod->append(array("three"));
$cmb->set_active(1);
//that should return an iter, not require one
var_dump($cmb->get_active_iter());
コード例 #4
0
	/**
	 * Used for settings up a GtkComboBox() without writing tons of code.
	 * @param GtkComboBox $cb The GtkComboBox() which should be initialized.
	*/
	function combobox_init(GtkComboBox $cb){
		$cellRenderer = new GtkCellRendererText();
		$cb->set_model(new GtkListStore(_TYPE_STRING));
		$cb->pack_start($cellRenderer);
		$cb->set_attributes($cellRenderer, "text", 0);
	}