easycoder 250106.14__py2.py3-none-any.whl → 250107.2__py2.py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of easycoder might be problematic. Click here for more details.

easycoder/__init__.py CHANGED
@@ -10,4 +10,4 @@ from .ec_program import *
10
10
  from .ec_timestamp import *
11
11
  from .ec_value import *
12
12
 
13
- __version__ = "250106.14"
13
+ __version__ = "250107.2"
easycoder/ec_graphics.py CHANGED
@@ -32,12 +32,12 @@ class Graphics(Handler):
32
32
  targetRecord = self.getVariable(command['name'])
33
33
  keyword = targetRecord['keyword']
34
34
  id = self.getRuntimeValue(command['id'])
35
- element = self.ui.getElement(id)
36
- if element == None:
35
+ uiElement = self.ui.getElement(id)
36
+ if uiElement == None:
37
37
  FatalError(self.program.compiler, f'There is no screen element with id \'{id}\'')
38
38
  return -1
39
- if element.getType() != keyword:
40
- etype = element['type']
39
+ if uiElement.getType() != keyword:
40
+ etype = uiElement['type']
41
41
  FatalError(self.program.compiler, f'Mismatched element type: "{etype}" and "{keyword}"')
42
42
  self.putSymbolValue(targetRecord, {'type': 'text', 'content': id})
43
43
  return self.nextPC()
@@ -265,6 +265,7 @@ class Graphics(Handler):
265
265
  self.ui.moveElementBy(self.getRuntimeValue(command['target']), dist)
266
266
  return self.nextPC()
267
267
 
268
+ # on click/tap {element} {action}
268
269
  def k_on(self, command):
269
270
  token = self.nextToken()
270
271
  if token in ['click', 'tap']:
@@ -298,14 +299,22 @@ class Graphics(Handler):
298
299
  return True
299
300
  return False
300
301
 
302
+ # Set a handler on every element
301
303
  def r_on(self, command):
302
304
  pc = command['goto']
303
305
  if command['type'] == 'tap':
304
306
  record = self.getVariable(command['target'])
307
+ def oncb(data):
308
+ record['index'] = data.index
309
+ self.run(data.pc)
305
310
  keyword = record['keyword']
306
311
  if self.isGraphicType(keyword):
307
- id = record['value'][record['index']]['content']
308
- self.ui.setOnClick(id, lambda: self.run(pc))
312
+ for index in range(0, record['elements']):
313
+ id = record['value'][index]['content']
314
+ data = Object()
315
+ data.pc = pc
316
+ data.index = index
317
+ self.ui.setOnClick(id, data, oncb)
309
318
  else:
310
319
  name = record['name']
311
320
  RuntimeError(self.program, f'{name} is not a clickable object')
easycoder/ec_renderer.py CHANGED
@@ -9,14 +9,39 @@ from kivy.clock import Clock
9
9
  from kivy.vector import Vector
10
10
  import math
11
11
 
12
- class Object():
13
- pass
12
+ # Get a real position or size value
13
+ # These are {n}w/h, where w/h are percentages
14
+ # e.g. 25w or 50h
15
+ def getReal(spec, val):
16
+ if isinstance(val, str):
17
+ c = val[-1]
18
+ if c in ['w', 'h']:
19
+ val = int(val[0:len(val)-1])
20
+ if spec.parent == None:
21
+ if c == 'w':
22
+ n = Window.width
23
+ else:
24
+ n = Window.height
25
+ else:
26
+ if c == 'w':
27
+ n = spec.parent.realsize[0]
28
+ else:
29
+ n = spec.parent.realsize[1]
30
+ return val * n / 100
31
+ return val
14
32
 
15
33
  class Element():
16
34
 
17
35
  def __init__(self, type, spec):
18
36
  self.type = type
19
37
  self.spec = spec
38
+ self.actionCB = None
39
+
40
+ def getRelativePosition(self):
41
+ spec = self.spec
42
+ x = getReal(spec, spec.pos[0])
43
+ y = getReal(spec, spec.pos[1])
44
+ return Vector(x, y)
20
45
 
21
46
  def getType(self):
22
47
  return self.spec.type
@@ -24,37 +49,25 @@ class Element():
24
49
  def getID(self):
25
50
  return self.spec.id
26
51
 
27
- def getRealPos(self):
28
- spec = self.spec
29
- pos = spec.realpos
30
- if spec.parent != None:
31
- pos = Vector(pos) + spec.parent.realpos
32
- return pos
33
-
34
52
  def getPos(self):
35
53
  spec = self.spec
36
- pos = spec.pos
54
+ pos = spec.realpos
37
55
  if spec.parent != None:
38
- pos = Vector(pos) + spec.parent.pos
56
+ pos = self.getRelativePosition() + spec.parent.realpos
39
57
  return pos
40
58
 
