easycoder 250107.4__py2.py3-none-any.whl → 250109.1__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.4"
13
+ __version__ = "250109.1"
easycoder/ec_graphics.py CHANGED
@@ -1,8 +1,7 @@
1
- import sys, threading, json
2
1
  from .ec_classes import FatalError, RuntimeError, Object
3
2
  from .ec_handler import Handler
4
3
  from .ec_screenspec import ScreenSpec
5
- from .ec_renderer import Renderer
4
+ from .ec_renderer import Renderer, getUI
6
5
  from .ec_program import flush
7
6
 
8
7
  class Graphics(Handler):
@@ -32,7 +31,7 @@ class Graphics(Handler):
32
31
  targetRecord = self.getVariable(command['name'])
33
32
  keyword = targetRecord['keyword']
34
33
  id = self.getRuntimeValue(command['id'])
35
- uiElement = self.ui.getElement(id)
34
+ uiElement = getUI().getElement(id)
36
35
  if uiElement == None:
37
36
  FatalError(self.program.compiler, f'There is no screen element with id \'{id}\'')
38
37
  return -1
@@ -122,6 +121,7 @@ class Graphics(Handler):
122
121
  for item in ['width', 'height', 'left', 'bottom', 'r', 'g', 'b', 'text']:
123
122
  if command[item] == None:
124
123
  FatalError(self.program.compiler, f'Missing property \'{item}\'')
124
+ else: return False
125
125
  self.add(command)
126
126
  record['elementID'] = command['id']
127
127
  return False
@@ -199,7 +199,7 @@ class Graphics(Handler):
199
199
  self.windowSpec.fill = (self.getRuntimeValue(command['fill'][0])/255, self.getRuntimeValue(command['fill'][1])/255, self.getRuntimeValue(command['fill'][2])/255)
200
200
  self.windowCreated = True
201
201
  else:
202
- element = self.ui.createWidget(self.getWidgetSpec(command))
202
+ element = getUI().createWidget(self.getWidgetSpec(command))
203
203
  print(element)
204
204
  except Exception as e:
205
205
  RuntimeError(self.program, e)
@@ -224,10 +224,6 @@ class Graphics(Handler):
224
224
  def r_ellipse(self, command):
225
225
  return self.nextPC()
226
226
 
227
- def r_getui(self, command):
228
- self.ui = self.renderer.getUI()
229
- return self.nextPC()
230
-
231
227
  # Hide an element
232
228
  def k_hide(self, command):
233
229
  if self.nextIsSymbol():
@@ -240,7 +236,7 @@ class Graphics(Handler):
240
236
  return False
241
237
 
242
238
  def r_hide(self, command):
243
- self.ui.setVisible(self.getRuntimeValue(command['target']), False)
239
+ getUI().setVisible(self.getRuntimeValue(command['target']), False)
244
240
  return self.nextPC()
245
241
 
246
242
  def k_image(self, command):
@@ -272,12 +268,12 @@ class Graphics(Handler):
272
268
 
273
269
  def r_move(self, command):
274
270
  pos = (self.getRuntimeValue(command['x']), self.getRuntimeValue(command['y']))
275
- self.ui.moveElementTo(self.getRuntimeValue(command['target']), pos)
271
+ getUI().moveElementTo(self.getRuntimeValue(command['target']), pos)
276
272
  return self.nextPC()
277
273
 
278
274
  def r_moveBy(self, command):
279
275
  dist = (self.getRuntimeValue(command['dx']), self.getRuntimeValue(command['dy']))
280
- self.ui.moveElementBy(self.getRuntimeValue(command['target']), dist)
276
+ getUI().moveElementBy(self.getRuntimeValue(command['target']), dist)
281
277
  return self.nextPC()
282
278
 
283
279
  # on click/tap {element} {action}
@@ -288,7 +284,7 @@ class Graphics(Handler):
288
284
  if self.nextIsSymbol():
289
285
  target = self.getSymbolRecord()
290
286
  else:
291
- FatalError(self.program.compiler, f'{self.getToken()} is not a screen element')
287
+ Warning(f'{self.getToken()} is not a screen element')
292
288
  return False
293
289
  command['target'] = target['name']
294
290
  command['goto'] = self.getPC() + 2
@@ -329,7 +325,7 @@ class Graphics(Handler):
329
325
  data = Object()
330
326
  data.pc = pc
331
327
  data.index = index
332
- self.ui.setOnClick(id, data, oncb)
328
+ getUI().setOnClick(id, data, oncb)
333
329
  else:
