easycoder 250107.2__tar.gz → 250109.1__tar.gz

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.

Files changed (164) hide show
  1. {easycoder-250107.2 → easycoder-250109.1}/PKG-INFO +1 -1
  2. {easycoder-250107.2 → easycoder-250109.1}/easycoder/__init__.py +1 -1
  3. {easycoder-250107.2 → easycoder-250109.1}/easycoder/ec_graphics.py +51 -25
  4. {easycoder-250107.2 → easycoder-250109.1}/easycoder/ec_program.py +1 -1
  5. {easycoder-250107.2 → easycoder-250109.1}/easycoder/ec_renderer.py +57 -22
  6. {easycoder-250107.2 → easycoder-250109.1}/easycoder/ec_screenspec.py +14 -7
  7. {easycoder-250107.2 → easycoder-250109.1}/easycoder/ec_value.py +9 -2
  8. easycoder-250109.1/plugins/ec_keyboard.py +248 -0
  9. easycoder-250109.1/plugins/keyboards/4-function.json +58 -0
  10. easycoder-250109.1/plugins/keyboards/round-button.png +0 -0
  11. {easycoder-250107.2 → easycoder-250109.1}/scripts/graphics-demo.ecg +12 -1
  12. easycoder-250109.1/scripts/keyboard.ecg +22 -0
  13. {easycoder-250107.2 → easycoder-250109.1}/scripts/wave.ecg +19 -4
  14. {easycoder-250107.2 → easycoder-250109.1}/LICENSE +0 -0
  15. {easycoder-250107.2 → easycoder-250109.1}/README.md +0 -0
  16. {easycoder-250107.2 → easycoder-250109.1}/doc/README.md +0 -0
  17. {easycoder-250107.2 → easycoder-250109.1}/doc/core/README.md +0 -0
  18. {easycoder-250107.2 → easycoder-250109.1}/doc/core/conditions/boolean.md +0 -0
  19. {easycoder-250107.2 → easycoder-250109.1}/doc/core/conditions/empty.md +0 -0
  20. {easycoder-250107.2 → easycoder-250109.1}/doc/core/conditions/ends.md +0 -0
  21. {easycoder-250107.2 → easycoder-250109.1}/doc/core/conditions/even.md +0 -0
  22. {easycoder-250107.2 → easycoder-250109.1}/doc/core/conditions/exists.md +0 -0
  23. {easycoder-250107.2 → easycoder-250109.1}/doc/core/conditions/greater.md +0 -0
  24. {easycoder-250107.2 → easycoder-250109.1}/doc/core/conditions/hasProperty.md +0 -0
  25. {easycoder-250107.2 → easycoder-250109.1}/doc/core/conditions/includes.md +0 -0
  26. {easycoder-250107.2 → easycoder-250109.1}/doc/core/conditions/is.md +0 -0
  27. {easycoder-250107.2 → easycoder-250109.1}/doc/core/conditions/less.md +0 -0
  28. {easycoder-250107.2 → easycoder-250109.1}/doc/core/conditions/list.md +0 -0
  29. {easycoder-250107.2 → easycoder-250109.1}/doc/core/conditions/none.md +0 -0
  30. {easycoder-250107.2 → easycoder-250109.1}/doc/core/conditions/not.md +0 -0
  31. {easycoder-250107.2 → easycoder-250109.1}/doc/core/conditions/numeric.md +0 -0
  32. {easycoder-250107.2 → easycoder-250109.1}/doc/core/conditions/object.md +0 -0
  33. {easycoder-250107.2 → easycoder-250109.1}/doc/core/conditions/odd.md +0 -0
  34. {easycoder-250107.2 → easycoder-250109.1}/doc/core/conditions/starts.md +0 -0
  35. {easycoder-250107.2 → easycoder-250109.1}/doc/core/conditions/string.md +0 -0
  36. {easycoder-250107.2 → easycoder-250109.1}/doc/core/keywords/add.md +0 -0
  37. {easycoder-250107.2 → easycoder-250109.1}/doc/core/keywords/append.md +0 -0
  38. {easycoder-250107.2 → easycoder-250109.1}/doc/core/keywords/assert.md +0 -0
  39. {easycoder-250107.2 → easycoder-250109.1}/doc/core/keywords/begin.md +0 -0
  40. {easycoder-250107.2 → easycoder-250109.1}/doc/core/keywords/clear.md +0 -0
  41. {easycoder-250107.2 → easycoder-250109.1}/doc/core/keywords/close.md +0 -0
  42. {easycoder-250107.2 → easycoder-250109.1}/doc/core/keywords/create.md +0 -0
  43. {easycoder-250107.2 → easycoder-250109.1}/doc/core/keywords/debug.md +0 -0
  44. {easycoder-250107.2 → easycoder-250109.1}/doc/core/keywords/decrement.md +0 -0
  45. {easycoder-250107.2 → easycoder-250109.1}/doc/core/keywords/delete.md +0 -0
  46. {easycoder-250107.2 → easycoder-250109.1}/doc/core/keywords/divide.md +0 -0
  47. {easycoder-250107.2 → easycoder-250109.1}/doc/core/keywords/exit.md +0 -0
  48. {easycoder-250107.2 → easycoder-250109.1}/doc/core/keywords/file.md +0 -0
  49. {easycoder-250107.2 → easycoder-250109.1}/doc/core/keywords/fork.md +0 -0
  50. {easycoder-250107.2 → easycoder-250109.1}/doc/core/keywords/get.md +0 -0
  51. {easycoder-250107.2 → easycoder-250109.1}/doc/core/keywords/go.md +0 -0
  52. {easycoder-250107.2 → easycoder-250109.1}/doc/core/keywords/gosub.md +0 -0
  53. {easycoder-250107.2 → easycoder-250109.1}/doc/core/keywords/if.md +0 -0
  54. {easycoder-250107.2 → easycoder-250109.1}/doc/core/keywords/import.md +0 -0
  55. {easycoder-250107.2 → easycoder-250109.1}/doc/core/keywords/increment.md +0 -0
  56. {easycoder-250107.2 → easycoder-250109.1}/doc/core/keywords/index.md +0 -0
  57. {easycoder-250107.2 → easycoder-250109.1}/doc/core/keywords/init.md +0 -0
  58. {easycoder-250107.2 → easycoder-250109.1}/doc/core/keywords/input.md +0 -0
  59. {easycoder-250107.2 → easycoder-250109.1}/doc/core/keywords/load.md +0 -0
  60. {easycoder-250107.2 → easycoder-250109.1}/doc/core/keywords/lock.md +0 -0
  61. {easycoder-250107.2 → easycoder-250109.1}/doc/core/keywords/module.md +0 -0
  62. {easycoder-250107.2 → easycoder-250109.1}/doc/core/keywords/multiply.md +0 -0
  63. {easycoder-250107.2 → easycoder-250109.1}/doc/core/keywords/negate.md +0 -0
  64. {easycoder-250107.2 → easycoder-250109.1}/doc/core/keywords/open.md +0 -0
  65. {easycoder-250107.2 → easycoder-250109.1}/doc/core/keywords/pop.md +0 -0
  66. {easycoder-250107.2 → easycoder-250109.1}/doc/core/keywords/post.md +0 -0
  67. {easycoder-250107.2 → easycoder-250109.1}/doc/core/keywords/print.md +0 -0
  68. {easycoder-250107.2 → easycoder-250109.1}/doc/core/keywords/push.md +0 -0
  69. {easycoder-250107.2 → easycoder-250109.1}/doc/core/keywords/put.md +0 -0
  70. {easycoder-250107.2 → easycoder-250109.1}/doc/core/keywords/read.md +0 -0
  71. {easycoder-250107.2 → easycoder-250109.1}/doc/core/keywords/release.md +0 -0
  72. {easycoder-250107.2 → easycoder-250109.1}/doc/core/keywords/replace.md +0 -0
  73. {easycoder-250107.2 → easycoder-250109.1}/doc/core/keywords/return.md +0 -0
  74. {easycoder-250107.2 → easycoder-250109.1}/doc/core/keywords/run.md +0 -0
  75. {easycoder-250107.2 → easycoder-250109.1}/doc/core/keywords/save.md +0 -0
  76. {easycoder-250107.2 → easycoder-250109.1}/doc/core/keywords/script.md +0 -0
  77. {easycoder-250107.2 → easycoder-250109.1}/doc/core/keywords/set.md +0 -0
  78. {easycoder-250107.2 → easycoder-250109.1}/doc/core/keywords/split.md +0 -0
  79. {easycoder-250107.2 → easycoder-250109.1}/doc/core/keywords/stack.md +0 -0
  80. {easycoder-250107.2 → easycoder-250109.1}/doc/core/keywords/stop.md +0 -0
  81. {easycoder-250107.2 → easycoder-250109.1}/doc/core/keywords/system.md +0 -0
  82. {easycoder-250107.2 → easycoder-250109.1}/doc/core/keywords/take.md +0 -0
  83. {easycoder-250107.2 → easycoder-250109.1}/doc/core/keywords/toggle.md +0 -0
  84. {easycoder-250107.2 → easycoder-250109.1}/doc/core/keywords/truncate.md +0 -0
  85. {easycoder-250107.2 → easycoder-250109.1}/doc/core/keywords/unlock.md +0 -0
  86. {easycoder-250107.2 → easycoder-250109.1}/doc/core/keywords/variable.md +0 -0
  87. {easycoder-250107.2 → easycoder-250109.1}/doc/core/keywords/wait.md +0 -0
  88. {easycoder-250107.2 → easycoder-250109.1}/doc/core/keywords/while.md +0 -0
  89. {easycoder-250107.2 → easycoder-250109.1}/doc/core/keywords/write.md +0 -0
  90. {easycoder-250107.2 → easycoder-250109.1}/doc/core/values/arg.md +0 -0
  91. {easycoder-250107.2 → easycoder-250109.1}/doc/core/values/args.md +0 -0
  92. {easycoder-250107.2 → easycoder-250109.1}/doc/core/values/cos.md +0 -0
  93. {easycoder-250107.2 → easycoder-250109.1}/doc/core/values/datime.md +0 -0
  94. {easycoder-250107.2 → easycoder-250109.1}/doc/core/values/decode.md +0 -0
  95. {easycoder-250107.2 → easycoder-250109.1}/doc/core/values/element.md +0 -0
  96. {easycoder-250107.2 → easycoder-250109.1}/doc/core/values/elements.md +0 -0
  97. {easycoder-250107.2 → easycoder-250109.1}/doc/core/values/empty.md +0 -0
  98. {easycoder-250107.2 → easycoder-250109.1}/doc/core/values/encode.md +0 -0
  99. {easycoder-250107.2 → easycoder-250109.1}/doc/core/values/error.md +0 -0
  100. {easycoder-250107.2 → easycoder-250109.1}/doc/core/values/files.md +0 -0
  101. {easycoder-250107.2 → easycoder-250109.1}/doc/core/values/float.md +0 -0
  102. {easycoder-250107.2 → easycoder-250109.1}/doc/core/values/from.md +0 -0
  103. {easycoder-250107.2 → easycoder-250109.1}/doc/core/values/hash.md +0 -0
  104. {easycoder-250107.2 → easycoder-250109.1}/doc/core/values/index.md +0 -0
  105. {easycoder-250107.2 → easycoder-250109.1}/doc/core/values/integer.md +0 -0
  106. {easycoder-250107.2 → easycoder-250109.1}/doc/core/values/json.md +0 -0
  107. {easycoder-250107.2 → easycoder-250109.1}/doc/core/values/keys.md +0 -0
  108. {easycoder-250107.2 → easycoder-250109.1}/doc/core/values/left.md +0 -0
  109. {easycoder-250107.2 → easycoder-250109.1}/doc/core/values/length.md +0 -0
  110. {easycoder-250107.2 → easycoder-250109.1}/doc/core/values/lowercase.md +0 -0
  111. {easycoder-250107.2 → easycoder-250109.1}/doc/core/values/memory.md +0 -0
  112. {easycoder-250107.2 → easycoder-250109.1}/doc/core/values/modification.md +0 -0
  113. {easycoder-250107.2 → easycoder-250109.1}/doc/core/values/modulo.md +0 -0
  114. {easycoder-250107.2 → easycoder-250109.1}/doc/core/values/newline.md +0 -0
  115. {easycoder-250107.2 → easycoder-250109.1}/doc/core/values/now.md +0 -0
  116. {easycoder-250107.2 → easycoder-250109.1}/doc/core/values/position.md +0 -0
  117. {easycoder-250107.2 → easycoder-250109.1}/doc/core/values/property.md +0 -0
  118. {easycoder-250107.2 → easycoder-250109.1}/doc/core/values/random.md +0 -0
  119. {easycoder-250107.2 → easycoder-250109.1}/doc/core/values/right.md +0 -0
  120. {easycoder-250107.2 → easycoder-250109.1}/doc/core/values/sin.md +0 -0
  121. {easycoder-250107.2 → easycoder-250109.1}/doc/core/values/stringify.md +0 -0
  122. {easycoder-250107.2 → easycoder-250109.1}/doc/core/values/tab.md +0 -0
  123. {easycoder-250107.2 → easycoder-250109.1}/doc/core/values/tan.md +0 -0
  124. {easycoder-250107.2 → easycoder-250109.1}/doc/core/values/timestamp.md +0 -0
  125. {easycoder-250107.2 → easycoder-250109.1}/doc/core/values/today.md +0 -0
  126. {easycoder-250107.2 → easycoder-250109.1}/doc/core/values/trim.md +0 -0
  127. {easycoder-250107.2 → easycoder-250109.1}/doc/core/values/type.md +0 -0
  128. {easycoder-250107.2 → easycoder-250109.1}/doc/core/values/uppercase.md +0 -0
  129. {easycoder-250107.2 → easycoder-250109.1}/doc/core/values/value.md +0 -0
  130. {easycoder-250107.2 → easycoder-250109.1}/doc/core/values/weekday.md +0 -0
  131. {easycoder-250107.2 → easycoder-250109.1}/doc/graphics/README.md +0 -0
  132. {easycoder-250107.2 → easycoder-250109.1}/doc/graphics/keywords/attach.md +0 -0
  133. {easycoder-250107.2 → easycoder-250109.1}/doc/graphics/keywords/close.md +0 -0
  134. {easycoder-250107.2 → easycoder-250109.1}/doc/graphics/keywords/create.md +0 -0
  135. {easycoder-250107.2 → easycoder-250109.1}/doc/graphics/keywords/ellipse.md +0 -0
  136. {easycoder-250107.2 → easycoder-250109.1}/doc/graphics/keywords/image.md +0 -0
  137. {easycoder-250107.2 → easycoder-250109.1}/doc/graphics/keywords/move.md +0 -0
  138. {easycoder-250107.2 → easycoder-250109.1}/doc/graphics/keywords/on.md +0 -0
  139. {easycoder-250107.2 → easycoder-250109.1}/doc/graphics/keywords/rectangle.md +0 -0
  140. {easycoder-250107.2 → easycoder-250109.1}/doc/graphics/keywords/render.md +0 -0
  141. {easycoder-250107.2 → easycoder-250109.1}/doc/graphics/keywords/run.md +0 -0
  142. {easycoder-250107.2 → easycoder-250109.1}/doc/graphics/keywords/set.md +0 -0
  143. {easycoder-250107.2 → easycoder-250109.1}/doc/graphics/keywords/text.md +0 -0
  144. {easycoder-250107.2 → easycoder-250109.1}/doc/graphics/values/attribute.md +0 -0
  145. {easycoder-250107.2 → easycoder-250109.1}/doc/graphics/values/window.md +0 -0
  146. {easycoder-250107.2 → easycoder-250109.1}/easycoder/README.md +0 -0
  147. {easycoder-250107.2 → easycoder-250109.1}/easycoder/ec.py +0 -0
  148. {easycoder-250107.2 → easycoder-250109.1}/easycoder/ec_classes.py +0 -0
  149. {easycoder-250107.2 → easycoder-250109.1}/easycoder/ec_compiler.py +0 -0
  150. {easycoder-250107.2 → easycoder-250109.1}/easycoder/ec_condition.py +0 -0
  151. {easycoder-250107.2 → easycoder-250109.1}/easycoder/ec_core.py +0 -0
  152. {easycoder-250107.2 → easycoder-250109.1}/easycoder/ec_handler.py +0 -0
  153. {easycoder-250107.2 → easycoder-250109.1}/easycoder/ec_timestamp.py +0 -0
  154. {easycoder-250107.2 → easycoder-250109.1}/images/Semoigo Dawn.jpg +0 -0
  155. {easycoder-250107.2 → easycoder-250109.1}/json/graphics-demo.json +0 -0
  156. {easycoder-250107.2 → easycoder-250109.1}/plugins/ec_p100.py +0 -0
  157. {easycoder-250107.2 → easycoder-250109.1}/plugins/example.py +0 -0
  158. {easycoder-250107.2 → easycoder-250109.1}/pyproject.toml +0 -0
  159. {easycoder-250107.2 → easycoder-250109.1}/scripts/README.md +0 -0
  160. {easycoder-250107.2 → easycoder-250109.1}/scripts/benchmark.ecs +0 -0
  161. {easycoder-250107.2 → easycoder-250109.1}/scripts/fizzbuzz.ecs +0 -0
  162. {easycoder-250107.2 → easycoder-250109.1}/scripts/hello.ecs +0 -0
  163. {easycoder-250107.2 → easycoder-250109.1}/scripts/points.ecs +0 -0
  164. {easycoder-250107.2 → easycoder-250109.1}/scripts/tests.ecs +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: easycoder
