|
Packit |
1470ea |
|
|
Packit |
1470ea |
<page xmlns="http://projectmallard.org/1.0/" xmlns:its="http://www.w3.org/2005/11/its" xmlns:e="http://projectmallard.org/experimental/" type="guide" style="task" id="properties.py" xml:lang="ca">
|
|
Packit |
1470ea |
|
|
Packit |
1470ea |
<info>
|
|
Packit |
1470ea |
<title type="text">Properties (Python)</title>
|
|
Packit |
1470ea |
<link type="guide" xref="beginner.py#theory"/>
|
|
Packit |
1470ea |
<link type="next" xref="grid.py"/>
|
|
Packit |
1470ea |
<revision version="0.1" date="2012-06-24" status="draft"/>
|
|
Packit |
1470ea |
|
|
Packit |
1470ea |
<desc>An explanation of properties, getters and setters.</desc>
|
|
Packit |
1470ea |
<credit type="author copyright">
|
|
Packit |
1470ea |
<name>Sebastian Pölsterl</name>
|
|
Packit |
1470ea |
<email its:translate="no">sebp@k-d-w.org</email>
|
|
Packit |
1470ea |
<years>2011</years>
|
|
Packit |
1470ea |
</credit>
|
|
Packit |
1470ea |
<credit type="editor">
|
|
Packit |
1470ea |
<name>Marta Maria Casetti</name>
|
|
Packit |
1470ea |
<email its:translate="no">mmcasetti@gmail.com</email>
|
|
Packit |
1470ea |
<years>2012</years>
|
|
Packit |
1470ea |
</credit>
|
|
Packit |
1470ea |
</info>
|
|
Packit |
1470ea |
|
|
Packit |
1470ea |
<title>Properties</title>
|
|
Packit |
1470ea |
|
|
Packit |
1470ea |
<links type="section"/>
|
|
Packit |
1470ea |
|
|
Packit |
1470ea |
<section id="overview">
|
|
Packit |
1470ea |
<title>Overview</title>
|
|
Packit |
1470ea |
|
|
Packit |
1470ea |
Properties describe the configuration and state of widgets. Each
|
|
Packit |
1470ea |
widget has its own particular set of properties. For example, a widget such as
|
|
Packit |
1470ea |
a button has the property label which contains the text of the
|
|
Packit |
1470ea |
widget. You can specify the name and value of any number of properties as
|
|
Packit |
1470ea |
keyword arguments when creating an instance of a widget. For example, to
|
|
Packit |
1470ea |
create a label with the text “Hello World”, an angle of 25 degrees, and
|
|
Packit |
1470ea |
aligned to the right, you can use:
|
|
Packit |
1470ea |
|
|
Packit |
1470ea |
label = Gtk.Label(label="Hello World", angle=25, halign=Gtk.Align.END)
|
|
Packit |
1470ea |
|
|
Packit |
1470ea |
Alternatively, you can define these properties separately by using the method associated with it.
|
|
Packit |
1470ea |
|
|
Packit |
1470ea |
label = Gtk.Label()
|
|
Packit |
1470ea |
label.set_label("Hello World")
|
|
Packit |
1470ea |
label.set_angle(25)
|
|
Packit |
1470ea |
label.set_halign(Gtk.Align.END)
|
|
Packit |
1470ea |
|
|
Packit |
1470ea |
Once you have created such a label, you can get the text of the label with label.get_label() , and analogously for the other properties.
|
|
Packit |
1470ea |
|
|
Packit |
1470ea |
Instead of using getters and setters you can also get and set the properties with get_property("prop-name") and set_property("prop-name", value) , respectively.
|
|
Packit |
1470ea |
|
|
Packit |
1470ea |
</section>
|
|
Packit |
1470ea |
<section id="references">
|
|
Packit |
1470ea |
<title>References</title>
|
|
Packit |
1470ea |
|
|
Packit |
1470ea |
<link href="http://python-gtk-3-tutorial.readthedocs.org/en/latest/basics.html">Basics - Properties</link> in Python GTK+ 3 Tutorial
|
|
Packit |
1470ea |
</section>
|
|
Packit |
1470ea |
|
|
Packit |
1470ea |
</page>
|