334
330
  name = record['name']
335
331
  RuntimeError(self.program, f'{name} is not a clickable object')
@@ -341,25 +337,26 @@ class Graphics(Handler):
341
337
  def r_rectangle(self, command):
342
338
  return self.nextPC()
343
339
 
344
- # render {spec}
340
+ # render spec {spec}
345
341
  def k_render(self, command):
346
- command['spec'] = self.nextValue()
347
- command['parent'] = None
348
- if self.peek() == 'in':
349
- self.nextToken()
350
- if self.nextIsSymbol():
351
- command['parent'] = self.getSymbolRecord()['name']
352
- self.add(command)
353
- return True
342
+ if self.nextToken() in ['specification', 'spec']:
343
+ command['spec'] = self.nextValue()
344
+ command['parent'] = None
345
+ if self.peek() == 'in':
346
+ self.nextToken()
347
+ if self.nextIsSymbol():
348
+ command['parent'] = self.getSymbolRecord()['name']
349
+ self.add(command)
350
+ return True
351
+ return False
354
352
 
355
353
  def r_render(self, command):
356
354
  spec = self.getRuntimeValue(command['spec'])
357
355
  parent = command['parent']
358
356
  if parent !=None:
359
357
  parent = self.getVariable(command['parent'])
360
- self.ui = self.renderer.getUI()
361
358
  try:
362
- ScreenSpec().render(spec, parent, self.ui)
359
+ ScreenSpec().render(spec, parent)
363
360
  except Exception as e:
364
361
  RuntimeError(self.program, e)
365
362
  return self.nextPC()
@@ -374,7 +371,6 @@ class Graphics(Handler):
374
371
  def r_run(self, command):
375
372
  self.renderer = Renderer()
376
373
  self.renderer.init(self.windowSpec)
377
- self.ui = self.renderer.getUI()
378
374
  self.program.setExternalControl()
379
375
  self.program.run(self.nextPC())
380
376
  self.renderer.run()
@@ -405,7 +401,7 @@ class Graphics(Handler):
405
401
  target = self.getVariable(command['target'])
406
402
  id = target['value'][target['index']]['content']
407
403
  value = self.getRuntimeValue(command['value'])
408
- self.ui.setAttribute(id, attribute, value)
404
+ getUI().setAttribute(id, attribute, value)
409
405
  return self.nextPC()
410
406
 
411
407
  # Show an element (restore it to its current position)
@@ -420,7 +416,7 @@ class Graphics(Handler):
420
416
  return False
421
417
 
422
418
  def r_show(self, command):
423
- self.ui.setVisible(self.getRuntimeValue(command['target']), True)
419
+ getUI().setVisible(self.getRuntimeValue(command['target']), True)
424
420
  return self.nextPC()
425
421
 
426
422
  def k_text(self, command):
@@ -483,7 +479,7 @@ class Graphics(Handler):
483
479
  attribute = self.getRuntimeValue(v['attribute'])
484
480
  target = self.getVariable(v['target'])
485
481
  val = self.getSymbolValue(target)
486
- v = self.ui.getAttribute(val['content'], attribute)
482
+ v = getUI().getAttribute(val['content'], attribute)
487
483
  value = {}
488
484
  value['type'] = 'int'
489
485
  value['content'] = int(round(v))
@@ -505,7 +501,7 @@ class Graphics(Handler):
505
501
  attribute = v['attribute']
506
502
  value = {}
507
503
  value['type'] = 'int'
508
- value['content'] = int(round(self.ui.getWindowAttribute(attribute)))
504
+ value['content'] = int(round(getUI().getWindowAttribute(attribute)))
509
505
  return value
510
506
  except Exception as e:
511
507
  RuntimeError(self.program, e)
easycoder/ec_program.py CHANGED
@@ -18,7 +18,6 @@ class Program:
18
18
 
19
19
  def __init__(self, argv):
20
20
  global queue
21
- print(f'EasyCoder version {version("easycoder")}')
22
21
  if len(argv) == 0:
23
22
  print('No script supplied')
24
23
  exit()
@@ -387,6 +386,7 @@ class Program:
387
386
 
388
387
  # This is the program launcher
389
388
  def Main():
389
+ print(f'EasyCoder version {version("easycoder")}')
390
390
  if (len(sys.argv) > 1):
391
391
  Program(sys.argv[1]).start()
392
392
  else:
easycoder/ec_renderer.py CHANGED
@@ -1,23 +1,31 @@
1
1
  from kivy.app import App
