How to get access to widgets?

Asked by Alexander Telenga on 2009-02-10

Is there any manual or howto of this problem?
I've created glade file, parsed it with Gladex and got two .py files - main and callbacks. Now I need to write callbacks functions, but I can't understand how to get access to widgets.
For example I have 3 entry boxes, 1 combobox, 3 buttons in my glade file. I have in the callbacks file :

def on_SolveButton_clicked(widget, data, wtree):
   print "function 'on_on_SolveButton_clicked' not implemented"
   pass

In this function I want to get data from first two entries, math sign from combobox and calculate result. How can I do this?

Question information

Language:
English Edit question
Status:
Solved
For:
Gladex Edit question
Assignee:
No assignee Edit question
Solved by:
Francesco Marella
Solved:
2009-02-13
Last query:
2009-02-13
Last reply:
2009-02-13

hi Alexander,

you can get access to the whole tree by using the parameter "wtree" like below:

"
def on_SolveButton_clicked(widget, data, wtree):
   #print "function 'on_on_SolveButton_clicked' not implemented"
   entry1 = wtree.get_widget("id_entry1")
   entry2 = wtree.get_widget("id_entry2")
   ...
   pass
"
now that you have the widgets you can call the proper methods (es. entry1.get_text() ).
See http://www.pygtk.org/docs/pygtk/index.html for more details.

-fm

Alexander Telenga (telenga) said : #2

Thanks Francesco Marella, that solved my question.