gschem: Add comment
[geda-gaf.git] / xorn / tests / cpython / snippets / storage_funcs.py
blob0449923c0820b7ac13fc5d69a1a3027ce5c9d4f3
1 # Copyright (C) 2013-2018 Roland Lutz
3 # This program is free software; you can redistribute it and/or modify
4 # it under the terms of the GNU General Public License as published by
5 # the Free Software Foundation; either version 2 of the License, or
6 # (at your option) any later version.
8 # This program is distributed in the hope that it will be useful,
9 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 # GNU General Public License for more details.
13 # You should have received a copy of the GNU General Public License
14 # along with this program; if not, write to the Free Software Foundation,
15 # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17 import xorn.storage
19 ## [add object]
20 rev = xorn.storage.Revision()
22 data = xorn.storage.Line()
23 data.x = 0.
24 data.y = 0.
25 data.width = 100.
26 data.height = 100.
27 data.line.width = 1.
29 ob = rev.add_object(data)
30 ## [add object]
32 ## [get/set object data]
33 data = rev.get_object_data(ob)
34 data.color = 3
35 rev.set_object_data(ob, data)
36 ## [get/set object data]
38 ## [get objects]
39 for ob in rev.get_objects():
40 data = rev.get_object_data(ob)
41 # do something with ob and data
42 ## [get objects]
44 component_data = xorn.storage.Component()
45 component = rev.add_object(component_data)
47 ## [add attribute]
48 text_data = xorn.storage.Text()
49 text_data.text = "refdes=R1"
51 ob = rev.add_object(text_data)
52 rev.relocate_object(ob, component, None)
53 ## [add attribute]