Re: My first program with PHP-GTK2

From: Date: Mon, 11 Jul 2005 18:09:34 +0000
Subject: Re: My first program with PHP-GTK2
References: 1 2  Groups: php.gtk.general 
Request: Send a blank email to php-gtk-general+get-5972@lists.php.net to get a copy of this message
Hi the source it's in my laptop :-( and the program is not finalized yet, but i put here the code: <?php function set_units($unit, $xml, $v = null) { switch(strtolower($unit)) { case 'temperature': return 'º' . $xml->units->temp; break; case 'visibility': return $xml->units->dist; break; case 'pressure': if($v != 'N/A') { return $xml->units->pres; break; } else { return ''; } case 'precip': return $xml->units->prec; break; } } $weather = simplexml_load_file('http://forecastfox.accuweather.com/adcbin/forecastfox/weather_data.asp?location=EUR;ES;-;ZARAUTZ&metric=1'); //var_dump($weather) $weatherCC = array(); $weatherCC['Temperature'] = $weather->currentconditions->temperature; $weatherCC['Humidity'] = $weather->currentconditions->humidity; $weatherCC['Visibility'] = $weather->currentconditions->visibility; $weatherCC['Wind speed'] = $weather->currentconditions->windspeed; $weatherCC['Pressure'] = $weather->currentconditions->pressure; $weatherCC['Precip'] = $weather->currentconditions->precip; $weatherCC['UV Index'] = $weather->currentconditions->uvindex; $window = new GtkWindow; $window->set_title('PHP-GTK Weather'); $window->connect_object('destroy', array('gtk', 'main_quit')); $window->set_default_size(225, 50); $a = new GtkAccelGroup; $window->add_accel_group($a); $box = new GtkHBox(false, 0); $table = new GtkTable(7, 2); $table->set_homogeneous(false); $i = 1; foreach($weatherCC as $key => $value) { $keyLabel = new GtkLabel($key); $keyLabel->set_justify(Gtk::JUSTIFY_LEFT); $keyLabel->set_alignment(0.0, 0.5); $valueLabel = new GtkLabel((string) $value . ' ' . set_units($key, $weather, (string) $value)); $valueLabel->set_alignment(1.0, 0.5); $table->attach($keyLabel, 0, 1, ($i - 1), $i); $table->attach($valueLabel, 1, 2, ($i - 1), $i); $i++; } $icon = new GtkImage; $icon->set_alignment(0.5, 0.1); $icon->set_from_file('images/'. $weather->currentconditions->weathericon .'.png'); $box->pack_start($table, false, false, 0); $box->pack_end($icon, false, false, 10); $menuBar = new GtkMenuBar; $file = new GtkMenuItem('File'); $file->get_child()->parse_uline('_File'); $file_menu = new GtkMenu; $separator = new GtkSeparatorMenuItem; $quit = GtkImageMenuItem::new_from_stock(Gtk::STOCK_QUIT, $a); $quit->get_child()->parse_uline('_Quit'); $quit->connect_object('activate', array('gtk', 'main_quit')); $file_menu->append($separator); $file_menu->append($quit); $file->set_submenu($file_menu); $menuBar->append($file); $statusBar = new GtkStatusBar; $text = new GtkLabel(); $text->set_markup('Now in Zarautz: <b>' . (string) $weather->currentconditions->weathertext . '</b>'); $text->set_alignment(0.5, 0.0); $windowBox = new GtkVBox(false, 0); $windowBox->pack_start($menuBar, false, false); $windowBox->pack_start($text, false, false); $windowBox->pack_start($box, true, true); $windowBox->pack_end($statusBar, false, false); $window->add($windowBox); $window->show_all(); gtk::main(); ?> On 7/11/05, Joseph Crawford <codebowl@gmail.com> wrote: > where can i download to see the source? > > -- > Joseph Crawford Jr. > Codebowl Solutions, Inc. > 1-802-671-2021 > codebowl@gmail.com > >

« previous php.gtk.general (#5972) next »