-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy path00020.php
42 lines (31 loc) · 905 Bytes
/
00020.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
<?php
/**
* PHP-GTK Cookbook
*
* https://andor.com.br/php-gtk/cook/how-to-use-gtkcomboboxtext
*/
Gtk::init();
$window = new \GtkWindow();
$window->set_size_request(500, 500);
// create a box
$vbox = new \GtkBox(GtkOrientation::VERTICAL);
// create the label and add to the box
$label = new \GtkLabel("User");
$vbox->pack_start($label, FALSE, TRUE, 0);
// create the GtkComboBoxText
$entry = GtkComboBoxText::new_with_entry();
$vbox->pack_start($entry, FALSE, TRUE, 0);
// add some values
$entry->append_text("scorninpc");
$entry->append("0002", "admin");
$entry->append("0003", "bruno");
// connect to change signal
$entry->connect("changed", function($widget) {
var_dump($widget->get_active_text());
});
// add a label only to complete the window area
$vbox->pack_start(new GtkLabel(""), TRUE, TRUE, 0);
// add box to window
$window->add($vbox);
$window->show_all();
Gtk::main();