2
2
  from kivy.uix.widget import Widget
3
+ from kivy.graphics import Color, Ellipse, Rectangle
3
4
  from kivy.uix.label import CoreLabel
4
5
  from kivy.uix.image import AsyncImage
5
6
  from kivy.core.window import Window
6
- from kivy.graphics import Color, Ellipse, Rectangle
7
7
  from kivy.utils import colormap
8
8
  from kivy.clock import Clock
9
9
  from kivy.vector import Vector
10
- import math
10
+ import math, os
11
+
12
+ os.environ['KIVY_TEXT'] = 'pango'
11
13
 
12
- # Get a real position or size value
13
- # These are {n}w/h, where w/h are percentages
14
+ ec_ui = None
15
+
16
+ def getUI():
17
+ global ec_ui
18
+ return ec_ui
19
+
20
+ # Get an actual screeen position or size value from a specified value
21
+ # such as {n}w/h, where w/h are percentages
14
22
  # e.g. 25w or 50h
15
- def getReal(spec, val):
23
+ def getActual(val, spec=None):
16
24
  if isinstance(val, str):
17
25
  c = val[-1]
18
26
  if c in ['w', 'h']:
19
27
  val = int(val[0:len(val)-1])
20
- if spec.parent == None:
28
+ if spec == None or spec.parent == None:
21
29
  if c == 'w':
22
30
  n = Window.width
23
31
  else:
@@ -40,8 +48,8 @@ class Element():
40
48
 
41
49
  def getRelativePosition(self):
42
50
  spec = self.spec
43
- x = getReal(spec, spec.pos[0])
44
- y = getReal(spec, spec.pos[1])
51
+ x = getActual(spec.pos[0], spec)
52
+ y = getActual(spec.pos[1], spec)
45
53
  return Vector(x, y)
46
54
 
47
55
  def getType(self):
@@ -108,10 +116,19 @@ class UI(Widget):
108
116
  Color(c[0], c[1], c[2])
109
117
  else:
110
118
  Color(c[0]/255, c[1]/255, c[2]/255)
111
- pos = (getReal(spec, spec.pos[0]), getReal(spec, spec.pos[1]))
112
- spec.realpos = pos
113
- size = (getReal(spec, spec.size[0]), getReal(spec, spec.size[1]))
119
+ size = (getActual(spec.size[0], spec), getActual(spec.size[1], spec))
114
120
  spec.realsize = size
121
+ # Deal with special case of 'center'
122
+ if spec.pos[0] == 'center':
123
+ left = getActual('50w', spec) - spec.realsize[0]/2
124
+ else:
125
+ left = getActual(spec.pos[0], spec)
126
+ if spec.pos[1] == 'center':
127
+ bottom = getActual('50h', spec) - spec.realsize[1]/2
128
+ else:
129
+ bottom = getActual(spec.pos[1], spec)
130
+ pos = (left, bottom)
131
+ spec.realpos = pos
115
132
  if spec.parent != None:
116
133
  pos = Vector(pos) + spec.parent.realpos
117
134
  if spec.type == 'ellipse':
@@ -128,10 +145,12 @@ class UI(Widget):
128
145
  Color(c[0]/255, c[1]/255, c[2]/255)
129
146
  else:
130
147
  Color(1, 1, 1, 1)
131
- label = CoreLabel(text=spec.text, font_size=1000, halign='center', valign='center')
148
+ if self.font == None:
149
+ label = CoreLabel(text=spec.text, font_size=1000, halign='center', valign='center')
150
+ else:
151
+ label = CoreLabel(text=spec.text, font_context = None, font_name=self.font, font_size=1000, halign='center', valign='center')
132
152
  label.refresh()
133
- text = label.texture
134
- item = Rectangle(pos=pos, size=size, texture=text)
153
+ item = Rectangle(pos=pos, size=size, texture=label.texture)
135
154
  elif spec.type == 'image':
136
155
  item = AsyncImage(pos=pos, size=size, source=spec.source)
137
156
  spec.item = item
@@ -231,9 +250,6 @@ class UI(Widget):
231
250
 
232
251
  class Renderer(App):
233
252
 
234
- def getUI(self):
235
- return self.ui
236
-
237
253
  def request_close(self):
238
254
  print('close window')
239
255
  self.kill()
@@ -247,7 +263,9 @@ class Renderer(App):
247
263
  return self.ui
248
264
 
249
265
  def init(self, spec):