3
- Version: 250107.2
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>
@@ -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.2"
13
+ __version__ = "250109.1"
@@ -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,8 +224,19 @@ 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()
227
+ # Hide an element
228
+ def k_hide(self, command):
229
+ if self.nextIsSymbol():
230
+ record = self.getSymbolRecord()
231
+ type = record['keyword']
232
+ if self.isGraphicType(type):
233
+ command['target'] = record['id']
234
+ self.add(command)
235
+ return True
236
+ return False
237
+
238
+ def r_hide(self, command):
239
+ getUI().setVisible(self.getRuntimeValue(command['target']), False)
229
240
  return self.nextPC()
230
241
 
231
242
  def k_image(self, command):
@@ -257,12 +268,12 @@ class Graphics(Handler):
257
268
 
258
269
  def r_move(self, command):
259
270
  pos = (self.getRuntimeValue(command['x']), self.getRuntimeValue(command['y']))
260
- self.ui.moveElementTo(self.getRuntimeValue(command['target']), pos)
271
+ getUI().moveElementTo(self.getRuntimeValue(command['target']), pos)
261
272
  return self.nextPC()
262
273
 
263
274
  def r_moveBy(self, command):
264
275
  dist = (self.getRuntimeValue(command['dx']), self.getRuntimeValue(command['dy']))
