easycoder 250107.4__py2.py3-none-any.whl → 250109.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__ = "250107.4"
13
+ __version__ = "250109.2"
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
@@ -182,7 +182,6 @@ class Graphics(Handler):
182
182
  command['source'] = source
183
183
 
184
184
  def r_create(self, command):
185
-
186
185
  try:
187
186
  type = command['type']
188
187
  if type == 'window':
@@ -198,8 +197,13 @@ class Graphics(Handler):
198
197
  self.windowSpec.size = (self.getRuntimeValue(command['size'][0]), self.getRuntimeValue(command['size'][1]))
199
198
  self.windowSpec.fill = (self.getRuntimeValue(command['fill'][0])/255, self.getRuntimeValue(command['fill'][1])/255, self.getRuntimeValue(command['fill'][2])/255)
200
199
  self.windowCreated = True
200
+ self.renderer = Renderer()
201
+ self.renderer.init(self.windowSpec)
202
+ self.program.setExternalControl()
203
+ self.program.run(self.nextPC())
204
+ self.renderer.run()
201
205
  else:
202
- element = self.ui.createWidget(self.getWidgetSpec(command))
206
+ element = getUI().createWidget(self.getWidgetSpec(command))
203
207
  print(element)
204
208
  except Exception as e:
205
209
  RuntimeError(self.program, e)
@@ -224,10 +228,6 @@ class Graphics(Handler):
224
228
  def r_ellipse(self, command):
225
229
  return self.nextPC()
226
230
 
227
- def r_getui(self, command):
228
- self.ui = self.renderer.getUI()
229
- return self.nextPC()
230
-
231
231
  # Hide an element
232
232
  def k_hide(self, command):
233
233
  if self.nextIsSymbol():
@@ -240,7 +240,7 @@ class Graphics(Handler):
240
240
  return False
241
241
 
242
242
  def r_hide(self, command):
243
- self.ui.setVisible(self.getRuntimeValue(command['target']), False)
243
+ getUI().setVisible(self.getRuntimeValue(command['target']), False)
244
244
  return self.nextPC()
245
245
 
246
246
  def k_image(self, command):
@@ -272,12 +272,12 @@ class Graphics(Handler):
272
272
 
273
273
  def r_move(self, command):
274
274
  pos = (self.getRuntimeValue(command['x']), self.getRuntimeValue(command['y']))
275
- self.ui.moveElementTo(self.getRuntimeValue(command['target']), pos)
275
+ getUI().moveElementTo(self.getRuntimeValue(command['target']), pos)
276
276
  return self.nextPC()
277
277
 
278
278
  def r_moveBy(self, command):
279
279
  dist = (self.getRuntimeValue(command['dx']), self.getRuntimeValue(command['dy']))
280
- self.ui.moveElementBy(self.getRuntimeValue(command['target']), dist)
280
+ getUI().moveElementBy(self.getRuntimeValue(command['target']), dist)
281
281
  return self.nextPC()
282
282
 
283
283
  # on click/tap {element} {action}
@@ -288,7 +288,7 @@ class Graphics(Handler):
288
288
  if self.nextIsSymbol():
289
289
  target = self.getSymbolRecord()
290
290
  else:
291
- FatalError(self.program.compiler, f'{self.getToken()} is not a screen element')
291
+ Warning(f'{self.getToken()} is not a screen element')
292
292
  return False
293
293
  command['target'] = target['name']
294
294
  command['goto'] = self.getPC() + 2
@@ -329,7 +329,7 @@ class Graphics(Handler):
329
329
  data = Object()
330
330
  data.pc = pc
331
331
  data.index = index
332
- self.ui.setOnClick(id, data, oncb)
332
+ getUI().setOnClick(id, data, oncb)
333
333
  else:
334
334
  name = record['name']
335
335
  RuntimeError(self.program, f'{name} is not a clickable object')
@@ -341,44 +341,30 @@ class Graphics(Handler):
341
341
  def r_rectangle(self, command):
342
342
  return self.nextPC()
343
343
 
344
- # render {spec}
344
+ # render spec {spec}
345
345
  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
