Blame platform-demos/fr/properties.py.page

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="fr">
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>Une explication des propriétés, des mécanismes d'obtention et de définition.</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
Packit 1470ea
    <mal:credit xmlns:mal="http://projectmallard.org/1.0/" type="translator copyright">
Packit 1470ea
      <mal:name>Luc Rebert,</mal:name>
Packit 1470ea
      <mal:email>traduc@rebert.name</mal:email>
Packit 1470ea
      <mal:years>2011</mal:years>
Packit 1470ea
    </mal:credit>
Packit 1470ea
  
Packit 1470ea
    <mal:credit xmlns:mal="http://projectmallard.org/1.0/" type="translator copyright">
Packit 1470ea
      <mal:name>Alain Lojewski,</mal:name>
Packit 1470ea
      <mal:email>allomervan@gmail.com</mal:email>
Packit 1470ea
      <mal:years>2011-2012</mal:years>
Packit 1470ea
    </mal:credit>
Packit 1470ea
  
Packit 1470ea
    <mal:credit xmlns:mal="http://projectmallard.org/1.0/" type="translator copyright">
Packit 1470ea
      <mal:name>Luc Pionchon</mal:name>
Packit 1470ea
      <mal:email>pionchon.luc@gmail.com</mal:email>
Packit 1470ea
      <mal:years>2011</mal:years>
Packit 1470ea
    </mal:credit>
Packit 1470ea
  
Packit 1470ea
    <mal:credit xmlns:mal="http://projectmallard.org/1.0/" type="translator copyright">
Packit 1470ea
      <mal:name>Bruno Brouard</mal:name>
Packit 1470ea
      <mal:email>annoa.b@gmail.com</mal:email>
Packit 1470ea
      <mal:years>2011-12</mal:years>
Packit 1470ea
    </mal:credit>
Packit 1470ea
  
Packit 1470ea
    <mal:credit xmlns:mal="http://projectmallard.org/1.0/" type="translator copyright">
Packit 1470ea
      <mal:name>Luis Menina</mal:name>
Packit 1470ea
      <mal:email>liberforce@freeside.fr</mal:email>
Packit 1470ea
      <mal:years>2014</mal:years>
Packit 1470ea
    </mal:credit>
Packit 1470ea
  </info>
Packit 1470ea
Packit 1470ea
<title>Propriétés</title>
Packit 1470ea
Packit 1470ea
<links type="section"/>
Packit 1470ea
Packit 1470ea
<section id="overview">
Packit 1470ea
<title>Présentation</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>Références</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>