265
- self.ui.moveElementBy(self.getRuntimeValue(command['target']), dist)
276
+ getUI().moveElementBy(self.getRuntimeValue(command['target']), dist)
266
277
  return self.nextPC()
267
278
 
268
279
  # on click/tap {element} {action}
@@ -273,7 +284,7 @@ class Graphics(Handler):
273
284
  if self.nextIsSymbol():
274
285
  target = self.getSymbolRecord()
275
286
  else:
276
- FatalError(self.program.compiler, f'{self.getToken()} is not a screen element')
287
+ Warning(f'{self.getToken()} is not a screen element')
277
288
  return False
278
289
  command['target'] = target['name']
279
290
  command['goto'] = self.getPC() + 2
@@ -314,7 +325,7 @@ class Graphics(Handler):
314
325
  data = Object()
315
326
  data.pc = pc
316
327
  data.index = index
317
- self.ui.setOnClick(id, data, oncb)
328
+ getUI().setOnClick(id, data, oncb)
318
329
  else:
319
330
  name = record['name']
320
331
  RuntimeError(self.program, f'{name} is not a clickable object')
@@ -326,25 +337,26 @@ class Graphics(Handler):
326
337
  def r_rectangle(self, command):
327
338
  return self.nextPC()
328
339
 
329
- # render {spec}
340
+ # render spec {spec}
330
341
  def k_render(self, command):