346
+ if self.nextToken() in ['specification', 'spec']:
347
+ command['spec'] = self.nextValue()
348
+ command['parent'] = None
349
+ if self.peek() == 'in':
350
+ self.nextToken()
351
+ if self.nextIsSymbol():
352
+ command['parent'] = self.getSymbolRecord()['name']
353
+ self.add(command)
354
+ return True
355
+ return False
354
356
 
355
357
  def r_render(self, command):
356
358
  spec = self.getRuntimeValue(command['spec'])
357
359
  parent = command['parent']
358
360
  if parent !=None:
359
361
  parent = self.getVariable(command['parent'])
360
- self.ui = self.renderer.getUI()
361
362
  try:
362
- ScreenSpec().render(spec, parent, self.ui)
363
+ ScreenSpec().render(spec, parent)
363
364
  except Exception as e:
364
365
  RuntimeError(self.program, e)
365
366
  return self.nextPC()
366
367
 
367
- # run graphics
368
- def k_run(self, command):
369
- if self.nextIs('graphics'):
370
- self.add(command)
371
- return True
372
- return False
373
-
374
- def r_run(self, command):
375
- self.renderer = Renderer()
376
- self.renderer.init(self.windowSpec)
377
- self.ui = self.renderer.getUI()
378
- self.program.setExternalControl()
379
- self.program.run(self.nextPC())
380
- self.renderer.run()
381
-
382
368
  # Set something
383
369
  def k_set(self, command):
384
370
  if self.nextIs('attribute'):
@@ -405,7 +391,7 @@ class Graphics(Handler):
405
391
  target = self.getVariable(command['target'])
406
392
  id = target['value'][target['index']]['content']
407
393
  value = self.getRuntimeValue(command['value'])
408
- self.ui.setAttribute(id, attribute, value)
394
+ getUI().setAttribute(id, attribute, value)
409
395
  return self.nextPC()
410
396
 
411
397
  # Show an element (restore it to its current position)
@@ -420,7 +406,7 @@ class Graphics(Handler):
420
406
  return False
421
407
 
422
408
  def r_show(self, command):
423
- self.ui.setVisible(self.getRuntimeValue(command['target']), True)
409
+ getUI().setVisible(self.getRuntimeValue(command['target']), True)
424
410
  return self.nextPC()
425
411
 
426
412
  def k_text(self, command):
@@ -483,7 +469,7 @@ class Graphics(Handler):
483
469
  attribute = self.getRuntimeValue(v['attribute'])
484
470
  target = self.getVariable(v['target'])
485
471
  val = self.getSymbolValue(target)
486
- v = self.ui.getAttribute(val['content'], attribute)
472
+ v = getUI().getAttribute(val['content'], attribute)
487
473
  value = {}
488
474
  value['type'] = 'int'
489
475
  value['content'] = int(round(v))
@@ -505,7 +491,7 @@ class Graphics(Handler):
505
491
  attribute = v['attribute']
506
492
  value = {}
507
493
  value['type'] = 'int'
508
- value['content'] = int(round(self.ui.getWindowAttribute(attribute)))
494
+ value['content'] = int(round(getUI().getWindowAttribute(attribute)))
509
495
  return value
510
496
  except Exception as e:
511
497
  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.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>
@@ -0,0 +1,19 @@
1
+ easycoder/README.md,sha256=PYqOc_SkIGiFbyCNs90y7JqoqWe4aO1xYIW-6bOnFKU,573
2
+ easycoder/__init__.py,sha256=IErx-lbecKTrIN5Hym-iAL4hyckfBU2Dv9jyVVyEjvQ,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=uH_8NK8PGoSYl5POgLMgDlwMw5l1ayrPV7CBXn26Fos,18486
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.2.dist-info/entry_points.txt,sha256=JXAZbenl0TnsIft2FcGJbJ-4qoztVu2FuT8PFmWFexM,44
16
+ easycoder-250109.2.dist-info/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
17
+ easycoder-250109.2.dist-info/WHEEL,sha256=Sgu64hAMa6g5FdzHxXv9Xdse9yxpGGMeagVtPMWpJQY,99
18
+ easycoder-250109.2.dist-info/METADATA,sha256=UsHVHoqqJvWVgxQfP1kKtUIkSlMXrCSIgs25vy1npbw,5817
19
+ easycoder-250109.2.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,,