easycoder 250107.1__py2.py3-none-any.whl → 250107.4__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__ = "250107.1"
13
+ __version__ = "250107.4"
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()
@@ -228,6 +228,21 @@ class Graphics(Handler):
228
228
  self.ui = self.renderer.getUI()
229
229
  return self.nextPC()
230
230
 
231
+ # Hide an element
232
+ def k_hide(self, command):
233
+ if self.nextIsSymbol():
234
+ record = self.getSymbolRecord()
235
+ type = record['keyword']
236
+ if self.isGraphicType(type):
237
+ command['target'] = record['id']
238
+ self.add(command)
239
+ return True
240
+ return False
241
+
242
+ def r_hide(self, command):
243
+ self.ui.setVisible(self.getRuntimeValue(command['target']), False)
244
+ return self.nextPC()
245
+
231
246
  def k_image(self, command):
232
247
  return self.compileVariable(command)
233
248
 
@@ -265,6 +280,7 @@ class Graphics(Handler):
265
280
  self.ui.moveElementBy(self.getRuntimeValue(command['target']), dist)
266
281
  return self.nextPC()
267
282
 
283
+ # on click/tap {element} {action}
268
284
  def k_on(self, command):
269
285
  token = self.nextToken()
270
286
  if token in ['click', 'tap']:
@@ -298,14 +314,22 @@ class Graphics(Handler):
298
314
  return True
299
315
  return False
300
316
 
317
+ # Set a handler on every element
301
318
  def r_on(self, command):
302
319
  pc = command['goto']
303
320
  if command['type'] == 'tap':
304
321
  record = self.getVariable(command['target'])
322
+ def oncb(data):
323
+ record['index'] = data.index
324
+ self.run(data.pc)
305
325
  keyword = record['keyword']
306
326
  if self.isGraphicType(keyword):
307
- id = record['value'][record['index']]['content']
308
- self.ui.setOnClick(id, lambda: self.run(pc))
327
+ for index in range(0, record['elements']):
328
+ id = record['value'][index]['content']
329
+ data = Object()
330
+ data.pc = pc
331
+ data.index = index
332
+ self.ui.setOnClick(id, data, oncb)
309
333
  else:
310
334
  name = record['name']
311
335
  RuntimeError(self.program, f'{name} is not a clickable object')
@@ -384,6 +408,21 @@ class Graphics(Handler):
384
408
  self.ui.setAttribute(id, attribute, value)
385
409
  return self.nextPC()
386
410
 
411
+ # Show an element (restore it to its current position)
412
+ def k_show(self, command):
413
+ if self.nextIsSymbol():
414
+ record = self.getSymbolRecord()
415
+ type = record['keyword']
416
+ if self.isGraphicType(type):
417
+ command['target'] = record['id']
418
+ self.add(command)
419
+ return True
420
+ return False
421
+
422
+ def r_show(self, command):
423
+ self.ui.setVisible(self.getRuntimeValue(command['target']), True)
424
+ return self.nextPC()
425
+
387
426
  def k_text(self, command):
388
427
  return self.compileVariable(command)
389
428
 
easycoder/ec_renderer.py CHANGED
@@ -35,6 +35,8 @@ class Element():
35
35
  def __init__(self, type, spec):
36
36
  self.type = type
37
37
  self.spec = spec
38
+ self.visible= True
39
+ self.actionCB = None
38
40
 
39
41
  def getRelativePosition(self):
40
42
  spec = self.spec
@@ -56,10 +58,11 @@ class Element():
56
58
  return pos
57
59
 
58
60
  def setPos(self, pos):
59
- # Update the spec
60
- self.spec.realpos = pos
61
- # Update the displayed item
62
- self.spec.item.pos = pos
61
+ if self.visible:
62
+ # Update the spec
63
+ self.spec.realpos = pos
64
+ # Update the displayed item
65
+ self.spec.item.pos = pos
63
66
 
64
67
  def getSize(self):
65
68
  return self.spec.realsize
@@ -68,6 +71,13 @@ class Element():
68
71
  self.spec.realsize = size
69
72
  self.spec.item.size = size
70
73
 
74
+ def setVisible(self, vis):
75
+ self.visible = vis
76
+ if vis:
77
+ self.setPos(self.spec.realpos)
78
+ else:
79
+ self.spec.item.pos = (Window.width, self.getPos()[1])
80
+
71
81
  def getChildren(self):