331
- command['spec'] = self.nextValue()
332
- command['parent'] = None
333
- if self.peek() == 'in':
334
- self.nextToken()
335
- if self.nextIsSymbol():
336
- command['parent'] = self.getSymbolRecord()['name']
337
- self.add(command)
338
- 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
339
352
 
340
353
  def r_render(self, command):
341
354
  spec = self.getRuntimeValue(command['spec'])
342
355
  parent = command['parent']
343
356
  if parent !=None:
344
357
  parent = self.getVariable(command['parent'])
345
- self.ui = self.renderer.getUI()
346
358
  try:
347
- ScreenSpec().render(spec, parent, self.ui)
359
+ ScreenSpec().render(spec, parent)
348
360
  except Exception as e:
349
361
  RuntimeError(self.program, e)
350
362
  return self.nextPC()
@@ -359,7 +371,6 @@ class Graphics(Handler):
359
371
  def r_run(self, command):
360
372
  self.renderer = Renderer()
361
373
  self.renderer.init(self.windowSpec)
362
- self.ui = self.renderer.getUI()
363
374
  self.program.setExternalControl()
364
375
  self.program.run(self.nextPC())
365
376
  self.renderer.run()
@@ -390,7 +401,22 @@ class Graphics(Handler):
390
401
  target = self.getVariable(command['target'])