250
- self.ui = UI()
266
+ global ec_ui
267
+ ec_ui = UI()
268
+ self.ui = ec_ui
251
269
  self.title = spec.title
252
270
  self.flush = spec.flush
253
271
  self.kill = spec.kill
@@ -1,21 +1,28 @@
1
1
  # screenspec.py
2
2
 
3
3
  from json import loads
4
- from .ec_renderer import Object
4
+ from .ec_renderer import Object, getUI
5
+
6
+ global_id = 0
5
7
 
6
8
  class ScreenSpec():
7
9
 
10
+ id = 0
11
+
8
12
  # Get an attribute of an element
9
13
  def getAttribute(self, id, attribute):
10
- element = self.ui.getElement(id)
14
+ element = getUI().getElement(id)
11
15
  return element[attribute]
12
16
 
13
17
  # Render a single widget
14
18
  def createWidget(self, widget, parent):
19
+ global global_id
15
20
  spec = Object()
16
21
  type = widget['type']
17
22
  spec.type = type
18
- spec.id = widget['id']
23
+ global_id += 1
24
+ if 'id' in widget: spec.id = widget['id']
25
+ else: spec.id = f'_{global_id}'
19
26
  spec.pos = (widget['left'], widget['bottom'])
20
27
  spec.size = (widget['width'], widget['height'])
21
28
  if widget.get('fill') != None:
@@ -30,7 +37,7 @@ class ScreenSpec():
30
37
  spec.color = widget['color']
31
38
  spec.parent = parent
32
39
  spec.children = []
33
- self.ui.createElement(spec)
40
+ getUI().createElement(spec)
34
41
 
35
42
  if '#' in widget:
36
43
  children = widget['#']
@@ -51,6 +58,8 @@ class ScreenSpec():
51
58
 
52
59
  # Render a complete specification
53
60
  def renderSpec(self, spec, parent):
61
+ if 'font' in spec: getUI().font = spec['font']
62
+ else: getUI().font = None
54
63
  widgets = spec['#']
55
64
  # If a list, iterate it
56
65
  if isinstance(widgets, list):
@@ -61,8 +70,7 @@ class ScreenSpec():
61
70
  self.createWidget(spec[widgets], parent)
62
71
 
63
72
  # Render a graphic specification
64
- def render(self, spec, parent, ui):
65
- self.ui = ui
73
+ def render(self, spec, parent):
66
74
 
67
75
  # If it'a string, process it
68
76
  if isinstance(spec, str):
@@ -71,4 +79,3 @@ class ScreenSpec():
71
79
  # If it's a 'dict', extract the spec and the args
72
80
  else:
73
81
  self.renderSpec(spec, parent)
74
-
easycoder/ec_value.py CHANGED
@@ -1,5 +1,12 @@
1
1
  from .ec_classes import FatalError
2
2
 
3
+ # Create a constant
4
+ def getConstant(str):
5
+ value = {}
6
+ value['type'] = 'text'
7
+ value['content'] = str
8
+ return value
9
+
3
10
  class Value:
4
11
 
5
12
  def __init__(self, compiler):
@@ -15,7 +22,7 @@ class Value:
15
22
  return None
16
23
 
17
24
  value = {}
18
-
25
+
19
26
  if token == 'true':
20
27
  value['type'] = 'boolean'
21
28
  value['content'] = True
@@ -80,7 +87,7 @@ class Value:
80
87
  value = domain.modifyValue(value)
81
88
 
82
89
  return value
83
-
90
+
84
91
  def compileConstant(self, token):
85
92
  value = {}
