/** * 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(); }
/** * 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; set_error_handler(array('TCoreApplication', 'errorHandler')); }
$tipsquery->set_text($tip_private); $tipsquery->emit_stop_by_name('widget-entered'); 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();
<?php /* Create base window */ $window = new GtkWindow(); $window->set_title('Notebooks and Pages'); $window->connect_simple('destroy', array('gtk', 'main_quit')); $window->add($vbox = new GtkHBox()); $group = 'MyGroup'; $vbox->add($notebook1 = new GtkNoteBook()); $notebook1->append_page($label = new GtkLabel('This is the first page')); $notebook1->set_tab_detachable($label, true); $notebook1->append_page($label = new GtkLabel('This is the second page')); $notebook1->set_tab_detachable($label, true); $notebook1->append_page($label = new GtkLabel('This is the third page')); $notebook1->set_tab_detachable($label, true); $notebook1->set_group($group); var_dump($notebook1->get_group()); $vbox->add($notebook2 = new GtkNoteBook()); $notebook2->append_page($label = new GtkLabel('This is the first page')); $notebook2->set_tab_detachable($label, true); $notebook2->append_page($label = new GtkLabel('This is the second page')); $notebook2->set_tab_detachable($label, true); $notebook2->append_page($label = new GtkLabel('This is the third page')); $notebook2->set_tab_detachable($label, true); $notebook2->set_group($group); var_dump($notebook2->get_group()); unset($group); $vbox->add($notebook3 = new GtkNoteBook()); $notebook3->append_page($label = new GtkLabel('This is the first page')); $notebook3->set_tab_detachable($label, true); $notebook3->append_page($label = new GtkLabel('This is the second page'));
<?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(); ?>
function create_notebook() { global $windows, $sample_notebook, $book_open, $book_open_mask, $book_closed, $book_closed_mask, $book_open_xpm, $book_closed_xpm; $items = array('Standard' => array('standard_notebook', &$sample_notebook), 'No tabs' => array('notabs_notebook', &$sample_notebook), 'Scrollable' => array('scrollable_notebook', &$sample_notebook)); if (!isset($windows['notebook'])) { $window = new GtkWindow(); $windows['notebook'] = $window; $window->connect('delete_event', 'delete_event'); $window->set_title('Notebook'); $window->set_border_width(0); $box1 =& new GtkVBox(false, 0); $box1->show(); $window->add($box1); $sample_notebook = new GtkNotebook(); $sample_notebook->show(); $sample_notebook->connect('switch_page', 'page_switch'); $sample_notebook->set_tab_pos(GTK_POS_TOP); $box1->pack_start($sample_notebook, true, true, 0); $sample_notebook->set_border_width(10); $sample_notebook->realize(); list($book_open, $book_open_mask) = Gdk::pixmap_create_from_xpm_d($sample_notebook->window, null, $book_open_xpm); list($book_closed, $book_closed_mask) = Gdk::pixmap_create_from_xpm_d($sample_notebook->window, null, $book_closed_xpm); create_pages(&$sample_notebook, 1, 5); $separator =& new GtkHSeparator(); $separator->show(); $box1->pack_start($separator, false, true, 10); $box2 =& new GtkHBox(false, 5); $box2->show(); $box2->set_border_width(10); $box1->pack_start($box2, false, true, 0); $button =& new GtkCheckButton('popup menu'); $button->show(); $box2->pack_start($button, true, false, 0); $button->connect('clicked', 'notebook_popup', &$sample_notebook); $button =& new GtkCheckButton('homogeneous tabs'); $button->show(); $box2->pack_start($button, true, false, 0); $button->connect('clicked', 'notebook_homogeneous', &$sample_notebook); $box2 =& new GtkHBox(false, 5); $box2->show(); $box2->set_border_width(10); $box1->pack_start($box2, false, true, 0); $label =& new GtkLabel('Notebook Style:'); $label->show(); $box2->pack_start($label, false, true, 0); $omenu = build_option_menu($items, 3, 0, &$sample_notebook); $omenu->show(); $box2->pack_start($omenu, false, true, 0); $button =& new GtkButton('Show all Pages'); $button->show(); $box2->pack_start($button, false, true, 0); $button->connect_object('clicked', 'show_all_pages', &$sample_notebook); $box2 =& new GtkHBox(true, 10); $box2->show(); $box2->set_border_width(10); $box1->pack_start($box2, false, true, 0); $button =& new GtkButton('prev'); $button->show(); $button->connect_object('clicked', array(&$sample_notebook, 'prev_page')); $box2->pack_start($button, true, true, 0); $button =& new GtkButton('next'); $button->show(); $button->connect_object('clicked', array(&$sample_notebook, 'next_page')); $box2->pack_start($button, true, true, 0); $button =& new GtkButton('rotate'); $button->show(); $button->connect_object('clicked', 'notebook_rotate', &$sample_notebook); $box2->pack_start($button, true, true, 0); $separator =& new GtkHSeparator(); $separator->show(); $box1->pack_start($separator, false, true, 5); $button =& new GtkButton('close'); $button->show(); $button->set_border_width(5); $button->connect('clicked', 'close_window'); $box1->pack_start($button, false, false, 0); $button->set_flags(GTK_CAN_DEFAULT); $button->grab_default(); } if ($windows['notebook']->flags() & GTK_VISIBLE) { $windows['notebook']->hide(); } else { $windows['notebook']->show(); } }
<?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();
#!/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();
/* * Create a list widget and populate it with month names. */ $list = new GtkList(); $list->set_selection_mode(GTK_SELECTION_BROWSE); foreach (range(1, 12) as $month_num) { $items[] = new GtkListItem(strftime('%B', mktime(0, 0, 0, $month_num))); } $list->append_items($items); /* * Create a scrolled window and add the list widget to it - this provides * automatic scrollbars. */ $scrolled_window = new GtkScrolledWindow(); $scrolled_window->set_policy(GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); $scrolled_window->add_with_viewport($list); /* * Add scrolled window and button to the vertical layout box. */ $box->pack_start($scrolled_window); $box->pack_start($button, false); /* * Add layout box to the window, set window attributes and show everything. */ $window->add($box); $window->set_title('PHP Rules!'); $window->set_name('MainWindow'); $window->set_usize(150, 200); $window->show_all(); /* Run the main loop. */ Gtk::main();
/** * Define the window's title * @param $title Window's title */ public function setTitle($title) { parent::set_title($title); }
// tell the tooltip to only appear over that area $tooltip->set_tip_area($rect); $tooltip->set_text('Only mouseover on text shows me'); return true; // return false or nothing to NOT show a tooltip } function redboxtip($widget, $x, $y, $keyboard_mode, $tooltip) { $tipwindow = $widget->get_tooltip_window(); $tipwindow->modify_bg(Gtk::STATE_NORMAL, GdkColor::parse("#CC0000")); return true; // return false or nothing to NOT show a tooltip } /* Create base window */ $window = new GtkWindow(); $window->set_title('New Tooltip API'); $window->connect_simple('destroy', array('gtk', 'main_quit')); $window->add($vbox = new GtkVBox()); // simple tooltips usage $vbox->add($label = new GtkLabel('I have a plain tooltip')); $label->set_tooltip_text('I am a tooltip, Dave'); // simple tooltips usage with markup $vbox->add($label = new GtkLabel('I have a markup tooltip')); $label->set_tooltip_markup('<i>I am cool and italic</i>'); // text $vbox->add($text = new GtkLabel('Text Tooltip')); $text->set_has_tooltip(true); // $text->set_property('has-tooltip', true); - notice this does the same thing $text->connect('query-tooltip', 'texttip'); // markup $vbox->add($text = new GtkLabel('Markup Tooltip'));
//instead of destroying it (because when you destroy it, //Gtk::main_quit() gets called) and show the main window //$wnd->destroy(); } } function show_file_select(GtkWindow $wnd) { $ConfigFile = new ConfigFile('select config file'); $ConfigFile->show(); } /** * main application section */ //Create the login window $wnd = new GtkWindow(); $wnd->set_title('gource-php-gtk'); //Close the main loop when the window is destroyed $wnd->connect_simple('destroy', array('gtk', 'main_quit')); //Set up all the widgets we need //The second parameter says that the underscore should be parsed as underline //path $lblRepositoryPath = new GtkLabel('Repository Path', true); $txtRepositoryPath = new GtkEntry(); $settings = Settings::load(); $txtRepositoryPath->set_text($settings['last_repo_path']); //options //hide $chkOptionHideFiles = new GtkCheckButton('Hide Files', true); $chkOptionHideFilenames = new GtkCheckButton('Hide File Names', true); $chkOptionHideDirnames = new GtkCheckButton('Hide Directories', true); $chkOptionHideDates = new GtkCheckButton('Hide Dates', true);
<?php $window = new GtkWindow(); $window->set_title('Amit'); $window->set_size_request(470, 150); $window->connect_simple('destroy', array('Gtk', 'main_quit')); $window->add($vbox = new GtkVBox()); // define menu definition $toolbar_definition = array('New', 'open', 'Save', 'Save As', 'Print', 'Preview', '<hr>', 'Cut', 'Copy', 'Paste', '<hr>', 'Undo', 'Redo'); setup_toolbar($vbox, $toolbar_definition); // display title $title = new GtkLabel("Set up Toolbar"); $title->modify_font(new PangoFontDescription("Times New Roman Italic 10")); $title->modify_fg(Gtk::STATE_NORMAL, GdkColor::parse("#0000ff")); $vbox->pack_start($title); $vbox->pack_start(new GtkLabel('')); $window->show_all(); Gtk::main(); // setup toolbar function setup_toolbar($vbox, $toolbar_definition) { // note 1 $toolbar = new GtkToolBar(); // note 2 $vbox->pack_start($toolbar, 0, 0); foreach ($toolbar_definition as $item) { if ($item == '<hr>') { $toolbar->insert(new GtkSeparatorToolItem(), -1); } else { $stock_image_name = 'Gtk::STOCK_' . strtoupper($item); // note 3
<?php $window = new GtkWindow(); $window->set_size_request(400, 200); $window->set_title('launch browser'); $window->connect_simple('destroy', array('Gtk', 'main_quit')); $window->add($vbox = new GtkVBox()); // displays a title $title = new GtkLabel("Launch External Application in windows\n without the flashing of cmd window"); $title->modify_font(new PangoFontDescription("Times New Roman Italic 10")); $title->modify_fg(Gtk::STATE_NORMAL, GdkColor::parse("#0000ff")); $title->set_size_request(-1, 40); $vbox->pack_start($title, 0, 0); $vbox->pack_start(new GtkLabel('')); // create the clickable label $clickable_label = new GtkHBox(); $clickable_label->set_size_request(-1, 24); $vbox->pack_start($clickable_label, 0, 0); $clickable_label->pack_start(new GtkLabel("reference: php-gtk2 "), 0, 0); $clickable_label->pack_start(link("manual", "http://gtk.php.net/manual/en/gtkclasses.php"), 0, 0); $clickable_label->pack_start(new GtkLabel(" and "), 0, 0); $clickable_label->pack_start(link("mailing list", "http://www.nabble.com/Php---GTK---General-f171.html"), 0, 0); //$vbox->pack_start(new GtkLabel('')); $status = new GtkLabel(''); $status->set_alignment(0, 0); $vbox->pack_start($status, 0, 0); // function to setup the link function link($title, $url) { $label = new GtkLabel($title); $label->set_markup('<span color="blue"><u>' . $title . "</u></span>");
$chnapis->modify_fg(Gtk::STATE_NORMAL, GdkColor::parse("#800000")); $h3box->pack_start($chnapis3 = new GtkLabel("TB"), 1); $chnapis3->modify_font(new PangoFontDescription($font . " 25")); $chnapis3->modify_fg(Gtk::STATE_NORMAL, GdkColor::parse("#800000")); $v2box->pack_start($h2box = new GtkHBox(), 1, 1); $h2box->pack_start($G["displejchyby"] = new GtkLabel("0"), 1); $G["displejchyby"]->modify_font(new PangoFontDescription($font . " 85")); $G["displejchyby"]->modify_fg(Gtk::STATE_NORMAL, GdkColor::parse("#800000")); $h2box->pack_start($G["displejodm"] = new GtkLabel('0'), 1); $G["displejodm"]->modify_font(new PangoFontDescription($font . " 85")); $G["displejodm"]->modify_fg(Gtk::STATE_NORMAL, GdkColor::parse("#800000")); $h2box->pack_start($G["displejtb"] = new GtkLabel('0.00'), 1); $G["displejtb"]->modify_font(new PangoFontDescription($font . " 85")); $G["displejtb"]->modify_fg(Gtk::STATE_NORMAL, GdkColor::parse("#800000")); $window = new GtkWindow(); $window->set_title($argv[0]); $window->set_size_request(750, 550); $window->connect_simple('destroy', array('Gtk', 'main_quit')); $window->add($vbox = new GtkVBox()); $window->modify_bg(Gtk::STATE_NORMAL, GdkColor::parse("#ffffff")); $window->connect_after('key-press-event', 'onKeyPress'); function onKeyPress($widget, $event) { global $righthand, $lefthand; if (get_class($widget) == "GtkWindow") { echo "Pressed: " . $event->keyval; } return true; } $G["rezimdisplej"] = new GtkLabel('A->A'); $G["sensorstatus1"] = new GtkLabel('[ ]');
/** * 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(); }