File: properties.py.page

package info (click to toggle)
gnome-devel-docs 40.3-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 79,188 kB
  • sloc: javascript: 2,514; xml: 2,407; ansic: 2,229; python: 1,854; makefile: 805; sh: 499; cpp: 131
file content (70 lines) | stat: -rw-r--r-- 2,846 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
<?xml version="1.0" encoding="utf-8"?>
<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="sv">

<info>
  <title type="text">Egenskaper (Python)</title>
  <link type="guide" xref="beginner.py#theory"/>
  <link type="next" xref="grid.py"/>
  <revision version="0.1" date="2012-06-24" status="draft"/>

  <desc>An explanation of properties, getters and setters.</desc>
  <credit type="author copyright">
    <name>Sebastian Pölsterl</name>
    <email its:translate="no">sebp@k-d-w.org</email>
    <years>2011</years>
  </credit>
  <credit type="editor">
    <name>Marta Maria Casetti</name>
    <email its:translate="no">mmcasetti@gmail.com</email>
    <years>2012</years>
  </credit>

    <mal:credit xmlns:mal="http://projectmallard.org/1.0/" type="translator copyright">
      <mal:name>Sebastian Rasmussen</mal:name>
      <mal:email>sebras@gmail.com</mal:email>
      <mal:years>2019</mal:years>
    </mal:credit>
  
    <mal:credit xmlns:mal="http://projectmallard.org/1.0/" type="translator copyright">
      <mal:name>Anders Jonsson</mal:name>
      <mal:email>anders.jonsson@norsjovallen.se</mal:email>
      <mal:years>2021</mal:years>
    </mal:credit>
  </info>

<title>Egenskaper</title>

<links type="section"/>

<section id="overview">
<title>Översikt</title>

<p><em>Properties</em> describe the configuration and state of widgets. Each
widget has its own particular set of properties. For example, a widget such as
a button has the property <code>label</code> which contains the text of the
widget. You can specify the name and value of any number of properties as
keyword arguments when creating an instance of a widget. For example, to
create a label with the text “Hello World”, an angle of 25 degrees, and
aligned to the right, you can use:</p>
<code>
label = Gtk.Label(label="Hej världen", angle=25, halign=Gtk.Align.END)</code>

<p>Alternativt kan du definiera dessa egenskaper separat genom att använda metoden som är associerad med det.</p>
<code>
label = Gtk.Label()
label.set_label("Hej världen")
label.set_angle(25)
label.set_halign(Gtk.Align.END)</code>

<p>Då du skapat en sådan etikett kan du få texten för etiketten med <code>label.get_label()</code>, och på motsvarande sätt för de andra egenskaperna.</p>

<p>Instead of using getters and setters you can also get and set the properties with <code>get_property(<var>"prop-name"</var>)</code> and <code>set_property(<var>"prop-name"</var>, <var>value</var>)</code>, respectively.</p>

</section>
<section id="references">
<title>Referenser</title>

<p><link href="http://python-gtk-3-tutorial.readthedocs.org/en/latest/basics.html">Basics - Properties</link> in Python GTK+ 3 Tutorial</p>
</section>

</page>