php-gtk glade mysql

From: Date: Thu, 24 Aug 2006 10:24:04 +0000
Subject: php-gtk glade mysql
Groups: php.gtk.general 
Request: Send a blank email to php-gtk-general+get-7101@lists.php.net to get a copy of this message
Hello all, I am a total newbie, having looked at php-gtk 6 months ago and gave up.. have decided to have another go at it now that php-gtk2.0a is out. My question is this, I would like to use glade as the user interfaces but i have having problems addressing the child widgets in the windows. I am pretty sure that is the last line that is wrong. $myClassInstance->loginButton('clicked','on_loginButton_clicked',$myClassInstance,$myClassInstance->loginEntry,$myClassInstance->passwordEnty); What i would like to do is load the glade file and when loginButton is clicked, pass the main window, the 2-3 textfields and comboBox to the login function. The login function will then check if the user can login into mysql. kind regards, suomaf My php file <?php //Here we use an object and connect all the // signals to *object methods* instead of // functions class MyClass { //This method is called when the button is clicked function on_cancelButton_clicked() { Gtk::main_quit(); } function on_loginButton_clicked(GtkWindow $wnd, GtkEntry $login, GtkEntry $password /*i would also like to be able to get combobox here too*/) { $loginName = $login->get_text(); $password = $password->get_text(); //error checking $errors = null; if (strlen($loginName) == 0) { $errors .= "Username is missing.\r\n"; } if (strlen($password) == 0) { $errors .= "No password given.\r\n"; } if ($errors !== null) { //There was at least one error. //We show a message box with the errors $dialog = new GtkMessageDialog($wnd, Gtk::DIALOG_MODAL, Gtk::MESSAGE_ERROR, Gtk::BUTTONS_OK, $errors); $dialog->set_markup( "The following errors occured:\r\n" . "<span foreground='red'>" . $errors . "</span>" ); $dialog->run(); $dialog->destroy(); } else { //No error. You would need to hide the dialog now //instead of destroying it (because when you destroy it, //Gtk::main_quit() gets called) and show the main window $wnd->destroy(); } $dbConnection = mysql_connect('localhost',$loginName,$password); $dbConnected = mysql_select_db("gms",$dbConnection); if(!$dbConnection) { echo "login unsuccessful\r\n"; } else { echo "login successful\r\n"; } } function staticMethod() { echo "MyClass::staticMethod()\r\n"; } } $glade = new GladeXML(dirname(__FILE__) . '/gmsdialog.glade'); //Let glade do all the signal connections we specified in the file // but this time, connect to the object methods $myClassInstance = new MyClass(); $glade->signal_autoconnect_instance($myClassInstance); $myClassInstance->loginButton('clicked','on_loginButton_clicked',$myClassInstance,$myClassInstance->loginEntry,$myClassInstance->passwordEnty); //Start the main loop Gtk::main() ?> My glade file === <?xml version="1.0" standalone="no"?> <!--*- mode: xml -*--> <!DOCTYPE glade-interface SYSTEM "http://glade.gnome.org/glade-2.0.dtd"> <glade-interface> <widget class="GtkWindow" id="gmsLoginForm"> <property name="visible">True</property> <property name="title" translatable="yes">gms::login</property> <property name="type">GTK_WINDOW_TOPLEVEL</property> <property name="window_position">GTK_WIN_POS_NONE</property> <property name="modal">False</property> <property name="default_width">100</property> <property name="default_height">150</property> <property name="resizable">True</property> <property name="destroy_with_parent">True</property> <property name="decorated">True</property> <property name="skip_taskbar_hint">False</property> <property name="skip_pager_hint">False</property> <property name="type_hint">GDK_WINDOW_TYPE_HINT_NORMAL</property> <property name="gravity">GDK_GRAVITY_NORTH_WEST</property> <property name="focus_on_map">True</property> <property name="urgency_hint">False</property> <signal name="destroy" handler="gtk::main_quit" last_modification_time="Thu, 24 Aug 2006 08:25:01 GMT"/> <child> <widget class="GtkVBox" id="vbox1"> <property name="border_width">10</property> <property name="visible">True</property> <property name="homogeneous">True</property> <property name="spacing">0</property> <child> <widget class="GtkTable" id="table1"> <property name="visible">True</property> <property name="n_rows">4</property> <property name="n_columns">2</property> <property name="homogeneous">True</property> <property name="row_spacing">5</property> <property name="column_spacing">10</property> <child> <widget class="GtkLabel" id="LoginLabel"> <property name="visible">True</property> <property name="label" translatable="yes">login</property> <property name="use_underline">False</property> <property name="use_markup">False</property> <property name="justify">GTK_JUSTIFY_RIGHT</property> <property name="wrap">False</property> <property name="selectable">False</property> <property name="xalign">0</property> <property name="yalign">0.5</property> <property name="xpad">0</property> <property name="ypad">0</property> <property name="ellipsize">PANGO_ELLIPSIZE_NONE</property> <property name="width_chars">-1</property> <property name="single_line_mode">False</property> <property name="angle">0</property> </widget> <packing> <property name="left_attach">0</property> <property name="right_attach">1</property> <property name="top_attach">0</property> <property name="bottom_attach">1</property> <property name="x_options">fill</property> <property name="y_options"></property> </packing> </child> <child> <widget class="GtkLabel" id="passwordLabel"> <property name="visible">True</property> <property name="label" translatable="yes">password</property> <property name="use_underline">False</property> <property name="use_markup">False</property> <property name="justify">GTK_JUSTIFY_RIGHT</property> <property name="wrap">False</property> <property name="selectable">False</property> <property name="xalign">0</property> <property name="yalign">0.5</property> <property name="xpad">0</property> <property name="ypad">0</property> <property name="ellipsize">PANGO_ELLIPSIZE_NONE</property> <property name="width_chars">-1</property> <property name="single_line_mode">False</property> <property name="angle">0</property> </widget> <packing> <property name="left_attach">0</property> <property name="right_attach">1</property> <property name="top_attach">1</property> <property name="bottom_attach">2</property> <property name="x_options">fill</property> <property name="y_options"></property> </packing> </child> <child> <widget class="GtkLabel" id="roleLabel"> <property name="visible">True</property> <property name="label" translatable="yes">role</property> <property name="use_underline">False</property> <property name="use_markup">False</property> <property name="justify">GTK_JUSTIFY_RIGHT</property> <property name="wrap">False</property> <property name="selectable">False</property> <property name="xalign">0</property> <property name="yalign">0.5</property> <property name="xpad">0</property> <property name="ypad">0</property> <property name="ellipsize">PANGO_ELLIPSIZE_NONE</property> <property name="width_chars">-1</property> <property name="single_line_mode">False</property> <property name="angle">0</property> </widget> <packing> <property name="left_attach">0</property> <property name="right_attach">1</property> <property name="top_attach">2</property> <property name="bottom_attach">3</property> <property name="x_options">fill</property> <property name="y_options"></property> </packing> </child> <child> <widget class="GtkButton" id="loginButton"> <property name="visible">True</property> <property name="can_focus">True</property> <property name="label" translatable="yes">_login</property> <property name="use_underline">True</property> <property name="relief">GTK_RELIEF_NORMAL</property> <property name="focus_on_click">True</property> <signal name="clicked" handler="on_loginButton_clicked" last_modification_time="Thu, 24 Aug 2006 08:18:46 GMT"/> </widget> <packing> <property name="left_attach">0</property> <property name="right_attach">1</property> <property name="top_attach">3</property> <property name="bottom_attach">4</property> <property name="x_options">fill</property> <property name="y_options"></property> </packing> </child> <child> <widget class="GtkButton" id="cancelButton"> <property name="visible">True</property> <property name="can_focus">True</property> <property name="label" translatable="yes">_cancel</property> <property name="use_underline">True</property> <property name="relief">GTK_RELIEF_NORMAL</property> <property name="focus_on_click">True</property> <signal name="clicked" handler="on_cancelButton_clicked" last_modification_time="Thu, 24 Aug 2006 08:18:38 GMT"/> </widget> <packing> <property name="left_attach">1</property> <property name="right_attach">2</property> <property name="top_attach">3</property> <property name="bottom_attach">4</property> <property name="x_options">fill</property> <property name="y_options"></property> </packing> </child> <child> <widget class="GtkEntry" id="loginEntry"> <property name="visible">True</property> <property name="can_focus">True</property> <property name="editable">True</property> <property name="visibility">True</property> <property name="max_length">0</property> <property name="text" translatable="yes"></property> <property name="has_frame">True</property> <property name="invisible_char">•</property> <property name="activates_default">False</property> </widget> <packing> <property name="left_attach">1</property> <property name="right_attach">2</property> <property name="top_attach">0</property> <property name="bottom_attach">1</property> <property name="y_options"></property> </packing> </child> <child> <widget class="GtkEntry" id="passwordEntry"> <property name="visible">True</property> <property name="can_focus">True</property> <property name="editable">True</property> <property name="visibility">False</property> <property name="max_length">0</property> <property name="text" translatable="yes"></property> <property name="has_frame">True</property> <property name="invisible_char">*</property> <property name="activates_default">False</property> </widget> <packing> <property name="left_attach">1</property> <property name="right_attach">2</property> <property name="top_attach">1</property> <property name="bottom_attach">2</property> <property name="y_options"></property> </packing> </child> <child> <widget class="GtkComboBoxEntry" id="RoleComboboxentry"> <property name="visible">True</property> <property name="items" translatable="yes">merchandiser supervisor</property> <property name="add_tearoffs">False</property> <property name="has_frame">True</property> <property name="focus_on_click">True</property> </widget> <packing> <property name="left_attach">1</property> <property name="right_attach">2</property> <property name="top_attach">2</property> <property name="bottom_attach">3</property> <property name="x_options">fill</property> <property name="y_options">fill</property> </packing> </child> </widget> <packing> <property name="padding">0</property> <property name="expand">True</property> <property name="fill">True</property> </packing> </child> </widget> </child> </widget> </glade-interface> ==== -- View this message in context: http://www.nabble.com/php-gtk-glade-mysql-tf2157838.html#a5961272 Sent from the Php - GTK - General forum at Nabble.com.

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