/** * Constructor Method */ function __construct() { parent::__construct(); parent::set_size_request(840, 640); parent::set_position(GTK::WIN_POS_CENTER); parent::connect_simple('delete-event', array($this, 'onClose')); parent::connect_simple('destroy', array('Gtk', 'main_quit')); parent::set_title(self::APP_TITLE); parent::set_icon(GdkPixbuf::new_from_file('favicon.png')); $gtk = GtkSettings::get_default(); $gtk->set_long_property("gtk-button-images", TRUE, 0); $gtk->set_long_property("gtk-menu-images", TRUE, 0); self::$inst = $this; $ini = parse_ini_file('application.ini'); $lang = $ini['language']; TAdiantiCoreTranslator::setLanguage($lang); TApplicationTranslator::setLanguage($lang); date_default_timezone_set($ini['timezone']); $this->content = new GtkFixed(); $vbox = new GtkVBox(); parent::add($vbox); $vbox->pack_start(GtkImage::new_from_file('app/images/pageheader-gtk.png'), false, false); $MenuBar = TMenuBar::newFromXML('menu.xml'); $vbox->pack_start($MenuBar, false, false); $vbox->pack_start($this->content, true, true); parent::show_all(); }
public function __construct() { parent::__construct(); parent::set_title('Incluir'); parent::connect_simple('destroy', array('Gtk', 'main_quit')); parent::set_default_size(400, 240); parent::set_border_width(10); parent::set_position(GTK::WIN_POS_CENTER); $vbox = new GtkVBox(); $this->labels['id'] = new GtkLabel('Código:'); $this->campos['id'] = new GtkEntry(); $this->campos['id']->set_size_request(80, -1); $this->labels['nome'] = new GtkLabel('Nome: '); $this->campos['nome'] = new GtkEntry(); $this->campos['nome']->set_size_request(240, -1); $this->labels['endereco'] = new GtkLabel('Endereço: '); $this->campos['endereco'] = new GtkEntry(); $this->campos['endereco']->set_size_request(240, -1); $this->labels['telefone'] = new GtkLabel('Telefone: '); $this->campos['telefone'] = new GtkEntry(); $this->campos['telefone']->set_size_request(140, -1); $this->labels['id_cidade'] = new GtkLabel('Cidade: '); $this->campos['id_cidade'] = GtkComboBox::new_text(); $this->campos['id_cidade']->set_size_request(240, -1); $this->campos['id_cidade']->insert_text(0, 'Porto Alegre'); $this->campos['id_cidade']->insert_text(1, 'São Paulo'); $this->campos['id_cidade']->insert_text(2, 'Rio de Janeiro'); $this->campos['id_cidade']->insert_text(3, 'Belo Horizonte'); foreach ($this->campos as $chave => $objeto) { $hbox = new GtkHBox(); $hbox->pack_start($this->labels[$chave], false, false); $hbox->pack_start($this->campos[$chave], false, false); $this->labels[$chave]->set_size_request(100, -1); $this->labels[$chave]->set_alignment(1, 0.5); // xAlign, yalign (0.5, 1) $vbox->pack_start($hbox, false, false); } $vbox->pack_start(new GtkHSeparator(), true, true); // cria uma caixa de botões $buttonbox = new GtkHButtonBox(); $buttonbox->set_layout(Gtk::BUTTONBOX_START); // cria um botão de salvar $botao = GtkButton::new_from_stock(Gtk::STOCK_SAVE); // conecta o botão ao método onSaveClick() $botao->connect_simple('clicked', array($this, 'onSaveClick')); $buttonbox->pack_start($botao, false, false); // cria um botão de fechar a aplicação $botao = GtkButton::new_from_stock(Gtk::STOCK_CLOSE); $botao->connect_simple('clicked', array('Gtk', 'main_quit')); $buttonbox->pack_start($botao, false, false); $vbox->pack_start($buttonbox, false, false); parent::add($vbox); // exibe a janela parent::show_all(); }
/** * Cria a janela no modo splash * * @name set_splash_image($image) * @param string $image Caminho para a imagem do splash * @return GtkFixed */ public function set_splash_image($image) { // Carrega a imagem $pixbuf = GdkPixbuf::new_from_file($image); // Modifica as propriedades da janela parent::set_type_hint(Gdk::WINDOW_TYPE_HINT_SPLASHSCREEN); parent::set_size_request($pixbuf->get_width(), $pixbuf->get_height()); parent::set_position(GTK::WIN_POS_CENTER); parent::realize(); // Adiciona a imagem no fundo do GtkWindow list($pixmap, $mask) = $pixbuf->render_pixmap_and_mask(255); $style = parent::get_style(); $style = $style->copy(); $style->bg_pixmap[Gtk::STATE_NORMAL] = $pixmap; parent::set_style($style); // Adiciona um fixed para futuros widgets $fixed = new GtkFixed(); parent::add($fixed); // Mostra o splash parent::show_all(); // Retorna o fixed para adição de widgets return $fixed; }
function ominus() { global $G; if ($G["odm"]->get_text() > 0) { $G["odm"]->set_text($G["odm"]->get_text() - 1); pocitajtb(); } } function pocitajtb() { #prepocet tb podla st. casu a chyb } load_startovka($cb[0]); $p = current($G["astartovka"]); show_vysledky($G['beh']->get_text(), $p[1]); $window->show_all(); function show_display() { global $window2, $G; $window2->show_all(); } $timeout_ID = Gtk::timeout_add(10, 'process_task'); Gtk::main(); function buttonbp() { global $G; if (prev($G["behy"])) { $b = current($G["behy"]); $G["beh"]->set_text($b[0]); load_startovka($b[0]); } else {
return false; } function starttips($tipsquery, $tooltips) { if ($tooltips->enabled) { $tipsquery->start_query(); $tooltips->disable(); } else { // $tipsquery->stop_query(); - this is automatic when the caller button is clicked $tooltips->enable(); } } $window = new GtkWindow(); $window->set_title('Tooltip'); $window->connect_simple('destroy', array('gtk', 'main_quit')); $window->add($vbox = new GtkVBox()); $vbox->pack_start($button = new GtkButton('Button1')); $tooltips->set_tip($button, 'This is button 1', 'Here is some help for button 1'); $vbox->pack_start($button = new GtkButton('Button2')); $tooltips->set_tip($button, 'This is button 2. This is also a really long tooltip which probably won\'t fit on a single line and will therefore need to be wrapped. Hopefully the wrapping will work correctly.', 'Here is some Help for button 2'); $vbox->pack_start($button = new GtkButton('Override TipsQuery Label')); $tooltips->set_tip($button, 'Toggle TipsQuery view.', 'Help for Help?'); $popup = new GtkWindow(Gtk::WINDOW_POPUP); $popup->add($tipsquery = new GtkTipsQuery()); $tipsquery->set_labels('Click to get help', 'No help found'); $button->connect_simple('clicked', 'starttips', $tipsquery, $tooltips); $tipsquery->set_caller($button); $tipsquery->connect('widget-entered', 'showtips'); $window->show_all(); $popup->show_all(); Gtk::main();
<?php $w = new GtkWindow(); $t = new GtkTextBuffer(); $v = new GtkTextView($t); $s = new GtkSpell($v); $s->set_language('en'); $w->set_title('Spell Check'); $w->set_size_request(200, 200); $w->add($v); $w->show_all(); $w->connect_simple('destroy', array('Gtk', 'main_quit')); Gtk::main(); ?>
#!/usr/bin/php -c/etc/php/php-gtk.ini #GTK Hello world! by Harvie 2oo9 <?php if (!class_exists('gtk')) { die("Please load the php-gtk2 module in your php.ini\r\n"); } $wnd = new GtkWindow(); $wnd->set_title('Hello world'); $wnd->connect_simple('destroy', array('gtk', 'main_quit')); $lblHello = new GtkLabel("Just wanted to say\r\n'Hello world!'"); $wnd->add($lblHello); $wnd->show_all(); Gtk::main();
/** * Show the window */ public function show() { if (parent::get_child()) { parent::get_child()->show(); } parent::show_all(); }
<?php $someHtml = ' <h1>Hello World!</h1> <p><font color="red" size="20">This is GtkHTML</font></p> <h2>Bye Bye World!</h2>'; $x = new GtkWindow(); $y = new GtkHTML(); $y->set_title("HTML Test!"); $y->load_from_string($someHtml); $x->add($y); $x->show_all(); $x->connect_simple('destroy', array('Gtk', 'main_quit')); Gtk::main();
<?php $x = new GtkSheet(10, 10, 'test'); $y = new GtkWindow(); $y->add($x); $y->connect_simple('destroy', array('Gtk', 'main_quit')); $y->set_title('Testing GtkSheet'); $y->show_all(); Gtk::main();
/** * Show a popup with information about the application. * * The popup should show information about the version, * the author, the license, where to get the latest * version and a short description. * * @access public * @param none * @return void */ function about() { // Create the new window. $about = new GtkWindow(); $about->set_title('About PHPUnit GUI Gtk'); $about->set_usize(250, -1); // Put two vboxes in the hbox. $vBox = new GtkVBox(); $about->add($vBox); // Create the labels. $version = new GtkLabel(" Version: 1.0"); $license = new GtkLabel(" License: PHP License v3.0"); $where = new GtkLabel(" Download from: http://pear.php.net/PHPUnit/"); $unitAuth = new GtkLabel(" PHPUnit Author: Sebastian Bergman"); $gtkAuth = new GtkLabel(" Gtk GUI Author: Scott Mattocks"); // Align everything to the left $where->set_alignment(0, 0.5); $version->set_alignment(0, 0.5); $license->set_alignment(0, 0.5); $gtkAuth->set_alignment(0, 0.5); $unitAuth->set_alignment(0, 0.5); // Pack everything into the vBox; $vBox->pack_start($version); $vBox->pack_start($license); $vBox->pack_start($where); $vBox->pack_start($unitAuth); $vBox->pack_start($gtkAuth); // Connect the destroy signal. $about->connect('destroy', array('gtk', 'true')); // Show the goods. $about->show_all(); }