41
59
  def setPos(self, pos):
60
+ # Update the spec
42
61
  self.spec.realpos = pos
62
+ # Update the displayed item
43
63
  self.spec.item.pos = pos
44
64
 
45
- # Called when the parent moves
46
- def repos(self):
47
- spec = self.spec
48
- spec.item.pos = Vector(spec.realpos) + spec.parent.realpos
49
-
50
- def getRealSize(self):
51
- return self.spec.realsize
52
-
53
65
  def getSize(self):
54
- return self.spec.size
66
+ return self.spec.realsize
55
67
 
56
68
  def setSize(self, size):
57
- self.spec.size = size
69
+ self.spec.realsize = size
70
+ self.spec.item.size = size
58
71
 
59
72
  def getChildren(self):
60
73
  return self.spec.children
@@ -78,25 +91,6 @@ class UI(Widget):
78
91
  self.zlist.append(element)
79
92
 
80
93
  def createElement(self, spec):
81
- # Get a real position or size value
82
- def getReal(val):
83
- if isinstance(val, str):
84
- c = val[-1]
85
- if c in ['w', 'h']:
86
- val = int(val[0:len(val)-1])
87
- if spec.parent == None:
88
- if c == 'w':
89
- n = Window.width
90
- else:
91
- n = Window.height
92
- else:
93
- if c == 'w':
94
- n = spec.parent.realsize[0]
95
- else:
96
- n = spec.parent.realsize[1]
97
- return val * n / 100
98
- return val
99
-
100
94
  with self.canvas:
101
95
  if hasattr(spec, 'fill'):
102
96
  c = spec.fill
@@ -105,9 +99,9 @@ class UI(Widget):
105
99
  Color(c[0], c[1], c[2])
106
100
  else:
107
101
  Color(c[0]/255, c[1]/255, c[2]/255)
108
- pos = (getReal(spec.pos[0]), getReal(spec.pos[1]))
102
+ pos = (getReal(spec, spec.pos[0]), getReal(spec, spec.pos[1]))
109
103
  spec.realpos = pos
110
- size = (getReal(spec.size[0]), getReal(spec.size[1]))
104
+ size = (getReal(spec, spec.size[0]), getReal(spec, spec.size[1]))
111
105
  spec.realsize = size
112
106
  if spec.parent != None:
113
107
  pos = Vector(pos) + spec.parent.realpos
@@ -137,15 +131,15 @@ class UI(Widget):
137
131
  def moveElementBy(self, id, dist):
138
132
  element = self.getElement(id)
139
133
  if element != None:
140
- element.setPos(Vector(element.getRealPos()) + dist)
134
+ element.setPos(Vector(element.getPos()) + dist)
141
135
  for id in element.getChildren():
142
- self.getElement(id).repos()
136
+ self.moveElementBy(id, dist)
143
137
  return
144
138
 
145
139
  def moveElementTo(self, id, pos):
146
140
  element = self.getElement(id)
147
141
  if element != None:
148
- self.moveElementBy(id, Vector(pos) - element.getRealPos())
142
+ self.moveElementBy(id, Vector(pos) - element.getPos())
149
143
  return
150
144
 
151
145
  def on_touch_down(self, touch):
@@ -153,12 +147,10 @@ class UI(Widget):
153
147
  x = tp[0]
154
148
  y = tp[1]
155
149
  for element in reversed(self.zlist):
156
- if element.cb != None:
150
+ if element.actionCB != None:
157
151
  spec = element.spec
158
152
  pos = spec.realpos
159
- if spec.parent != None:
160
- pos = Vector(pos) + spec.parent.realpos
161
- size = spec.size
153
+ size = element.getSize()
162
154
  if spec.type == 'ellipse':
163
155
  a = int(size[0])/2
164
156
  b = int(size[1])/2
@@ -166,15 +158,17 @@ class UI(Widget):
166
158
  h = ctr[0]
167
159
  k = ctr[1]
168
160
  if (math.pow((x - h), 2) / math.pow(a, 2)) + (math.pow((y - k), 2) / math.pow(b, 2)) <= 1:
169
- element.cb()
161
+ element.actionCB(element.data)
170
162
  break
171
163
  elif spec.type in ['rectangle', 'text', 'image']:
172
164
  if tp[0] >= pos[0] and tp[0] < pos[0] + size[0] and tp[1] >= pos[1] and tp[1] < pos[1] + size[1]:
173
- element.cb()
165
+ element.actionCB(element.data)
174
166
  break
175
167
 
176
- def setOnClick(self, id, callback):
177
- self.getElement(id).cb = callback
168
+ def setOnClick(self, id, data, callback):
169
+ element = self.getElement(id)
170
+ element.data = data
171
+ element.actionCB = callback
178
172
 
179
173
  def getWindowAttribute(self, attribute):
180
174
  if attribute == 'left':