72
82
  return self.spec.children
73
83
 
@@ -141,16 +151,22 @@ class UI(Widget):
141
151
  self.moveElementBy(id, Vector(pos) - element.getPos())
142
152
  return
143
153
 
154
+ def setVisible(self, id, vis):
155
+ element = self.getElement(id)
156
+ if element != None:
157
+ element.setVisible(vis)
158
+ for id in element.getChildren():
159
+ self.setVisible(id, vis)
160
+ return
161
+
144
162
  def on_touch_down(self, touch):
145
163
  tp = touch.pos
146
164
  x = tp[0]
147
165
  y = tp[1]
148
166
  for element in reversed(self.zlist):
149
- if element.cb != None:
167
+ if element.actionCB != None:
150
168
  spec = element.spec
151
169
  pos = spec.realpos
152
- # if spec.parent != None:
153
- # pos = Vector(pos) + spec.parent.spec.getPos()
154
170
  size = element.getSize()
155
171
  if spec.type == 'ellipse':
156
172
  a = int(size[0])/2
@@ -159,15 +175,17 @@ class UI(Widget):
159
175
  h = ctr[0]
160
176
  k = ctr[1]
161
177
  if (math.pow((x - h), 2) / math.pow(a, 2)) + (math.pow((y - k), 2) / math.pow(b, 2)) <= 1:
162
- element.cb()
178
+ element.actionCB(element.data)
163
179
  break
164
180
  elif spec.type in ['rectangle', 'text', 'image']:
165
181
  if tp[0] >= pos[0] and tp[0] < pos[0] + size[0] and tp[1] >= pos[1] and tp[1] < pos[1] + size[1]:
166
- element.cb()
182
+ element.actionCB(element.data)
167
183
  break
168
184
 
169
- def setOnClick(self, id, callback):
170
- self.getElement(id).cb = callback
185
+ def setOnClick(self, id, data, callback):
186
+ element = self.getElement(id)
187
+ element.data = data
188
+ element.actionCB = callback
171
189
 
172
190
  def getWindowAttribute(self, attribute):
173
191
  if attribute == 'left':
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: easycoder
3
- Version: 250107.1
3
+ Version: 250107.4
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=mWjtIxciExi22rtbw36o2c6d91Coh7jHg-SxJ3kRinY,283
2
+ easycoder/__init__.py,sha256=J-25pqc30KkHPO5UzX5ZTBS1d4NijjSZMeFcPC1An3c,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=oSOYp76eXwwlGi3D8pyPJT2JecT8qvzeOewKAuZNqfY,18730
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=epGuH9n11-Vae3Ftganb5kU9JX46xz3iwKvRlPhuCGo,7984
11
+ easycoder/ec_renderer.py,sha256=ac643-wRsePClMI_l8bjZIgjbNZbR7WQa6zOo5mLwLM,8516
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-250107.1.dist-info/entry_points.txt,sha256=JXAZbenl0TnsIft2FcGJbJ-4qoztVu2FuT8PFmWFexM,44
16
- easycoder-250107.1.dist-info/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
17
- easycoder-250107.1.dist-info/WHEEL,sha256=Sgu64hAMa6g5FdzHxXv9Xdse9yxpGGMeagVtPMWpJQY,99
18
- easycoder-250107.1.dist-info/METADATA,sha256=zzd8y3mHMcL-68xV7nM_3stuPfVDJ9xgiEt-g2VxxRc,5817
19
- easycoder-250107.1.dist-info/RECORD,,
15
+ easycoder-250107.4.dist-info/entry_points.txt,sha256=JXAZbenl0TnsIft2FcGJbJ-4qoztVu2FuT8PFmWFexM,44
16
+ easycoder-250107.4.dist-info/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
17
+ easycoder-250107.4.dist-info/WHEEL,sha256=Sgu64hAMa6g5FdzHxXv9Xdse9yxpGGMeagVtPMWpJQY,99
18
+ easycoder-250107.4.dist-info/METADATA,sha256=fSAK0zcnj-XNADlQ9_hgkgI--stSuWmzlB_SIJK6x7U,5817
19
+ easycoder-250107.4.dist-info/RECORD,,