easycoder 250123.2__py2.py3-none-any.whl → 250204.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 +1 -1
- easycoder/ec_core.py +19 -10
- easycoder/ec_graphics.py +34 -325
- easycoder/ec_gutils.py +25 -5
- {easycoder-250123.2.dist-info → easycoder-250204.1.dist-info}/METADATA +1 -1
- {easycoder-250123.2.dist-info → easycoder-250204.1.dist-info}/RECORD +9 -9
- {easycoder-250123.2.dist-info → easycoder-250204.1.dist-info}/LICENSE +0 -0
- {easycoder-250123.2.dist-info → easycoder-250204.1.dist-info}/WHEEL +0 -0
- {easycoder-250123.2.dist-info → easycoder-250204.1.dist-info}/entry_points.txt +0 -0
easycoder/__init__.py
CHANGED
easycoder/ec_core.py
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import json, math, hashlib, threading, os, subprocess, sys, requests, time, numbers, base64
|
|
1
|
+
import json, math, hashlib, threading, os, subprocess, sys, requests, time, numbers, base64, binascii
|
|
2
2
|
from psutil import Process
|
|
3
3
|
from datetime import datetime, timezone
|
|
4
4
|
from random import randrange
|
|
@@ -484,7 +484,6 @@ class Core(Handler):
|
|
|
484
484
|
except:
|
|
485
485
|
pass
|
|
486
486
|
RuntimeError(self.program, f'There is no label "{label}"')
|
|
487
|
-
return None
|
|
488
487
|
|
|
489
488
|
def r_gotoPC(self, command):
|
|
490
489
|
return command['goto']
|
|
@@ -499,12 +498,14 @@ class Core(Handler):
|
|
|
499
498
|
|
|
500
499
|
def r_gosub(self, command):
|
|
501
500
|
label = command['gosub'] + ':'
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
501
|
+
try:
|
|
502
|
+
address = self.symbols[label]
|
|
503
|
+
if address != None:
|
|
504
|
+
self.stack.append(self.nextPC())
|
|
505
|
+
return address
|
|
506
|
+
except:
|
|
507
|
+
pass
|
|
508
|
+
RuntimeError(self.program, f'There is no label "{label}"')
|
|
508
509
|
|
|
509
510
|
# if <condition> <action> [else <action>]
|
|
510
511
|
def k_if(self, command):
|
|
@@ -1002,9 +1003,9 @@ class Core(Handler):
|
|
|
1002
1003
|
program = command['program']
|
|
1003
1004
|
code = program.code[program.pc]
|
|
1004
1005
|
lino = str(code['lino'] + 1)
|
|
1005
|
-
while len(lino) <
|
|
1006
|
+
while len(lino) < 5: lino = f' {lino}'
|
|
1006
1007
|
if value == None: value = '<empty>'
|
|
1007
|
-
if 'log' in command: print(f'{datetime.now().time()}:
|
|
1008
|
+
if 'log' in command: print(f'{datetime.now().time()}:{lino}-> {value}')
|
|
1008
1009
|
else: print(value)
|
|
1009
1010
|
return self.nextPC()
|
|
1010
1011
|
|
|
@@ -1988,6 +1989,10 @@ class Core(Handler):
|
|
|
1988
1989
|
value['type'] = 'text'
|
|
1989
1990
|
if self.encoding == 'utf-8':
|
|
1990
1991
|
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')
|
|
1991
1996
|
elif self.encoding == 'base64':
|
|
1992
1997
|
base64_bytes = content.encode('ascii')
|
|
1993
1998
|
message_bytes = base64.b64decode(base64_bytes)
|
|
@@ -2031,6 +2036,10 @@ class Core(Handler):
|
|
|
2031
2036
|
value['type'] = 'text'
|
|
2032
2037
|
if self.encoding == 'utf-8':
|
|
2033
2038
|
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')
|
|
2034
2043
|
elif self.encoding == 'base64':
|
|
2035
2044
|
data_bytes = content.encode('ascii')
|
|
2036
2045
|
base64_bytes = base64.b64encode(data_bytes)
|
easycoder/ec_graphics.py
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
from .ec_classes import FatalError, RuntimeError,
|
|
2
|
-
from .ec_handler import Handler
|
|
1
|
+
from .ec_classes import FatalError, RuntimeError, Handler
|
|
3
2
|
from .ec_gutils import GUtils
|
|
4
3
|
import PySimpleGUI as psg
|
|
5
4
|
import json
|
|
5
|
+
from copy import deepcopy
|
|
6
6
|
|
|
7
7
|
class Graphics(Handler):
|
|
8
8
|
|
|
@@ -61,28 +61,13 @@ class Graphics(Handler):
|
|
|
61
61
|
args = self.utils.decode(self, default, layout[n])
|
|
62
62
|
except Exception as e:
|
|
63
63
|
RuntimeError(self.program, e)
|
|
64
|
-
item = self.utils.
|
|
64
|
+
item = self.utils.createWidget(type, param, args)
|
|
65
65
|
target['layout'].append(item)
|
|
66
66
|
else:
|
|
67
67
|
v = self.getVariable(args)
|
|
68
68
|
target['layout'].append(v['layout'])
|
|
69
69
|
return self.nextPC()
|
|
70
70
|
|
|
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
71
|
def k_close(self, command):
|
|
87
72
|
if self.nextIsSymbol():
|
|
88
73
|
symbolRecord = self.getSymbolRecord()
|
|
@@ -126,15 +111,14 @@ class Graphics(Handler):
|
|
|
126
111
|
type = command['type']
|
|
127
112
|
record = self.getVariable(command['name'])
|
|
128
113
|
if type == 'window':
|
|
129
|
-
layout = self.getVariable(command['layout'])
|
|
130
114
|
title = self.getRuntimeValue(command['title'])
|
|
131
|
-
|
|
115
|
+
layout = self.getVariable(command['layout'])['layout']
|
|
116
|
+
window = psg.Window(title, layout, finalize=True)
|
|
132
117
|
record['window'] = window
|
|
133
118
|
record['eventHandlers'] = {}
|
|
134
119
|
self.program.windowRecord = record
|
|
135
120
|
self.program.run(self.nextPC())
|
|
136
121
|
self.mainLoop()
|
|
137
|
-
# self.program.kill()
|
|
138
122
|
return 0
|
|
139
123
|
else:
|
|
140
124
|
RuntimeError(self.program, 'Variable is not a window or an element')
|
|
@@ -206,176 +190,7 @@ class Graphics(Handler):
|
|
|
206
190
|
psg.popup(self.getRuntimeValue(command['message']))
|
|
207
191
|
return self.nextPC()
|
|
208
192
|
|
|
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):
|
|
193
|
+
def k_refresh(self, command):
|
|
379
194
|
if self.nextIsSymbol():
|
|
380
195
|
symbolRecord = self.getSymbolRecord()
|
|
381
196
|
if symbolRecord['keyword'] == 'window':
|
|
@@ -384,121 +199,9 @@ class Graphics(Handler):
|
|
|
384
199
|
return True
|
|
385
200
|
return False
|
|
386
201
|
|
|
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):
|
|
202
|
+
def r_refresh(self, command):
|
|
447
203
|
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']))
|
|
204
|
+
target['window'].refresh()
|
|
502
205
|
return self.nextPC()
|
|
503
206
|
|
|
504
207
|
# set property {property} of {key} in {window} to {value}
|
|
@@ -560,21 +263,24 @@ class Graphics(Handler):
|
|
|
560
263
|
return value
|
|
561
264
|
|
|
562
265
|
if token == 'property':
|
|
563
|
-
value['
|
|
266
|
+
value['property'] = self.nextValue()
|
|
564
267
|
if self.nextIs('of'):
|
|
565
268
|
if self.nextToken() == 'the':
|
|
566
269
|
if self.nextIs('event'):
|
|
567
|
-
value['source'] = '_event_'
|
|
568
270
|
return value
|
|
569
|
-
|
|
570
|
-
|
|
271
|
+
return None
|
|
272
|
+
|
|
273
|
+
if token == 'value':
|
|
274
|
+
if self.nextIs('of'):
|
|
275
|
+
if self.nextIs('key'):
|
|
276
|
+
value['key'] = self.nextValue()
|
|
571
277
|
if self.nextIs('in'):
|
|
572
278
|
if self.nextIsSymbol():
|
|
573
279
|
record = self.getSymbolRecord()
|
|
574
280
|
if record['keyword'] == 'window':
|
|
575
|
-
value['
|
|
281
|
+
value['window'] = record['name']
|
|
576
282
|
return value
|
|
577
|
-
|
|
283
|
+
return None
|
|
578
284
|
|
|
579
285
|
#############################################################################
|
|
580
286
|
# Modify a value or leave it unchanged.
|
|
@@ -600,21 +306,23 @@ class Graphics(Handler):
|
|
|
600
306
|
return v
|
|
601
307
|
|
|
602
308
|
def v_property(self, v):
|
|
309
|
+
property = self.getRuntimeValue(v['property'])
|
|
310
|
+
window = self.eventValues['window']
|
|
311
|
+
values = self.eventValues['values']
|
|
312
|
+
self.utils.getEventProperties(window, values)
|
|
313
|
+
v['type'] = 'text'
|
|
314
|
+
v['content'] = values[property]
|
|
315
|
+
return v
|
|
316
|
+
|
|
317
|
+
def v_value(self, v):
|
|
603
318
|
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
|
|
319
|
+
window = self.getVariable(v['window'])
|
|
320
|
+
value = self.utils.getWidgetValue(window, key)
|
|
321
|
+
if value == None: RuntimeError(self.program, 'getWidgetValue: unimplemented widget type')
|
|
322
|
+
v = deepcopy(v)
|
|
323
|
+
v['type'] = 'text'
|
|
324
|
+
v['content'] = value
|
|
325
|
+
return v
|
|
618
326
|
|
|
619
327
|
#############################################################################
|
|
620
328
|
# Compile a condition
|
|
@@ -643,3 +351,4 @@ class Graphics(Handler):
|
|
|
643
351
|
self.eventValues['values'] = values
|
|
644
352
|
self.eventValues['window'] = window
|
|
645
353
|
eventHandlers[event]()
|
|
354
|
+
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
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: easycoder
|
|
3
|
-
Version:
|
|
3
|
+
Version: 250204.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>
|
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
easycoder/README.md,sha256=PYqOc_SkIGiFbyCNs90y7JqoqWe4aO1xYIW-6bOnFKU,573
|
|
2
|
-
easycoder/__init__.py,sha256=
|
|
2
|
+
easycoder/__init__.py,sha256=hLMGC60RrVT7YsX6vj0nXfkwrDe44zEhhtTXTeYy8xk,262
|
|
3
3
|
easycoder/ec_classes.py,sha256=xnWBNak8oKydkFoxHLlq9wo3lIsB3aMnTDrqbtCfoWo,1512
|
|
4
4
|
easycoder/ec_compiler.py,sha256=dFJEA_uOhD-HeSiAdBzmmA6q3LHThUVoJpSETanmSHs,4800
|
|
5
5
|
easycoder/ec_condition.py,sha256=WSbONo4zs2sX1icOVpscZDFSCAEFmTsquoc2RGcLx_k,763
|
|
6
|
-
easycoder/ec_core.py,sha256=
|
|
7
|
-
easycoder/ec_graphics.py,sha256=
|
|
8
|
-
easycoder/ec_gutils.py,sha256=
|
|
6
|
+
easycoder/ec_core.py,sha256=ORrMf2TlsAxETK-5Of-zrSCHX517nVHtThI7ew9ts0o,87416
|
|
7
|
+
easycoder/ec_graphics.py,sha256=8GhnqIOITyZzIkdjouTnOQ9x0J6RpMz0sFseKkJATfE,12977
|
|
8
|
+
easycoder/ec_gutils.py,sha256=Pfz3u5KQieXm-F7qsB9gy6IUGDi-oJaX9xdiM9ZeO6s,5885
|
|
9
9
|
easycoder/ec_handler.py,sha256=IJvxcrJJSR53d6DS_8H5qPHKhp9y5-GV4WXAjhZxu_o,2250
|
|
10
10
|
easycoder/ec_program.py,sha256=R8zMukA-pfRsOpcy9WqTw7fE_190dQfrMt2la23Yrs4,9904
|
|
11
11
|
easycoder/ec_timestamp.py,sha256=_3QFJPzIWZ9Rzk3SQOQJ-gwmvB07pg78k23SPntoZtY,288
|
|
12
12
|
easycoder/ec_value.py,sha256=zgDJTJhIg3yOvmnnKIfccIizmIhGbtvL_ghLTL1T5fg,2516
|
|
13
|
-
easycoder-
|
|
14
|
-
easycoder-
|
|
15
|
-
easycoder-
|
|
16
|
-
easycoder-
|
|
17
|
-
easycoder-
|
|
13
|
+
easycoder-250204.1.dist-info/entry_points.txt,sha256=JXAZbenl0TnsIft2FcGJbJ-4qoztVu2FuT8PFmWFexM,44
|
|
14
|
+
easycoder-250204.1.dist-info/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
|
|
15
|
+
easycoder-250204.1.dist-info/WHEEL,sha256=Sgu64hAMa6g5FdzHxXv9Xdse9yxpGGMeagVtPMWpJQY,99
|
|
16
|
+
easycoder-250204.1.dist-info/METADATA,sha256=arFjAPGsq4FgHUm5QoCqVDJyiIgNQFSNF_1zVPzERlU,6162
|
|
17
|
+
easycoder-250204.1.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|