@@ -250,3 +244,6 @@ class Renderer(App):
250
244
  Window.size = spec.size
251
245
  Window.left = spec.pos[0]
252
246
  Window.top = spec.pos[1]
247
+
248
+ class Object():
249
+ pass
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: easycoder
3
- Version: 250106.14
3
+ Version: 250107.2
4
4
  Summary: Rapid scripting in English
5
5
  Keywords: compiler,scripting,prototyping,programming,coding,python,low code,hypertalk,computer language,learn to code
6
6
  Author-email: Graham Trott <gtanyware@gmail.com>
@@ -1,19 +1,19 @@
1
1
  easycoder/README.md,sha256=PYqOc_SkIGiFbyCNs90y7JqoqWe4aO1xYIW-6bOnFKU,573
2
- easycoder/__init__.py,sha256=Bqk4iGvp4QC9Uw0PkvYjNr2_f5MJntTIk3Yi2Lb9vtc,284
2
+ easycoder/__init__.py,sha256=o6OZz0QSM7ohvjnlTSkXAzegCE7zs0mLOY6aHiiXb0I,283
3
3
  easycoder/ec.py,sha256=Nj5PRl8GsKjfGJKq0FOM1a7FeK3cN68CoIFg8lswQEg,221
4
4
  easycoder/ec_classes.py,sha256=xnWBNak8oKydkFoxHLlq9wo3lIsB3aMnTDrqbtCfoWo,1512
5
5
  easycoder/ec_compiler.py,sha256=f3zZRtbNsegBuRHTvTLK8BOdnuRq5p_p-1vtJYb-LiY,4800
6
6
  easycoder/ec_condition.py,sha256=WSbONo4zs2sX1icOVpscZDFSCAEFmTsquoc2RGcLx_k,763
7
7
  easycoder/ec_core.py,sha256=71rSNOwMrO0Ik1hdgTshOYRo2XVD0Br7gUZfCR7A0OA,86291
8
- easycoder/ec_graphics.py,sha256=E0WhVZ6p-vvl3Zj42P6qTGyua60sTZ6JXU8MLZKrcQs,17396
8
+ easycoder/ec_graphics.py,sha256=yHNzpPBBXc7vLm3lIlWX5o8Fy0mVOCCUHiTSvqcAjlk,17742
9
9
  easycoder/ec_handler.py,sha256=IJvxcrJJSR53d6DS_8H5qPHKhp9y5-GV4WXAjhZxu_o,2250
10
10
  easycoder/ec_program.py,sha256=xNhFM6hoRaXx3Nl9Scn9f_qQL5-57WnvNXfwKdHl0rc,9844
11
- easycoder/ec_renderer.py,sha256=eCd4DoHEYbn3wR5Zj6yBIIf5gH4IgGsXTeCr_LfdQfA,8121
11
+ easycoder/ec_renderer.py,sha256=UFMEXTWWWTMNys_KHDdweSA9wO7m15mpWr3Peisnzdk,8011
12
12
  easycoder/ec_screenspec.py,sha256=qNqhbP16gAi2cRUD3W0dpb8tTC4-N4mE2l6HtOG0vbc,2405
13
13
  easycoder/ec_timestamp.py,sha256=_3QFJPzIWZ9Rzk3SQOQJ-gwmvB07pg78k23SPntoZtY,288
14
14
  easycoder/ec_value.py,sha256=7yJovn24pPC3jrURSQyEvZ8m826fXiqxsCpSvxwNrfQ,2403
15
- easycoder-250106.14.dist-info/entry_points.txt,sha256=JXAZbenl0TnsIft2FcGJbJ-4qoztVu2FuT8PFmWFexM,44
16
- easycoder-250106.14.dist-info/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
17
- easycoder-250106.14.dist-info/WHEEL,sha256=Sgu64hAMa6g5FdzHxXv9Xdse9yxpGGMeagVtPMWpJQY,99
18
- easycoder-250106.14.dist-info/METADATA,sha256=DlUpSLcVjPyOJHDcHcIItPA0fR5XNiOX3P8PgBNQDKs,5818
19
- easycoder-250106.14.dist-info/RECORD,,
15
+ easycoder-250107.2.dist-info/entry_points.txt,sha256=JXAZbenl0TnsIft2FcGJbJ-4qoztVu2FuT8PFmWFexM,44
16
+ easycoder-250107.2.dist-info/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
17
+ easycoder-250107.2.dist-info/WHEEL,sha256=Sgu64hAMa6g5FdzHxXv9Xdse9yxpGGMeagVtPMWpJQY,99
18
+ easycoder-250107.2.dist-info/METADATA,sha256=UfdQPhoG9RLOhlJLWZHqRJ9Qvdb6mGtUqJFY9pZ4UVM,5817
19
+ easycoder-250107.2.dist-info/RECORD,,