summaryrefslogtreecommitdiffstats
path: root/kivio/kiviopart/stencils/Flowcharting/BasicFlowcharting/PyStencil.spy
blob: aa11f970255b9ec0aba8688aa0286d2d05e04001 (plain)
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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
<?xml version="1.0"?>
<KivioPyStencil creator="vi">
    <KivioPyStencilSpawnerInfo>
        <Author data="Dmitry Poplavsky"/>
        <Title data="Python"/>
        <Id data="Python"/>
        <Description data="Basic flowcharting card tqshape"/>
        <Version data="0.1"/>
        <Web data="www.thekompany.com"/>
        <Email data="[email protected]"/>
        <AutoUpdate data="off"/>
    </KivioPyStencilSpawnerInfo>

<init code="Python">
<![CDATA[

# defined variables : x, y, w, h, x2=x+w, y2=y+h

x=70
y=40
w=100
h=100

x2=x+w
y2=y+w

style = {
          "color" : "blue",
          "bgcolor" : "white",
          "linewidth" : 1,
        }

connections = []

connector_targets = [ { "x":x+2,  "y":y-2 },
                      { "x":x+2,  "y":y2-2 },
                      { "x":x2-2, "y":y+2 },
                      { "x":x2-2, "y":y2-2 },
                      { "x": x+w/2, "y":y }
                    ]


tqshapes = {
          "rect" :{
                   "type"  : "Rectangle",
                   "fillstyle" : "solid",
                   "x" : x+2,
                   "y" : y+2,
                   "w" : w-4,
                   "h" : w-4
                   },
          "rect2" :{
                   "type"  : "Rectangle",
                   "color" : [250,40,40],
                   "bgcolor" : "darkgreen",
                   "selected" : { "bgcolor" : "blue", "fillstyle":"solid" },
                   "fillstyle" : "solid",
                   "x" : x+w-35,
                   "y" : y+h-35,
                   "w" : 20,
                   "h" : 20
                   },
          "rect3" :{
                   "type"  : "Ellipse",
                   "color" : [250,40,40],
                   "selected" : { "color":[40,200,40] },
                   "x" : x+15,
                   "y" : y+15,
                   "w" : 20,
                   "h" : 20,
                   "rx": 15,
                   "ry": 15
                   },
          "text"  : {
                   "type" : "TextBox",
                   "x"    : x+5,
                   "y"    : y+5,
                   "w"    : w-10,
                   "h"    : h-10,
                   "text" : "2"
                   }
       }

]]>
</init>

<resize>
<![CDATA[

# as default all coords are scalled, and this code will be runned
# defined variables : x, y, w, h, x2=x+w, y2=y+h  and all variables , defined in <init>
connector_targets = [ { "x":x+2,  "y":y-2 },
                            { "x":x+2,  "y":y2-2 },
                            { "x":x2-2, "y":y+2 },
                            { "x":x2-2, "y":y2-2 },
                            { "x":(x+x2)/2, "y":y }
                          ]

tqshapes["rect2"]["x"] = x+w-35
tqshapes["rect2"]["y"] = y+h-35
tqshapes["rect2"]["w"] = 20
tqshapes["rect2"]["h"] = 20

if ( tqshapes["text"]["text"] == "1" ):
    stencil = curLayer().firstStencil()
    stencil.setText( "x:"+str(x)+"  y:"+str(y) )

]]>
</resize>

</KivioPyStencil>