391
402
  id = target['value'][target['index']]['content']
392
403
  value = self.getRuntimeValue(command['value'])
393
- self.ui.setAttribute(id, attribute, value)
404
+ getUI().setAttribute(id, attribute, value)
405
+ return self.nextPC()
406
+
407
+ # Show an element (restore it to its current position)
408
+ def k_show(self, command):
409
+ if self.nextIsSymbol():
410
+ record = self.getSymbolRecord()
411
+ type = record['keyword']
412
+ if self.isGraphicType(type):
413
+ command['target'] = record['id']
414
+ self.add(command)
415
+ return True
416
+ return False
417
+
418
+ def r_show(self, command):
419
+ getUI().setVisible(self.getRuntimeValue(command['target']), True)
394
420
  return self.nextPC()
395
421
 
396
422
  def k_text(self, command):
@@ -453,7 +479,7 @@ class Graphics(Handler):
453
479
  attribute = self.getRuntimeValue(v['attribute'])
454
480
  target = self.getVariable(v['target'])
455
481
  val = self.getSymbolValue(target)
456
- v = self.ui.getAttribute(val['content'], attribute)
482
+ v = getUI().getAttribute(val['content'], attribute)
457
483
  value = {}
458
484
  value['type'] = 'int'
459
485
  value['content'] = int(round(v))
