On Jul 6, 2006, at 8:42 PM, Christopher Spears wrote:
In the PyGTK tutorial, I came across this function:
def enter_callback(self, widget, entry):
entry_text = entry.get_text()
print "Entry contents: %s\n" % entry_text
This function prints text that was entered into an
entry. I'm confused by the parameters. Isn't the
entry also the widget? The webpage I am referring to
is:
http://www.pygtk.org/pygtk2tutorial/sec-TextEntries.html
Yes, in that case it is - you can test it by changing the code to:
def enter_callback(self, widget, entry):
print 'widget is entry', widget is entry
entry_text = entry.get_text()
print "Entry contents: %s\n" % entry_text
this prints: widget is entry true
You'll notice some of the other callbacks have the extra parameter
which is the entry such as:
def entry_toggle_editable(self, checkbutton, entry):
entry.set_editable(checkbutton.get_active())
This is setup by the statement:
check.connect("toggled", self.entry_toggle_editable, entry)
The parameter after self is the widget the event occurred in (in this
case the check widget, in the other case the entry). The extra
parameter passed to the connect function is also passed to the
callback when it is called.
HTH,
Dave
_______________________________________________
pygtk mailing list [email protected]
http://www.daa.com.au/mailman/listinfo/pygtk
Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/