Re: [PHP-GTK] New to GTK
[email protected] ("Steph")
| Newsgroups | php.gtk |
|---|---|
| Message-ID | <00c501c11b61$4dd273a0$364101d5@t2r1o8> |
darn sorry did it again (hit wrong button) could you please post yr code as an attachment to the list? something isn't being recognised somewhere .. ----- Original Message ----- From: "loll" <[email protected]> To: <[email protected]> Sent: Thursday, August 02, 2001 3:30 PM Subject: Re: [PHP-GTK] New to GTK Steph, Thansk for the help :) , I tried using the $window->remove($box); command which got rid of the window..(not sure if it got rid of the window the "proper" way or not but the window dissapeared with no errors.. So i then moved the main code into a function and now i get an error "call to member function on a non -object(line 32) I have globalized the variables but im still getting that error.. not sure what i have done Thanks for the help :) Loll ========================================================= below is the code im using <? $fcontents = @file ('preferences.inc'); $uph = explode(":",$fcontents[0]); $username = $uph[0]; $password = $uph[1]; $host = $uph[2]; $windows = array(); if (strtoupper(substr(PHP_OS, 0, 3)) == 'WIN') dl('php_gtk.dll'); else dl('php_gtk.so'); function shutdown(){ Gtk::main_quit(); } function write_preferences(){ global $username,$password,$host,$entry,$hbox,$window,$box; $user = $entry['username']->get_text(); $pass = $entry['password']->get_text(); $hst = $entry['host']->get_text(); $file = fopen("preferences.inc", "w"); fputs($file, "$user:$pass:$hst"); fclose($file); echo "debug:$window:$box:"; $window->remove($box); mainwindow(); } //end write_preference function function mainwindow() { global $window,$box,$vbox,$label,$hbox,$entry,$fields,$username,$password,$host,$button; $window = &new GtkWindow(); $window->set_title('GTK Test'); $window->connect('destroy','shutdown'); $window->set_border_width(10); $box = &new GtkVBox(); $window->add($box); $box->show(); if($username == "" || $password == "" || $host == ""){ $vbox = &new GtkVBox(); $box->pack_start($vbox,false,false); $vbox->show(); $vbox->set_border_width(3); $label = &new GtkLabel("Please enter in your MySQL connection information"); $label->set_usize(150,40); $vbox->pack_start($label,false); $label->show(); $fields = array( username => 'Username: ', password => 'Password: ', host => 'Host: '); while(list($f,$l) = each($fields)) { $vbox = &new GtkVBox(); $box->pack_start($vbox,false,false); $vbox->show(); $vbox->set_border_width(3); $hbox = &new GtkHBox(); $vbox->pack_start($hbox,false,false); $hbox->show(); $label = &new GtkLabel("$l"); $label->set_usize(150,10); $hbox->pack_start($label,false); $label->show(); $entry[$f] = &new GtkEntry(); $hbox->pack_start($entry[$f],false); $entry[$f]->show(); } $vbox = &new GtkVBox(); $box->pack_start($vbox,false,false); $vbox->show(); $vbox->set_border_width(3); $hbox = &new GtkHBox(); $vbox->pack_start($hbox,false,false); $hbox->show(); $button = &new GtkButton('Save Settings'); $button->connect('clicked',write_preferences); $hbox->pack_start($button); $button->show(); } else { $vbox = &new GtkVBox(); $box->pack_start($vbox,false,false); $vbox->show(); $vbox->set_border_width(3); $buttons = array( Query => 'update_clist', Quit => 'shutdown'); $hbox = &new GtkHBox(); $hbox->set_border_width(3); $vbox->pack_start($hbox,false,false); $hbox->show(); while(list($l,$f) = each($buttons)) { $button = &new GtkButton($l); $button->connect('clicked',$f); $hbox->pack_start($button); $button->show(); } } $window->show_all(); } // end of mainwindow function mainwindow(); Gtk::main(); ?> Steph wrote: >Loll, your smtp hates my smtp. Try $window->remove($firstvbox); & globalise $window in each function to add($newvbox) to, show_all() at the end of each function as well as just before main(). If it's not having any, you might need to hide() the main window and create a fresh one in every function. You can't display a vbox without a window. >hth >& please write via the list, it's easier! > >----- Original Message ----- >From: "loll" <[email protected]> >To: <[email protected]> >Sent: Wednesday, August 01, 2001 2:45 PM >Subject: [PHP-GTK] New to GTK > > >Hi, > >Im new to GTK and im using some of the example scripts to try and learn >how it all works > >Using the menu example script thats available.. Im trying to add text >boxes to the main box... > >here is a code snippet from the menu.php example: > >$window = &new GtkWindow(); >$window->connect('destroy', shutdown); >$window->set_position(GTK_WIN_POS_CENTER); >$window->set_usize(450,400); >$window->set_policy(FALSE,TRUE,FALSE); > >$box = &new GtkVBox(); >$window->add($box); >$box->show(); > >$vpane= &new GtkVPaned(); >$vpane->set_border_width(0); >$vpane->set_handle_size(0); > > >$box->add($vpane); > > >$vpane->show(); > >$accel = &new GtkAccelGroup(); >$window->add_accel_group($accel); > > >$label = &new GtkLabel(""); >$label->set_line_wrap(TRUE); > >$scrl_win = &new GtkScrolledWindow(); >$scrl_win->set_policy(GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); >$col1 = &new GdkColor(60000,60000,60000); >$col2 = &new GdkColor(0,0,0); >$style = $scrl_win->style; >$style->bg[GTK_STATE_NORMAL] = $col1; >$style->fg[GTK_STATE_NORMAL] = $col2; >$vpane->add2($scrl_win); >$scrl_win->show(); >$scrl_win->add_with_viewport($label); >$label->show(); > > >$window->show_all(); > >if i change it to be like this: > >$window = &new GtkWindow(); >$window->connect('destroy', shutdown); >$window->set_position(GTK_WIN_POS_CENTER); >$window->set_usize(450,400); >$window->set_policy(FALSE,TRUE,FALSE); > >$box = &new GtkVBox(); >$window->add($box); >$box->show(); > >$vpane= &new GtkVPaned(); >$vpane->set_border_width(0); >$vpane->set_handle_size(0); >//=================================== >$entry = &new GtkEntry(); >$box->add($entry); >$entry->show(); >//==================================== >$box->add($vpane); > >this adds a text box but it puts it centered under the main >box(expanding the window etc) ... How do i get the box to be inside the >main box ? > >Thansk for your help > >Loll > > > -- PHP GTK Mailing List (http://www.php.net/) To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected] To contact the list administrators, e-mail: [email protected]