@@ -475,7 +501,7 @@ class Graphics(Handler):
475
501
  attribute = v['attribute']
476
502
  value = {}
477
503
  value['type'] = 'int'
478
- value['content'] = int(round(self.ui.getWindowAttribute(attribute)))
504
+ value['content'] = int(round(getUI().getWindowAttribute(attribute)))
479
505
  return value
480
506
  except Exception as e:
481
507
  RuntimeError(self.program, e)
@@ -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:
@@ -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'
13
+
14
+ ec_ui = None
15
+
16
+ def getUI():
17
+ global ec_ui
18
+ return ec_ui
11
19
 
12
- # Get a real position or size value
13
- # These are {n}w/h, where w/h are percentages
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:
@@ -35,12 +43,13 @@ class Element():
35
43
  def __init__(self, type, spec):
36
44
  self.type = type
37
45
  self.spec = spec
46
+ self.visible= True
38
47
  self.actionCB = None
39
48
 
40
49
  def getRelativePosition(self):
41
50
  spec = self.spec
42
- x = getReal(spec, spec.pos[0])
43
- y = getReal(spec, spec.pos[1])
51
+ x = getActual(spec.pos[0], spec)
52
+ y = getActual(spec.pos[1], spec)
44
53
  return Vector(x, y)
45
54
 