86
93
  if type(token) == 'str':
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: easycoder
3
- Version: 250107.4
3
+ Version: 250109.1
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>
@@ -0,0 +1,19 @@
1
+ easycoder/README.md,sha256=PYqOc_SkIGiFbyCNs90y7JqoqWe4aO1xYIW-6bOnFKU,573
2
+ easycoder/__init__.py,sha256=wQ2Kn9KbWzsub8jAuII1644-ArCW8QmMuopYeT1FKfo,283
3
+ easycoder/ec.py,sha256=Nj5PRl8GsKjfGJKq0FOM1a7FeK3cN68CoIFg8lswQEg,221
4
+ easycoder/ec_classes.py,sha256=xnWBNak8oKydkFoxHLlq9wo3lIsB3aMnTDrqbtCfoWo,1512
5
+ easycoder/ec_compiler.py,sha256=f3zZRtbNsegBuRHTvTLK8BOdnuRq5p_p-1vtJYb-LiY,4800
6
+ easycoder/ec_condition.py,sha256=WSbONo4zs2sX1icOVpscZDFSCAEFmTsquoc2RGcLx_k,763
7
+ easycoder/ec_core.py,sha256=71rSNOwMrO0Ik1hdgTshOYRo2XVD0Br7gUZfCR7A0OA,86291
8
+ easycoder/ec_graphics.py,sha256=FesA34EeSTS7TH_84E5jCSJXnbc0ce9COf1VeXNWYi0,18639
9
+ easycoder/ec_handler.py,sha256=IJvxcrJJSR53d6DS_8H5qPHKhp9y5-GV4WXAjhZxu_o,2250
10
+ easycoder/ec_program.py,sha256=u51FxCnarubxwoAfREnqGMHf2YL7zaWnH9Gs8XUWmJ4,9843
11
+ easycoder/ec_renderer.py,sha256=yqLfXjCed1oFyFH0uzN6ffu1hot59vYx7yr1Sv7E_Uo,9225
12
+ easycoder/ec_screenspec.py,sha256=nhWuUJ4Jvew0iKmcfkTY-7EIvAWIwXWwrqub6aW4N3c,2609
13
+ easycoder/ec_timestamp.py,sha256=_3QFJPzIWZ9Rzk3SQOQJ-gwmvB07pg78k23SPntoZtY,288
14
+ easycoder/ec_value.py,sha256=zgDJTJhIg3yOvmnnKIfccIizmIhGbtvL_ghLTL1T5fg,2516
15
+ easycoder-250109.1.dist-info/entry_points.txt,sha256=JXAZbenl0TnsIft2FcGJbJ-4qoztVu2FuT8PFmWFexM,44
16
+ easycoder-250109.1.dist-info/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
17
+ easycoder-250109.1.dist-info/WHEEL,sha256=Sgu64hAMa6g5FdzHxXv9Xdse9yxpGGMeagVtPMWpJQY,99
18
+ easycoder-250109.1.dist-info/METADATA,sha256=GYAtYztAU8hjM9c6e4_iu7Qb4mfZDlRwlsCkYCQGC5w,5817
19
+ easycoder-250109.1.dist-info/RECORD,,
@@ -1,19 +0,0 @@
1
- easycoder/README.md,sha256=PYqOc_SkIGiFbyCNs90y7JqoqWe4aO1xYIW-6bOnFKU,573
2
- easycoder/__init__.py,sha256=J-25pqc30KkHPO5UzX5ZTBS1d4NijjSZMeFcPC1An3c,283
3
- easycoder/ec.py,sha256=Nj5PRl8GsKjfGJKq0FOM1a7FeK3cN68CoIFg8lswQEg,221
4
- easycoder/ec_classes.py,sha256=xnWBNak8oKydkFoxHLlq9wo3lIsB3aMnTDrqbtCfoWo,1512
5
- easycoder/ec_compiler.py,sha256=f3zZRtbNsegBuRHTvTLK8BOdnuRq5p_p-1vtJYb-LiY,4800
6
- easycoder/ec_condition.py,sha256=WSbONo4zs2sX1icOVpscZDFSCAEFmTsquoc2RGcLx_k,763
7
- easycoder/ec_core.py,sha256=71rSNOwMrO0Ik1hdgTshOYRo2XVD0Br7gUZfCR7A0OA,86291
8
- easycoder/ec_graphics.py,sha256=oSOYp76eXwwlGi3D8pyPJT2JecT8qvzeOewKAuZNqfY,18730
9
- easycoder/ec_handler.py,sha256=IJvxcrJJSR53d6DS_8H5qPHKhp9y5-GV4WXAjhZxu_o,2250
10
- easycoder/ec_program.py,sha256=xNhFM6hoRaXx3Nl9Scn9f_qQL5-57WnvNXfwKdHl0rc,9844
11
- easycoder/ec_renderer.py,sha256=ac643-wRsePClMI_l8bjZIgjbNZbR7WQa6zOo5mLwLM,8516
12
- easycoder/ec_screenspec.py,sha256=qNqhbP16gAi2cRUD3W0dpb8tTC4-N4mE2l6HtOG0vbc,2405
13
- easycoder/ec_timestamp.py,sha256=_3QFJPzIWZ9Rzk3SQOQJ-gwmvB07pg78k23SPntoZtY,288
14
- easycoder/ec_value.py,sha256=7yJovn24pPC3jrURSQyEvZ8m826fXiqxsCpSvxwNrfQ,2403
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,,