[pygtk] General PyGtk design question
Rafael Villar Burke
pachi at rvburke.com
Wed Jun 25 18:18:14 WST 2008
Walter Leibbrandt wrote:
> Good day,
>
> I would just like to ask a question about the design of PyGtk: What
> were the reasons for the C-like deisgn of PyGtk? For example having to
> use "label.set_text('bleh')" in stead of "label.text = 'bleh'" and
> "txt = label.get_text()" in stead of "txt = label.text".
You can do that for object properties, such as "label" for a gtk.Label.
They can be accessed through the props attribute like this:
print my_object.props.label
my_object.props.label = "this is <b>my</b> label"
In your example, gtk.Label's "text" is not a widget property, but
"label" is, so you'd still need to use the get_text method to get the
label text without any markup in it, but you could better use "label" to
set it as it brings you the capability of using pango markup in it, and
it also works fine to get the marked up text contents of the gtk.Label.
For some time now, some gtk widgets have grown new properties that were
implicit by those set/get pairs but weren't reflected as visible
properties, so things are still improving...
Regards,
Rafael Villar Burke
More information about the pygtk
mailing list