easycoder 250126.1__py2.py3-none-any.whl → 250205.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/README.md +2 -2
- easycoder/__init__.py +1 -1
- easycoder/ec_core.py +29 -22
- easycoder/ec_graphics.py +34 -324
- easycoder/ec_gutils.py +25 -5
- {easycoder-250126.1.dist-info → easycoder-250205.1.dist-info}/METADATA +2 -2
- easycoder-250205.1.dist-info/RECORD +17 -0
- {easycoder-250126.1.dist-info → easycoder-250205.1.dist-info}/WHEEL +1 -1
- easycoder-250126.1.dist-info/RECORD +0 -17
- {easycoder-250126.1.dist-info → easycoder-250205.1.dist-info}/LICENSE +0 -0
- {easycoder-250126.1.dist-info → easycoder-250205.1.dist-info}/entry_points.txt +0 -0
easycoder/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# EasyCode source code
|
|
2
2
|
These are the Python files that comprise **_EasyCoder_**.
|
|
3
3
|
|
|
4
|
-
**_EasyCoder_** has a small number of third-party dependencies. A minor one is `pytz`, which handles timezones. The biggest one by far is `
|
|
4
|
+
**_EasyCoder_** has a small number of third-party dependencies. A minor one is `pytz`, which handles timezones. The biggest one by far is `PySimpleGUI`, a comprehensive Python graphics library.
|
|
5
5
|
|
|
6
|
-
If an **_EasyCoder_** script filename ends with `.ecs` it's a command-line script. If it ends with `.ecg` it's a script for a graphical application and will cause `
|
|
6
|
+
If an **_EasyCoder_** script filename ends with `.ecs` it's a command-line script. If it ends with `.ecg` it's a script for a graphical application and will cause `PySimpleGUI` to be imported. Obviously this will only work on a GUI-based system, whereas command-line scripts will run anywhere there is Python.
|
easycoder/__init__.py
CHANGED
easycoder/ec_core.py
CHANGED
|
@@ -484,6 +484,7 @@ class Core(Handler):
|
|
|
484
484
|
except:
|
|
485
485
|
pass
|
|
486
486
|
RuntimeError(self.program, f'There is no label "{label}"')
|
|
487
|
+
return None
|
|
487
488
|
|
|
488
489
|
def r_gotoPC(self, command):
|
|
489
490
|
return command['goto']
|
|
@@ -498,14 +499,12 @@ class Core(Handler):
|
|
|
498
499
|
|
|
499
500
|
def r_gosub(self, command):
|
|
500
501
|
label = command['gosub'] + ':'
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
pass
|
|
508
|
-
RuntimeError(self.program, f'There is no label "{label}"')
|
|
502
|
+
address = self.symbols[label]
|
|
503
|
+
if address != None:
|
|
504
|
+
self.stack.append(self.nextPC())
|
|
505
|
+
return address
|
|
506
|
+
RuntimeError(self.program, f'There is no label "{label + ":"}"')
|
|
507
|
+
return None
|
|
509
508
|
|
|
510
509
|
# if <condition> <action> [else <action>]
|
|
511
510
|
def k_if(self, command):
|
|
@@ -1005,8 +1004,10 @@ class Core(Handler):
|
|
|
1005
1004
|
lino = str(code['lino'] + 1)
|
|
1006
1005
|
while len(lino) < 5: lino = f' {lino}'
|
|
1007
1006
|
if value == None: value = '<empty>'
|
|
1008
|
-
if 'log' in command:
|
|
1009
|
-
|
|
1007
|
+
if 'log' in command:
|
|
1008
|
+
print(f'{datetime.now().time()}:{lino}-> {value}')
|
|
1009
|
+
else:
|
|
1010
|
+
print(value)
|
|
1010
1011
|
return self.nextPC()
|
|
1011
1012
|
|
|
1012
1013
|
# Push a value onto a stack
|
|
@@ -1817,10 +1818,12 @@ class Core(Handler):
|
|
|
1817
1818
|
return None
|
|
1818
1819
|
|
|
1819
1820
|
if token == 'value':
|
|
1820
|
-
value['type'] = 'valueOf'
|
|
1821
1821
|
if self.nextIs('of'):
|
|
1822
|
-
|
|
1823
|
-
|
|
1822
|
+
v = self.nextValue()
|
|
1823
|
+
if v !=None:
|
|
1824
|
+
value['type'] = 'valueOf'
|
|
1825
|
+
value['content'] = v
|
|
1826
|
+
return value
|
|
1824
1827
|
return None
|
|
1825
1828
|
|
|
1826
1829
|
if token == 'length':
|
|
@@ -1989,10 +1992,6 @@ class Core(Handler):
|
|
|
1989
1992
|
value['type'] = 'text'
|
|
1990
1993
|
if self.encoding == 'utf-8':
|
|
1991
1994
|
value['content'] = content.decode('utf-8')
|
|
1992
|
-
elif self.encoding == 'hex':
|
|
1993
|
-
b = content.encode('utf-8')
|
|
1994
|
-
mb = binascii.unhexlify(b)
|
|
1995
|
-
value['content'] = mb.decode('utf-8')
|
|
1996
1995
|
elif self.encoding == 'base64':
|
|
1997
1996
|
base64_bytes = content.encode('ascii')
|
|
1998
1997
|
message_bytes = base64.b64decode(base64_bytes)
|
|
@@ -2036,10 +2035,6 @@ class Core(Handler):
|
|
|
2036
2035
|
value['type'] = 'text'
|
|
2037
2036
|
if self.encoding == 'utf-8':
|
|
2038
2037
|
value['content'] = content.encode('utf-8')
|
|
2039
|
-
elif self.encoding == 'hex':
|
|
2040
|
-
b = content.encode('utf-8')
|
|
2041
|
-
mb = binascii.hexlify(b)
|
|
2042
|
-
value['content'] = mb.decode('utf-8')
|
|
2043
2038
|
elif self.encoding == 'base64':
|
|
2044
2039
|
data_bytes = content.encode('ascii')
|
|
2045
2040
|
base64_bytes = base64.b64encode(data_bytes)
|
|
@@ -2405,11 +2400,22 @@ class Core(Handler):
|
|
|
2405
2400
|
if self.nextToken() == 'with':
|
|
2406
2401
|
condition.value2 = self.nextValue()
|
|
2407
2402
|
return condition
|
|
2403
|
+
return None
|
|
2408
2404
|
|
|
2409
2405
|
if token == 'includes':
|
|
2410
2406
|
condition.value2 = self.nextValue()
|
|
2411
2407
|
return condition
|
|
2412
2408
|
|
|
2409
|
+
if token == 'does':
|
|
2410
|
+
self.nextToken()
|
|
2411
|
+
if self.nextIs('not'):
|
|
2412
|
+
if self.nextIs('include'):
|
|
2413
|
+
condition.value2 = self.nextValue()
|
|
2414
|
+
condition.type = 'includes'
|
|
2415
|
+
condition.negate = True
|
|
2416
|
+
return condition
|
|
2417
|
+
return None
|
|
2418
|
+
|
|
2413
2419
|
if token == 'is':
|
|
2414
2420
|
token = self.nextToken()
|
|
2415
2421
|
if self.peek() == 'not':
|
|
@@ -2497,7 +2503,8 @@ class Core(Handler):
|
|
|
2497
2503
|
def c_includes(self, condition):
|
|
2498
2504
|
value1 = self.getRuntimeValue(condition.value1)
|
|
2499
2505
|
value2 = self.getRuntimeValue(condition.value2)
|
|
2500
|
-
|
|
2506
|
+
test = value2 in value1
|
|
2507
|
+
return not test if condition.negate else test
|
|
2501
2508
|
|
|
2502
2509
|
def c_is(self, condition):
|
|
2503
2510
|
comparison = self.program.compare(condition.value1, condition.value2)
|
easycoder/ec_graphics.py
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
from .ec_classes import FatalError, RuntimeError
|
|
1
|
+
from .ec_classes import FatalError, RuntimeError
|
|
2
2
|
from .ec_handler import Handler
|
|
3
3
|
from .ec_gutils import GUtils
|
|
4
4
|
import PySimpleGUI as psg
|
|
5
5
|
import json
|
|
6
|
+
from copy import deepcopy
|
|
6
7
|
|
|
7
8
|
class Graphics(Handler):
|
|
8
9
|
|
|
@@ -61,28 +62,13 @@ class Graphics(Handler):
|
|
|
61
62
|
args = self.utils.decode(self, default, layout[n])
|
|
62
63
|
except Exception as e:
|
|
63
64
|
RuntimeError(self.program, e)
|
|
64
|
-
item = self.utils.
|
|
65
|
+
item = self.utils.createWidget(type, param, args)
|
|
65
66
|
target['layout'].append(item)
|
|
66
67
|
else:
|
|
67
68
|
v = self.getVariable(args)
|
|
68
69
|
target['layout'].append(v['layout'])
|
|
69
70
|
return self.nextPC()
|
|
70
71
|
|
|
71
|
-
def k_capture(self, command):
|
|
72
|
-
if self.nextIs('event'):
|
|
73
|
-
if self.nextIs('as'):
|
|
74
|
-
if self.nextIsSymbol():
|
|
75
|
-
record = self.getSymbolRecord()
|
|
76
|
-
command['target'] = record['name']
|
|
77
|
-
self.addCommand(command)
|
|
78
|
-
return True
|
|
79
|
-
return False
|
|
80
|
-
|
|
81
|
-
def r_capture(self, command):
|
|
82
|
-
target = self.getVariable(command['target'])
|
|
83
|
-
self.putSymbolValue(target, self.getConstant(self.eventValues))
|
|
84
|
-
return self.nextPC()
|
|
85
|
-
|
|
86
72
|
def k_close(self, command):
|
|
87
73
|
if self.nextIsSymbol():
|
|
88
74
|
symbolRecord = self.getSymbolRecord()
|
|
@@ -126,15 +112,14 @@ class Graphics(Handler):
|
|
|
126
112
|
type = command['type']
|
|
127
113
|
record = self.getVariable(command['name'])
|
|
128
114
|
if type == 'window':
|
|
129
|
-
layout = self.getVariable(command['layout'])
|
|
130
115
|
title = self.getRuntimeValue(command['title'])
|
|
131
|
-
|
|
116
|
+
layout = self.getVariable(command['layout'])['layout']
|
|
117
|
+
window = psg.Window(title, layout, finalize=True)
|
|
132
118
|
record['window'] = window
|
|
133
119
|
record['eventHandlers'] = {}
|
|
134
120
|
self.program.windowRecord = record
|
|
135
121
|
self.program.run(self.nextPC())
|
|
136
122
|
self.mainLoop()
|
|
137
|
-
# self.program.kill()
|
|
138
123
|
return 0
|
|
139
124
|
else:
|
|
140
125
|
RuntimeError(self.program, 'Variable is not a window or an element')
|
|
@@ -206,176 +191,7 @@ class Graphics(Handler):
|
|
|
206
191
|
psg.popup(self.getRuntimeValue(command['message']))
|
|
207
192
|
return self.nextPC()
|
|
208
193
|
|
|
209
|
-
|
|
210
|
-
def k_set(self, command):
|
|
211
|
-
if self.nextIs('property'):
|
|
212
|
-
command['property'] = self.nextValue()
|
|
213
|
-
if self.nextIs('of'):
|
|
214
|
-
command['key'] = self.nextValue()
|
|
215
|
-
if self.nextIs('in'):
|
|
216
|
-
if self.nextIsSymbol():
|
|
217
|
-
record = self.getSymbolRecord()
|
|
218
|
-
if record['keyword'] == 'window':
|
|
219
|
-
name = record['name']
|
|
220
|
-
command['window'] = name
|
|
221
|
-
if self.nextIs('to'):
|
|
222
|
-
command['value'] = self.nextValue()
|
|
223
|
-
self.add(command)
|
|
224
|
-
return True
|
|
225
|
-
else: RuntimeError(self.program, f'\'{name}\' is not a window variable')
|
|
226
|
-
else: RuntimeError(self.program, 'No window variable given')
|
|
227
|
-
return False
|
|
228
|
-
|
|
229
|
-
def r_set(self, command):
|
|
230
|
-
property = self.getRuntimeValue(command['property'])
|
|
231
|
-
key = self.getRuntimeValue(command['key'])
|
|
232
|
-
window = self.program.windowRecord['window']
|
|
233
|
-
value = self.getRuntimeValue(command['value'])
|
|
234
|
-
self.utils.updateProperty(window[key], property, value)
|
|
235
|
-
return self.nextPC()
|
|
236
|
-
|
|
237
|
-
def k_window(self, command):
|
|
238
|
-
return self.compileVariable(command)
|
|
239
|
-
|
|
240
|
-
def r_window(self, command):
|
|
241
|
-
return self.nextPC()
|
|
242
|
-
|
|
243
|
-
#############################################################################
|
|
244
|
-
# Compile a value in this domain
|
|
245
|
-
def compileValue(self):
|
|
246
|
-
value = {}
|
|
247
|
-
value['domain'] = self.getName()
|
|
248
|
-
token = self.getToken()
|
|
249
|
-
if self.isSymbol():
|
|
250
|
-
value['name'] = token
|
|
251
|
-
symbolRecord = self.getSymbolRecord()
|
|
252
|
-
keyword = symbolRecord['keyword']
|
|
253
|
-
if keyword == 'event':
|
|
254
|
-
value['type'] = 'symbol'
|
|
255
|
-
return value
|
|
256
|
-
return None
|
|
257
|
-
|
|
258
|
-
if self.getToken() == 'the':
|
|
259
|
-
self.nextToken()
|
|
260
|
-
|
|
261
|
-
token = self.getToken()
|
|
262
|
-
value['type'] = token
|
|
263
|
-
|
|
264
|
-
if token == 'event':
|
|
265
|
-
return value
|
|
266
|
-
|
|
267
|
-
return None
|
|
268
|
-
|
|
269
|
-
#############################################################################
|
|
270
|
-
# Modify a value or leave it unchanged.
|
|
271
|
-
def modifyValue(self, value):
|
|
272
|
-
return value
|
|
273
|
-
|
|
274
|
-
#############################################################################
|
|
275
|
-
# Value handlers
|
|
276
|
-
|
|
277
|
-
# This is used by the expression evaluator to get the value of a symbol
|
|
278
|
-
def v_symbol(self, symbolRecord):
|
|
279
|
-
if symbolRecord['keyword'] == 'event':
|
|
280
|
-
return self.getSymbolValue(symbolRecord)
|
|
281
|
-
else:
|
|
282
|
-
return None
|
|
283
|
-
|
|
284
|
-
def v_event(self, v):
|
|
285
|
-
v['type'] = 'text'
|
|
286
|
-
v['content'] = self.eventValues
|
|
287
|
-
return v
|
|
288
|
-
|
|
289
|
-
#############################################################################
|
|
290
|
-
# Compile a condition
|
|
291
|
-
def compileCondition(self):
|
|
292
|
-
condition = {}
|
|
293
|
-
return condition
|
|
294
|
-
|
|
295
|
-
#############################################################################
|
|
296
|
-
# Condition handlers
|
|
297
|
-
|
|
298
|
-
#############################################################################
|
|
299
|
-
# The main loop
|
|
300
|
-
def mainLoop(self):
|
|
301
|
-
windowRecord = self.program.windowRecord
|
|
302
|
-
window = windowRecord['window']
|
|
303
|
-
eventHandlers = windowRecord['eventHandlers']
|
|
304
|
-
while True:
|
|
305
|
-
event, values = window.Read(timeout=100)
|
|
306
|
-
if event == psg.WIN_CLOSED or event == "EXIT":
|
|
307
|
-
del window
|
|
308
|
-
break
|
|
309
|
-
if event == '__TIMEOUT__': self.program.flushCB()
|
|
310
|
-
else:
|
|
311
|
-
if event in eventHandlers:
|
|
312
|
-
self.eventValues = values
|
|
313
|
-
eventHandlers[event]()
|
|
314
|
-
class Graphics(Handler):
|
|
315
|
-
|
|
316
|
-
def __init__(self, compiler):
|
|
317
|
-
Handler.__init__(self, compiler)
|
|
318
|
-
self.utils = GUtils()
|
|
319
|
-
|
|
320
|
-
def getName(self):
|
|
321
|
-
return 'graphics'
|
|
322
|
-
|
|
323
|
-
#############################################################################
|
|
324
|
-
# Keyword handlers
|
|
325
|
-
|
|
326
|
-
def k_add(self, command):
|
|
327
|
-
token = self.nextToken()
|
|
328
|
-
if self.isSymbol():
|
|
329
|
-
symbolRecord = self.getSymbolRecord()
|
|
330
|
-
name = symbolRecord['name']
|
|
331
|
-
keyword = symbolRecord['keyword']
|
|
332
|
-
if keyword == 'layout':
|
|
333
|
-
command['args'] = name
|
|
334
|
-
elif keyword in ['column', 'frame', 'tab']:
|
|
335
|
-
command['name'] = name
|
|
336
|
-
command['type'] = token
|
|
337
|
-
if self.peek() == 'to':
|
|
338
|
-
command['args'] = []
|
|
339
|
-
else:
|
|
340
|
-
command['args'] = self.utils.getArgs(self)
|
|
341
|
-
else:
|
|
342
|
-
command['type'] = token
|
|
343
|
-
command['args'] = self.utils.getArgs(self)
|
|
344
|
-
if self.nextIs('to'):
|
|
345
|
-
if self.nextIsSymbol():
|
|
346
|
-
symbolRecord = self.getSymbolRecord()
|
|
347
|
-
if symbolRecord['keyword'] in ['column', 'frame', 'layout', 'tab']:
|
|
348
|
-
command['target'] = symbolRecord['name']
|
|
349
|
-
self.addCommand(command)
|
|
350
|
-
return True
|
|
351
|
-
return False
|
|
352
|
-
|
|
353
|
-
def r_add(self, command):
|
|
354
|
-
target = self.getVariable(command['target'])
|
|
355
|
-
type = command['type']
|
|
356
|
-
args = command['args']
|
|
357
|
-
param= None
|
|
358
|
-
if not 'layout' in target:
|
|
359
|
-
target['layout'] = []
|
|
360
|
-
if args[0] == '{':
|
|
361
|
-
if type in ['Column', 'Frame', 'Tab']:
|
|
362
|
-
record = self.getVariable(command['name'])
|
|
363
|
-
param = record['layout']
|
|
364
|
-
layout = json.loads(self.getRuntimeValue(json.loads(args)))
|
|
365
|
-
default = self.utils.getDefaultArgs(type)
|
|
366
|
-
for n in range(0, len(layout)):
|
|
367
|
-
try:
|
|
368
|
-
args = self.utils.decode(self, default, layout[n])
|
|
369
|
-
except Exception as e:
|
|
370
|
-
RuntimeError(self.program, e)
|
|
371
|
-
item = self.utils.createElement(type, param, args)
|
|
372
|
-
target['layout'].append(item)
|
|
373
|
-
else:
|
|
374
|
-
v = self.getVariable(args)
|
|
375
|
-
target['layout'].append(v['layout'])
|
|
376
|
-
return self.nextPC()
|
|
377
|
-
|
|
378
|
-
def k_close(self, command):
|
|
194
|
+
def k_refresh(self, command):
|
|
379
195
|
if self.nextIsSymbol():
|
|
380
196
|
symbolRecord = self.getSymbolRecord()
|
|
381
197
|
if symbolRecord['keyword'] == 'window':
|
|
@@ -384,121 +200,9 @@ class Graphics(Handler):
|
|
|
384
200
|
return True
|
|
385
201
|
return False
|
|
386
202
|
|
|
387
|
-
def
|
|
388
|
-
target = self.getVariable(command['target'])
|
|
389
|
-
target['window'].close()
|
|
390
|
-
return self.nextPC()
|
|
391
|
-
|
|
392
|
-
def k_column(self, command):
|
|
393
|
-
return self.compileVariable(command)
|
|
394
|
-
|
|
395
|
-
def r_column(self, command):
|
|
396
|
-
return self.nextPC()
|
|
397
|
-
|
|
398
|
-
# create {window} layout {layout}
|
|
399
|
-
# create {element} {args...}
|
|
400
|
-
def k_create(self, command):
|
|
401
|
-
if self.nextIsSymbol():
|
|
402
|
-
symbolRecord = self.getSymbolRecord()
|
|
403
|
-
type = symbolRecord['keyword']
|
|
404
|
-
command['type'] = type
|
|
405
|
-
command['name'] = symbolRecord['name']
|
|
406
|
-
if type == 'window':
|
|
407
|
-
command['title'] = self.nextValue()
|
|
408
|
-
if self.nextIs('layout'):
|
|
409
|
-
if self.nextIsSymbol():
|
|
410
|
-
symbolRecord = self.getSymbolRecord()
|
|
411
|
-
if symbolRecord['keyword'] == 'layout':
|
|
412
|
-
command['layout'] = symbolRecord['name']
|
|
413
|
-
self.addCommand(command)
|
|
414
|
-
return True
|
|
415
|
-
return False
|
|
416
|
-
|
|
417
|
-
def r_create(self, command):
|
|
418
|
-
type = command['type']
|
|
419
|
-
record = self.getVariable(command['name'])
|
|
420
|
-
if type == 'window':
|
|
421
|
-
title = self.getRuntimeValue(command['title'])
|
|
422
|
-
layout = self.getVariable(command['layout'])['layout']
|
|
423
|
-
# keys = {}
|
|
424
|
-
# self.utils.tagKeys(keys, layout)
|
|
425
|
-
window = psg.Window(title, layout, finalize=True)
|
|
426
|
-
# window.keys = keys
|
|
427
|
-
record['window'] = window
|
|
428
|
-
record['eventHandlers'] = {}
|
|
429
|
-
self.program.windowRecord = record
|
|
430
|
-
self.program.run(self.nextPC())
|
|
431
|
-
self.mainLoop()
|
|
432
|
-
# self.program.kill()
|
|
433
|
-
return 0
|
|
434
|
-
else:
|
|
435
|
-
RuntimeError(self.program, 'Variable is not a window or an element')
|
|
436
|
-
|
|
437
|
-
def k_init(self, command):
|
|
438
|
-
if self.nextIsSymbol():
|
|
439
|
-
symbolRecord = self.getSymbolRecord()
|
|
440
|
-
if symbolRecord['keyword'] in ['column', 'frame', 'layout', 'tab']:
|
|
441
|
-
command['target'] = symbolRecord['name']
|
|
442
|
-
self.add(command)
|
|
443
|
-
return True
|
|
444
|
-
return False
|
|
445
|
-
|
|
446
|
-
def r_init(self, command):
|
|
203
|
+
def r_refresh(self, command):
|
|
447
204
|
target = self.getVariable(command['target'])
|
|
448
|
-
target['
|
|
449
|
-
return self.nextPC()
|
|
450
|
-
|
|
451
|
-
def k_layout(self, command):
|
|
452
|
-
return self.compileVariable(command)
|
|
453
|
-
|
|
454
|
-
def r_layout(self, command):
|
|
455
|
-
return self.nextPC()
|
|
456
|
-
|
|
457
|
-
def k_on(self, command):
|
|
458
|
-
token = self.nextToken()
|
|
459
|
-
if token == 'event':
|
|
460
|
-
command['key'] = self.nextValue()
|
|
461
|
-
if self.nextIs('in'):
|
|
462
|
-
if self.nextIsSymbol():
|
|
463
|
-
record = self.getSymbolRecord()
|
|
464
|
-
if record['keyword'] == 'window':
|
|
465
|
-
command['window'] = record['name']
|
|
466
|
-
command['goto'] = self.getPC() + 2
|
|
467
|
-
self.add(command)
|
|
468
|
-
self.nextToken()
|
|
469
|
-
pcNext = self.getPC()
|
|
470
|
-
cmd = {}
|
|
471
|
-
cmd['domain'] = 'core'
|
|
472
|
-
cmd['lino'] = command['lino']
|
|
473
|
-
cmd['keyword'] = 'gotoPC'
|
|
474
|
-
cmd['goto'] = 0
|
|
475
|
-
cmd['debug'] = False
|
|
476
|
-
self.addCommand(cmd)
|
|
477
|
-
self.compileOne()
|
|
478
|
-
cmd = {}
|
|
479
|
-
cmd['domain'] = 'core'
|
|
480
|
-
cmd['lino'] = command['lino']
|
|
481
|
-
cmd['keyword'] = 'stop'
|
|
482
|
-
cmd['debug'] = False
|
|
483
|
-
self.addCommand(cmd)
|
|
484
|
-
# Fixup the link
|
|
485
|
-
self.getCommandAt(pcNext)['goto'] = self.getPC()
|
|
486
|
-
return True
|
|
487
|
-
return False
|
|
488
|
-
|
|
489
|
-
def r_on(self, command):
|
|
490
|
-
key = self.getRuntimeValue(command['key'])
|
|
491
|
-
window = self.getVariable(command['window'])
|
|
492
|
-
window['eventHandlers'][key] = lambda: self.run(command['goto'])
|
|
493
|
-
return self.nextPC()
|
|
494
|
-
|
|
495
|
-
def k_popup(self, command):
|
|
496
|
-
command['message'] = self.nextValue()
|
|
497
|
-
self.addCommand(command)
|
|
498
|
-
return True
|
|
499
|
-
|
|
500
|
-
def r_popup(self, command):
|
|
501
|
-
psg.popup(self.getRuntimeValue(command['message']))
|
|
205
|
+
target['window'].refresh()
|
|
502
206
|
return self.nextPC()
|
|
503
207
|
|
|
504
208
|
# set property {property} of {key} in {window} to {value}
|
|
@@ -560,21 +264,24 @@ class Graphics(Handler):
|
|
|
560
264
|
return value
|
|
561
265
|
|
|
562
266
|
if token == 'property':
|
|
563
|
-
value['
|
|
267
|
+
value['property'] = self.nextValue()
|
|
564
268
|
if self.nextIs('of'):
|
|
565
269
|
if self.nextToken() == 'the':
|
|
566
270
|
if self.nextIs('event'):
|
|
567
|
-
value['source'] = '_event_'
|
|
568
271
|
return value
|
|
569
|
-
|
|
570
|
-
|
|
272
|
+
return None
|
|
273
|
+
|
|
274
|
+
if token == 'value':
|
|
275
|
+
if self.nextIs('of'):
|
|
276
|
+
if self.nextIs('key'):
|
|
277
|
+
value['key'] = self.nextValue()
|
|
571
278
|
if self.nextIs('in'):
|
|
572
279
|
if self.nextIsSymbol():
|
|
573
280
|
record = self.getSymbolRecord()
|
|
574
281
|
if record['keyword'] == 'window':
|
|
575
|
-
value['
|
|
282
|
+
value['window'] = record['name']
|
|
576
283
|
return value
|
|
577
|
-
|
|
284
|
+
return None
|
|
578
285
|
|
|
579
286
|
#############################################################################
|
|
580
287
|
# Modify a value or leave it unchanged.
|
|
@@ -600,21 +307,23 @@ class Graphics(Handler):
|
|
|
600
307
|
return v
|
|
601
308
|
|
|
602
309
|
def v_property(self, v):
|
|
310
|
+
property = self.getRuntimeValue(v['property'])
|
|
311
|
+
window = self.eventValues['window']
|
|
312
|
+
values = self.eventValues['values']
|
|
313
|
+
self.utils.getEventProperties(window, values)
|
|
314
|
+
v['type'] = 'text'
|
|
315
|
+
v['content'] = values[property]
|
|
316
|
+
return v
|
|
317
|
+
|
|
318
|
+
def v_value(self, v):
|
|
603
319
|
key = self.getRuntimeValue(v['key'])
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
return v
|
|
612
|
-
else:
|
|
613
|
-
window = self.getVariable(source)
|
|
614
|
-
widget = window['window'].key_dict[key]
|
|
615
|
-
v['type'] = 'text'
|
|
616
|
-
v['content'] = widget.get()
|
|
617
|
-
return v
|
|
320
|
+
window = self.getVariable(v['window'])
|
|
321
|
+
value = self.utils.getWidgetValue(window, key)
|
|
322
|
+
if value == None: RuntimeError(self.program, 'getWidgetValue: unimplemented widget type')
|
|
323
|
+
v = deepcopy(v)
|
|
324
|
+
v['type'] = 'text'
|
|
325
|
+
v['content'] = value
|
|
326
|
+
return v
|
|
618
327
|
|
|
619
328
|
#############################################################################
|
|
620
329
|
# Compile a condition
|
|
@@ -643,3 +352,4 @@ class Graphics(Handler):
|
|
|
643
352
|
self.eventValues['values'] = values
|
|
644
353
|
self.eventValues['window'] = window
|
|
645
354
|
eventHandlers[event]()
|
|
355
|
+
pass
|
easycoder/ec_gutils.py
CHANGED
|
@@ -52,14 +52,14 @@ class GUtils:
|
|
|
52
52
|
keys = values.keys()
|
|
53
53
|
for key in keys:
|
|
54
54
|
v = values[key]
|
|
55
|
-
|
|
56
|
-
if type(
|
|
55
|
+
widget = window.key_dict[key]
|
|
56
|
+
if type(widget) is psg.Listbox:
|
|
57
57
|
# Only pick one from those selected
|
|
58
58
|
v = v[0]
|
|
59
59
|
values[key] = v
|
|
60
60
|
|
|
61
|
-
# Create
|
|
62
|
-
def
|
|
61
|
+
# Create a widget
|
|
62
|
+
def createWidget(self, type, param, args):
|
|
63
63
|
if type == 'Button': return self.createButton(param, args)
|
|
64
64
|
elif type == 'Checkbox': return self.createCheckbox(param, args)
|
|
65
65
|
elif type == 'Column': return self.createColumn(param, args)
|
|
@@ -69,10 +69,29 @@ class GUtils:
|
|
|
69
69
|
elif type == 'Text': return self.createText(param, args)
|
|
70
70
|
else: return None
|
|
71
71
|
|
|
72
|
+
# Get the current value of a widget
|
|
73
|
+
def getWidgetValue(self, window, key):
|
|
74
|
+
key_dict = window['window'].key_dict
|
|
75
|
+
widget = key_dict[key]
|
|
76
|
+
if type(widget) is psg.Button: return widget.get()
|
|
77
|
+
elif type(widget) is psg.Checkbox: return widget.get()
|
|
78
|
+
elif type(widget) is psg.Column: return widget.get()
|
|
79
|
+
elif type(widget) is psg.Input: return widget.get()
|
|
80
|
+
elif type(widget) is psg.Listbox:
|
|
81
|
+
items = widget.get()
|
|
82
|
+
if len(items) > 0:
|
|
83
|
+
return items[0]
|
|
84
|
+
return ''
|
|
85
|
+
elif type(widget) is psg.Multiline: return widget.get()
|
|
86
|
+
elif type(widget) is psg.Text: return widget.get()
|
|
87
|
+
return None
|
|
88
|
+
|
|
72
89
|
# Update a property
|
|
73
90
|
def updateProperty(self, element, property, value):
|
|
74
91
|
if property == 'disabled':
|
|
75
92
|
element.update(disabled=value)
|
|
93
|
+
elif property == 'text':
|
|
94
|
+
element.update(text=value)
|
|
76
95
|
elif property == 'value':
|
|
77
96
|
element.update(value=value)
|
|
78
97
|
elif property == 'values':
|
|
@@ -136,9 +155,10 @@ class GUtils:
|
|
|
136
155
|
|
|
137
156
|
def getDefaultText(self, args):
|
|
138
157
|
args['text'] = '(empty)'
|
|
158
|
+
args['key'] = None
|
|
139
159
|
args['size'] = (None, None)
|
|
140
160
|
args['expand_x'] = False
|
|
141
161
|
|
|
142
162
|
def createText(self, param, args):
|
|
143
|
-
return psg.Text(text=args['text'], expand_x=args['expand_x'], size=self.getSize(args))
|
|
163
|
+
return psg.Text(text=args['text'], expand_x=args['expand_x'], key=args['key'], size=self.getSize(args))
|
|
144
164
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
Metadata-Version: 2.
|
|
1
|
+
Metadata-Version: 2.1
|
|
2
2
|
Name: easycoder
|
|
3
|
-
Version:
|
|
3
|
+
Version: 250205.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,17 @@
|
|
|
1
|
+
easycoder/README.md,sha256=BVXmYphcTJ6q6RN_9L6HtQukgCnOjSLVIsTM3lk-9aM,587
|
|
2
|
+
easycoder/__init__.py,sha256=Y3LsOHjBOTK-wrREfqMN4Sq_ejIOx0eWV2xlP_-4Fa0,262
|
|
3
|
+
easycoder/ec_classes.py,sha256=xnWBNak8oKydkFoxHLlq9wo3lIsB3aMnTDrqbtCfoWo,1512
|
|
4
|
+
easycoder/ec_compiler.py,sha256=dFJEA_uOhD-HeSiAdBzmmA6q3LHThUVoJpSETanmSHs,4800
|
|
5
|
+
easycoder/ec_condition.py,sha256=WSbONo4zs2sX1icOVpscZDFSCAEFmTsquoc2RGcLx_k,763
|
|
6
|
+
easycoder/ec_core.py,sha256=Z47ByZY8CrEv-Qy_x4jrOz1fKZ47qlmjWIhPmPPP5kc,87584
|
|
7
|
+
easycoder/ec_graphics.py,sha256=I5C4YYzdaCjL7_Vc7cNalABV18PL8QOqDbJQnQB6lrY,13000
|
|
8
|
+
easycoder/ec_gutils.py,sha256=Pfz3u5KQieXm-F7qsB9gy6IUGDi-oJaX9xdiM9ZeO6s,5885
|
|
9
|
+
easycoder/ec_handler.py,sha256=IJvxcrJJSR53d6DS_8H5qPHKhp9y5-GV4WXAjhZxu_o,2250
|
|
10
|
+
easycoder/ec_program.py,sha256=R8zMukA-pfRsOpcy9WqTw7fE_190dQfrMt2la23Yrs4,9904
|
|
11
|
+
easycoder/ec_timestamp.py,sha256=_3QFJPzIWZ9Rzk3SQOQJ-gwmvB07pg78k23SPntoZtY,288
|
|
12
|
+
easycoder/ec_value.py,sha256=zgDJTJhIg3yOvmnnKIfccIizmIhGbtvL_ghLTL1T5fg,2516
|
|
13
|
+
easycoder-250205.1.dist-info/entry_points.txt,sha256=JXAZbenl0TnsIft2FcGJbJ-4qoztVu2FuT8PFmWFexM,44
|
|
14
|
+
easycoder-250205.1.dist-info/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
|
|
15
|
+
easycoder-250205.1.dist-info/WHEEL,sha256=Sgu64hAMa6g5FdzHxXv9Xdse9yxpGGMeagVtPMWpJQY,99
|
|
16
|
+
easycoder-250205.1.dist-info/METADATA,sha256=0xFEU997MjQw1hTZokP-NIQXxcLhEz35wTIbNDW4UQE,6162
|
|
17
|
+
easycoder-250205.1.dist-info/RECORD,,
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
easycoder/README.md,sha256=PYqOc_SkIGiFbyCNs90y7JqoqWe4aO1xYIW-6bOnFKU,573
|
|
2
|
-
easycoder/__init__.py,sha256=7blwInEm57sQkA8ubHAOO5NaWltFnOaWw8hAAN-7rEw,262
|
|
3
|
-
easycoder/ec_classes.py,sha256=xnWBNak8oKydkFoxHLlq9wo3lIsB3aMnTDrqbtCfoWo,1512
|
|
4
|
-
easycoder/ec_compiler.py,sha256=dFJEA_uOhD-HeSiAdBzmmA6q3LHThUVoJpSETanmSHs,4800
|
|
5
|
-
easycoder/ec_condition.py,sha256=WSbONo4zs2sX1icOVpscZDFSCAEFmTsquoc2RGcLx_k,763
|
|
6
|
-
easycoder/ec_core.py,sha256=ORrMf2TlsAxETK-5Of-zrSCHX517nVHtThI7ew9ts0o,87416
|
|
7
|
-
easycoder/ec_graphics.py,sha256=KbLbhNDr-DjKKy8RbkzpBogvz30FXFOsmQUJxFcBg4E,23718
|
|
8
|
-
easycoder/ec_gutils.py,sha256=cREktnAoHd_1t_fDgrnQ1F60n_TzFTGvoXJeWc_LJo4,5068
|
|
9
|
-
easycoder/ec_handler.py,sha256=IJvxcrJJSR53d6DS_8H5qPHKhp9y5-GV4WXAjhZxu_o,2250
|
|
10
|
-
easycoder/ec_program.py,sha256=R8zMukA-pfRsOpcy9WqTw7fE_190dQfrMt2la23Yrs4,9904
|
|
11
|
-
easycoder/ec_timestamp.py,sha256=_3QFJPzIWZ9Rzk3SQOQJ-gwmvB07pg78k23SPntoZtY,288
|
|
12
|
-
easycoder/ec_value.py,sha256=zgDJTJhIg3yOvmnnKIfccIizmIhGbtvL_ghLTL1T5fg,2516
|
|
13
|
-
easycoder-250126.1.dist-info/entry_points.txt,sha256=JXAZbenl0TnsIft2FcGJbJ-4qoztVu2FuT8PFmWFexM,44
|
|
14
|
-
easycoder-250126.1.dist-info/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
|
|
15
|
-
easycoder-250126.1.dist-info/WHEEL,sha256=ssQ84EZ5gH1pCOujd3iW7HClo_O_aDaClUbX4B8bjKY,100
|
|
16
|
-
easycoder-250126.1.dist-info/METADATA,sha256=9Tbknq92pjycV1Lp3HYqrXldtHsRVOxVYif_KKeqRAQ,6162
|
|
17
|
-
easycoder-250126.1.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|