46
55
  def getType(self):
@@ -57,10 +66,11 @@ class Element():
57
66
  return pos
58
67
 
59
68
  def setPos(self, pos):
60
- # Update the spec
61
- self.spec.realpos = pos
62
- # Update the displayed item
63
- self.spec.item.pos = pos
69
+ if self.visible:
70
+ # Update the spec
71
+ self.spec.realpos = pos
72
+ # Update the displayed item
73
+ self.spec.item.pos = pos
64
74
 
65
75
  def getSize(self):
66
76
  return self.spec.realsize
@@ -69,6 +79,13 @@ class Element():
69
79
  self.spec.realsize = size
70
80
  self.spec.item.size = size
71
81
 
82
+ def setVisible(self, vis):
83
+ self.visible = vis
84
+ if vis:
85
+ self.setPos(self.spec.realpos)
86
+ else:
87
+ self.spec.item.pos = (Window.width, self.getPos()[1])
88
+
72
89
  def getChildren(self):
73
90
  return self.spec.children
74
91
 
@@ -99,10 +116,19 @@ class UI(Widget):
99
116
  Color(c[0], c[1], c[2])
100
117
  else:
101
118
  Color(c[0]/255, c[1]/255, c[2]/255)
102
- pos = (getReal(spec, spec.pos[0]), getReal(spec, spec.pos[1]))
103
- spec.realpos = pos
104
- size = (getReal(spec, spec.size[0]), getReal(spec, spec.size[1]))
119
+ size = (getActual(spec.size[0], spec), getActual(spec.size[1], spec))
105
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
106
132
  if spec.parent != None:
107
133
  pos = Vector(pos) + spec.parent.realpos
108
134
  if spec.type == 'ellipse':
@@ -119,10 +145,12 @@ class UI(Widget):
119
145
  Color(c[0]/255, c[1]/255, c[2]/255)
120
146
  else:
121
147
  Color(1, 1, 1, 1)
122
- 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')
123
152
  label.refresh()
124
- text = label.texture
125
- item = Rectangle(pos=pos, size=size, texture=text)
153
+ item = Rectangle(pos=pos, size=size, texture=label.texture)
126
154
  elif spec.type == 'image':
127
155
  item = AsyncImage(pos=pos, size=size, source=spec.source)
128
156
  spec.item = item
@@ -142,6 +170,14 @@ class UI(Widget):
142
170
  self.moveElementBy(id, Vector(pos) - element.getPos())
143
171
  return
144
172
 
173
+ def setVisible(self, id, vis):
174
+ element = self.getElement(id)
175
+ if element != None:
176
+ element.setVisible(vis)
177
+ for id in element.getChildren():
178
+ self.setVisible(id, vis)
179
+ return
180
+
145
181
  def on_touch_down(self, touch):
146
182
  tp = touch.pos
147
183
  x = tp[0]
@@ -214,9 +250,6 @@ class UI(Widget):
214
250
 
215
251
  class Renderer(App):
216
252
 
217
- def getUI(self):
218
- return self.ui
219
-
220
253
  def request_close(self):
221
254
  print('close window')
222
255
  self.kill()
@@ -230,7 +263,9 @@ class Renderer(App):
230
263
  return self.ui
231
264
 
232
265
  def init(self, spec):
233
- self.ui = UI()
266
+ global ec_ui
267
+ ec_ui = UI()
268
+ self.ui = ec_ui
234
269
  self.title = spec.title
235
270
  self.flush = spec.flush
236
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
-
@@ -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':