PHP-GTK2 Cookbook Forum
Welcome, Guest
Please Login or Register.    Lost Password?
Re:get_widget in non-GLADE to access widgets by name? (1 viewing) (1) Guest
Go to bottom Post Reply Favoured: 0
TOPIC: Re:get_widget in non-GLADE to access widgets by name?
#904
SSantos (User)
Fresh Boarder
Posts: 2
graphgraph
User Offline Click here to see the profile of this user
get_widget in non-GLADE to access widgets by name? 1 Month, 2 Weeks ago Karma: 0  
Hi all,

is there a function returning the widget by name from a non-GLADE setup as done by GladeXML::get_widget()?

Reason is that I created a GtkVBox that will be filled later by dynamic software modules' GtkButtons (expense types in a car cost overview software, like refuel or washing): Window_Main::addModuleButtons in kfz.php (see below). The widget is currently being fetched from the GLADE-setup via get_widget(), but I am reprogramming that to dynamically create windows from the defined data structure, because
1. the PHP-GTK2 package obviously lacks GladeXML support
2. the software creates dialogs according to its internal setup itself.
So what I need is the respective function for non-GLADE.

Code:
...
$this->_window = new GtkWindow;
...
$this->gladeXML = new GladeXML(...
...
    function addModuleButton($name, $signalList)
    {
        if (!$name || !$signalList)
            return false;

        $button = new GtkButton($name, true);
        $button->set_visible(true);
        foreach($signalList as $signalName=>$signalAction)
            $button->connect_simple($signalName, $signalAction);

        if ($this->gladeXML) {
            $vboxModules = $this->gladeXML->get_widget('vboxModules');
            $vboxModules->set_visible(true);
            $vboxModules->pack_end($button);
        }

        if ($this->_window) {
            $vBoxModulesWin = $this->getWidget($this->_window, 'vboxModules');
#from here does not work:
            $vboxModulesWin->set_visible(true);
            $vboxModulesWin->pack_end($button);
        }
    }
I tried to program that myself, without success with recursive calls to dive into the widget tree, later foreach() and array_search() instead (yes: beccoming more and more desperate). To see the source code for the full conxtext see SVN version on http://sourceforge.net/projects/kfz/ . Thx Silverio
 
  The administrator has disabled public write access.
#905
kksou (Admin)
Admin
Posts: 391
graph
User Online Now Click here to see the profile of this user
Re:get_widget in non-GLADE to access widgets by name? 1 Month, 2 Weeks ago Karma: 8  
Hi,

I do not quite understand what do you mean by


1. the PHP-GTK2 package obviously lacks GladeXML support


Would you please elaborate a bit about this. We can use PHP-GTK2 with Glade. So exactly what kind of GladeXML support are you referring to?

Also, you said


2. the software creates dialogs according to its internal setup itself.


I don't quite understand about this too. What is the "internal setup" you're referring to?

By the way, there's nothing "magical" about glade. The glade tool helps you with the UI design, while the glade library helps you with the initial loading of the widgets and auto-connecting of the signals.

If you can try to describe in a simpler term what you've trying to achieve, maybe I could help with some sample codes. At least for now, I do not quite get what you have in mind.

Regards,
/kksou
 
 
Last Edit: 2008/10/02 00:38 By kksou.
  The administrator has disabled public write access.
#907
SSantos (User)
Fresh Boarder
Posts: 2
graphgraph
User Offline Click here to see the profile of this user
Re:get_widget in non-GLADE to access widgets by name? 1 Month, 2 Weeks ago Karma: 0  
kksou,

the main question is if there is a function like get_wigdet for non-Glade Gtk objects, like the widget tree below a GtkWindow.

1. My project is running fine on Linux, but I am also interested in having it running on Windows. As the project is in beta-phase this is less important for me ATM. For your questions I freshly downloaded php-gtk2 and also php (nts, to mix them) and copied dlls from one to the other and adapted php.ini to load them. Nevertheless php keeps telling me:
PHP Fatal error: Class "GladeXML" not found in ...
and php-gtk2 tells:
Fatal error: Call to undefined function bindtextdomain() in ...
While the first indicates a problem in Glade setup, the second message shows an issue with gettext.

2. Have a look at the source code from SVN on sourceforge: internal setup means there is a data model set up, that automatically sets up SQL-tables, transforms form data in SQL-compatible data (e.g. the array from GtkCalendar in iso-style yyyy-mm-dd) and is used to create a form on the fly. This method, of course, has advantages over Glade in terms of not needing to take care of changing Glade after updates in data structure.

As shown in the code example for 2. to allow access to widgets by their name for Glade there is a function get_widget() that returns the widget object. I miss this function for non-GLADE widget-trees to easily perform the same actions on non-GLADE, too.

Regards
SSantos
 
  The administrator has disabled public write access.
#910
kksou (Admin)
Admin
Posts: 391
graph
User Online Now Click here to see the profile of this user
Re:get_widget in non-GLADE to access widgets by name? 1 Month, 2 Weeks ago Karma: 8  
SSantos wrote:

1. ...I freshly downloaded php-gtk2 and also php (nts, to mix them) and copied dlls from one to the other and adapted php.ini to load them. Nevertheless php keeps telling me:
PHP Fatal error: Class "GladeXML" not found in ...
and php-gtk2 tells:
Fatal error: Call to undefined function bindtextdomain() in ...
While the first indicates a problem in Glade setup, the second message shows an issue with gettext.


Glade does work on windows.

Please take a look at the following post
http://www.kksou.com/php-gtk2/PHP-GTK2-Help/833-It-doesn-t-fit-together-GladeXML.php

Read through the entire post. You should be able to get Glade up and running on windows, and it should solve your question 1.

Let me know if you bump into any problem.

Regards,
/kksou
 
  The administrator has disabled public write access.
Go to top Post Reply
Powered by FireBoardget the latest posts directly to your desktop

Blog - Forum - Privacy Policy - Contact Us
Copyright © 2006-2008. kksou.com. All Rights Reserved