easycoder 250118.1__py2.py3-none-any.whl → 251103.4__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.
- easycoder/__init__.py +4 -1
- easycoder/close.png +0 -0
- easycoder/ec_border.py +63 -0
- easycoder/ec_classes.py +10 -6
- easycoder/ec_compiler.py +48 -19
- easycoder/ec_condition.py +2 -1
- easycoder/ec_core.py +632 -281
- easycoder/ec_handler.py +4 -2
- easycoder/ec_keyboard.py +439 -0
- easycoder/ec_program.py +43 -38
- easycoder/ec_pyside.py +1545 -0
- easycoder/ec_timestamp.py +1 -1
- easycoder/tick.png +0 -0
- {easycoder-250118.1.dist-info → easycoder-251103.4.dist-info}/METADATA +30 -30
- easycoder-251103.4.dist-info/RECORD +19 -0
- {easycoder-250118.1.dist-info → easycoder-251103.4.dist-info}/WHEEL +1 -1
- easycoder/README.md +0 -6
- easycoder/ec_graphics.py +0 -314
- easycoder/ec_gutils.py +0 -84
- easycoder-250118.1.dist-info/RECORD +0 -17
- {easycoder-250118.1.dist-info → easycoder-251103.4.dist-info}/entry_points.txt +0 -0
- {easycoder-250118.1.dist-info → easycoder-251103.4.dist-info/licenses}/LICENSE +0 -0
easycoder/ec_timestamp.py
CHANGED
|
@@ -2,7 +2,7 @@ import pytz, time
|
|
|
2
2
|
from datetime import datetime
|
|
3
3
|
|
|
4
4
|
def getTimestamp(t):
|
|
5
|
-
tz = pytz.timezone('
|
|
5
|
+
tz = pytz.timezone('GB') # Localize this!
|
|
6
6
|
dt = datetime.fromtimestamp(t)
|
|
7
7
|
# print(f'{dt} + {tz.dst(dt).seconds}')
|
|
8
8
|
return int(t) + tz.dst(dt).seconds
|
easycoder/tick.png
ADDED
|
Binary file
|
|
@@ -1,16 +1,25 @@
|
|
|
1
|
-
Metadata-Version: 2.
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
2
|
Name: easycoder
|
|
3
|
-
Version:
|
|
3
|
+
Version: 251103.4
|
|
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>
|
|
7
7
|
Description-Content-Type: text/markdown
|
|
8
8
|
Classifier: License :: OSI Approved :: MIT License
|
|
9
|
+
License-File: LICENSE
|
|
9
10
|
Requires-Dist: pytz
|
|
11
|
+
Requires-Dist: requests
|
|
12
|
+
Requires-Dist: psutil
|
|
13
|
+
Requires-Dist: paramiko
|
|
14
|
+
Requires-Dist: pyside6
|
|
10
15
|
Project-URL: Home, https://github.com/easycoder/easycoder-py
|
|
11
16
|
|
|
12
17
|
# Introduction
|
|
13
|
-
**_EasyCoder_** is a high-level English-like scripting language suited for prototyping and rapid testing of ideas. It operates on the command line and a graphics module is under construction.
|
|
18
|
+
**_EasyCoder_** is a high-level English-like domain-specific scripting language (DSL) suited for prototyping and rapid testing of ideas. It operates on the command line and a graphics module is under construction. The language is written in Python and it acts as a fairly thin wrapper around standard Python functions, giving fast compilation and good runtime performance for general applications.
|
|
19
|
+
|
|
20
|
+
**_EasyCoder_** is well suited to building command-line or graphical applications for expressing random logic such as operating procedures and rules, or controlling physical systems, particularly those using wifi devices. It is easy to construct and issue REST commands to local or remote web servers.
|
|
21
|
+
|
|
22
|
+
For more advanced applications, **_EasyCoder_** is designed to be extensible, by enabling extra language syntax to be added via plugin-in modules. Once these are installed they act as seamless extensions to the basic syntax provided. **_EasyCoder_** derives its power from the use of rich and comprehensive language rather than a complex system of frameworks such as those commonly used in modern programming. This makes it very easy to learn as our brains are wired to operate that way. Having said that, the needs of most control systems are usually served by a fairly modest number of keywords and syntactic variants.
|
|
14
23
|
<hr>
|
|
15
24
|
|
|
16
25
|
There is also a JavaScript version of **_EasyCoder_**, which provides a full set of graphical features to run in a browser. For this, please visit
|
|
@@ -22,15 +31,12 @@ Website: [https://easycoder.github.io](https://easycoder.github.io)
|
|
|
22
31
|
## Quick Start
|
|
23
32
|
Install **_EasyCoder_** in your Python environment:
|
|
24
33
|
```
|
|
25
|
-
pip install requests
|
|
34
|
+
pip install requests easycoder
|
|
26
35
|
```
|
|
27
36
|
|
|
28
37
|
Test the install by typing the command `easycoder`.
|
|
29
38
|
<hr>
|
|
30
|
-
On Linux, this will probably fail as the installer places the executable file in the `$HOME/.local/bin` directory. So give the command
|
|
31
|
-
```
|
|
32
|
-
export PATH=$HOME/.local/bin:$PATH
|
|
33
|
-
```
|
|
39
|
+
On Linux, this will probably fail as the installer places the executable file in the `$HOME/.local/bin` directory. So give the command `export PATH=$HOME/.local/bin:$PATH`.
|
|
34
40
|
|
|
35
41
|
To make this change permanent, edit your `.profile` file, adding the following:
|
|
36
42
|
```
|
|
@@ -41,35 +47,40 @@ fi
|
|
|
41
47
|
```
|
|
42
48
|
<hr>
|
|
43
49
|
|
|
44
|
-
Now write a test script,
|
|
50
|
+
Now write a test script, `hello.ecs`, containing the following:
|
|
45
51
|
```
|
|
46
52
|
print `Hello, world!`
|
|
53
|
+
exit
|
|
47
54
|
```
|
|
48
55
|
(Note the backticks.) This is traditionally the first program to be written in virtually any language. To run it, use `easycoder hello.ecs`.
|
|
49
56
|
|
|
50
|
-
The output will look like this (the version number will differ):
|
|
57
|
+
The output will look like this (the version number will likely differ):
|
|
51
58
|
```
|
|
52
|
-
EasyCoder version
|
|
59
|
+
EasyCoder version 250403.1
|
|
53
60
|
Compiled <anon>: 1 lines (2 tokens) in 0 ms
|
|
54
61
|
Run <anon>
|
|
55
|
-
|
|
62
|
+
Hello, world!
|
|
56
63
|
```
|
|
57
64
|
|
|
65
|
+
Why the `exit`? Because EasyCoder can't tell that the program is finished. It might contain elements that are waiting for outside events, so without `exit` it just stops and waits. You can kill it by typing Control-C.
|
|
66
|
+
|
|
58
67
|
It's conventional to add a program title to a script:
|
|
59
68
|
```
|
|
60
69
|
! Test script
|
|
61
70
|
script Test
|
|
62
|
-
|
|
71
|
+
log `Hello, world!`
|
|
72
|
+
exit
|
|
63
73
|
```
|
|
64
|
-
|
|
74
|
+
|
|
75
|
+
The first line here is just a comment and has no effect on the running of the script. The second line gives the script a name, which is useful in debugging as it says which script was running. I've also changed `print` to `log` to get more information from the script. When run, the output is now
|
|
65
76
|
```
|
|
66
|
-
EasyCoder version
|
|
77
|
+
EasyCoder version 250403.1
|
|
67
78
|
Compiled Test: 3 lines (4 tokens) in 0 ms
|
|
68
79
|
Run Test
|
|
69
|
-
3-> Hello, world!
|
|
80
|
+
16:37:39.132311: 3-> Hello, world!
|
|
70
81
|
```
|
|
71
82
|
|
|
72
|
-
As you might guess from the above, the
|
|
83
|
+
As you might guess from the above, the `log` command shows the time and the line in the script it was called from. This is very useful in tracking down debugging print commands in large scripts.
|
|
73
84
|
|
|
74
85
|
Here in the repository is a folder called `scripts` containing some sample scripts:
|
|
75
86
|
|
|
@@ -77,19 +88,8 @@ Here in the repository is a folder called `scripts` containing some sample scrip
|
|
|
77
88
|
`tests.ecs` is a test program containing many of the **_EasyCoder_** features
|
|
78
89
|
`benchmark.ecs` allows the performance of **_EasyCoder_** to be compared to other languages if a similar script is written for each one.
|
|
79
90
|
|
|
80
|
-
## Graphical
|
|
81
|
-
**_EasyCoder_** includes a graphical programming environment that is in
|
|
82
|
-
```
|
|
83
|
-
sudo apt install python3-tk
|
|
84
|
-
```
|
|
85
|
-
|
|
86
|
-
Next, install the Python `pySimpleGUI` graphics library; this is done with `pip install pysimplegui`. Then run your **_EasyCoder_** script using `easycoder {scriptname}.ecg`.
|
|
87
|
-
|
|
88
|
-
Graphical scripts look much like any other script but their file names must use the extension `.ecg` to signal to **_EasyCoder_** that it needs to load the graphics module. Non-graphical applications can use any extension but `.ecs` is recommended. This allows the **_EasyCoder_** application to be used wherever Python is installed, in either a command-line or a graphical environment, but graphics will of course not be available in the former.
|
|
89
|
-
|
|
90
|
-
Some demo graphical scripts will included in the `scripts` directory as development proceeds.
|
|
91
|
-
|
|
92
|
-
`gtest.ecg` contains sample code to demonstrate and test basic features.
|
|
91
|
+
## Graphical programming
|
|
92
|
+
**_EasyCoder_** includes a graphical programming environment based on PySide6, that is in under development. Some demo scripts will be included in the `scripts` directory as development proceeds. Anyone wishing to track progress can do so via this repository. At the time of writing we are transitioning from an early version based on PySimpleGUI to one based on PySide, the latter being an open product that matches the needs of a DSL better than does the former.
|
|
93
93
|
|
|
94
94
|
## Significant features
|
|
95
95
|
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
easycoder/__init__.py,sha256=x5eJ0b_BaGw0O88hLzy-pO_ktclTFPZfSD5bmPM85WQ,339
|
|
2
|
+
easycoder/close.png,sha256=3B9ueRNtEu9E4QNmZhdyC4VL6uqKvGmdfeFxIV9aO_Y,9847
|
|
3
|
+
easycoder/ec_border.py,sha256=KpOy0Jq8jI_6DYGo4jaFvoBP_jTIoAYWrmuHhl-FXA4,2355
|
|
4
|
+
easycoder/ec_classes.py,sha256=YGUiKnVN6T5scoeBmmGDQAtE8xJgaTHi0Exh9A7H2Y4,1750
|
|
5
|
+
easycoder/ec_compiler.py,sha256=teu33Y9j0s1kT4R9XvTy6EIXOadpIEz3IVFji5CdBTM,5625
|
|
6
|
+
easycoder/ec_condition.py,sha256=uamZrlW3Ej3R4bPDuduGB2f00M80Z1D0qV8muDx4Qfw,784
|
|
7
|
+
easycoder/ec_core.py,sha256=c51wdwTwppZwGLOhN22SBCdAmnTFQw0eirMJxkOb8vI,100780
|
|
8
|
+
easycoder/ec_handler.py,sha256=zEZ5cPruEVZp3SIQ6ZjdZN5jDyW2gFvHcNmFaet4Sd4,2324
|
|
9
|
+
easycoder/ec_keyboard.py,sha256=H8DhPT8-IvAIGgRxCs4qSaF_AQLaS6lxxtDteejbktM,19010
|
|
10
|
+
easycoder/ec_program.py,sha256=aPuZOYWFqGd1jsLDl5M5YmLu5LfFAewF9EZh6zHIbyM,10308
|
|
11
|
+
easycoder/ec_pyside.py,sha256=ejcSSmGLJZ4mTcRuy2lktM4bG3weH2XhlH22RsT1RlY,58251
|
|
12
|
+
easycoder/ec_timestamp.py,sha256=myQnnF-mT31_1dpQKv2VEAu4BCcbypvMdzq7_DUi1xc,277
|
|
13
|
+
easycoder/ec_value.py,sha256=zgDJTJhIg3yOvmnnKIfccIizmIhGbtvL_ghLTL1T5fg,2516
|
|
14
|
+
easycoder/tick.png,sha256=OedASXJJTYvnza4J6Kv5m5lz6DrBfy667zX_WGgtbmM,9127
|
|
15
|
+
easycoder-251103.4.dist-info/entry_points.txt,sha256=JXAZbenl0TnsIft2FcGJbJ-4qoztVu2FuT8PFmWFexM,44
|
|
16
|
+
easycoder-251103.4.dist-info/licenses/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
|
|
17
|
+
easycoder-251103.4.dist-info/WHEEL,sha256=Dyt6SBfaasWElUrURkknVFAZDHSTwxg3PaTza7RSbkY,100
|
|
18
|
+
easycoder-251103.4.dist-info/METADATA,sha256=ErcQE05dpxvUuSWSZY_mwvadAf8t4nb_kvqYZhNlL28,6897
|
|
19
|
+
easycoder-251103.4.dist-info/RECORD,,
|
easycoder/README.md
DELETED
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
# EasyCode source code
|
|
2
|
-
These are the Python files that comprise **_EasyCoder_**.
|
|
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 `kivy`, a comprehensive Python graphics library.
|
|
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 `kivy` to be imported. Obviously this will only work on a GUI-based system, whereas command-line scripts will run anywhere there is Python.
|
easycoder/ec_graphics.py
DELETED
|
@@ -1,314 +0,0 @@
|
|
|
1
|
-
from .ec_classes import FatalError, RuntimeError, Object
|
|
2
|
-
from .ec_handler import Handler
|
|
3
|
-
from .ec_gutils import GUtils
|
|
4
|
-
import PySimpleGUI as psg
|
|
5
|
-
import json
|
|
6
|
-
|
|
7
|
-
class Graphics(Handler):
|
|
8
|
-
|
|
9
|
-
def __init__(self, compiler):
|
|
10
|
-
Handler.__init__(self, compiler)
|
|
11
|
-
self.utils = GUtils()
|
|
12
|
-
|
|
13
|
-
def getName(self):
|
|
14
|
-
return 'graphics'
|
|
15
|
-
|
|
16
|
-
#############################################################################
|
|
17
|
-
# Keyword handlers
|
|
18
|
-
|
|
19
|
-
def k_add(self, command):
|
|
20
|
-
token = self.nextToken()
|
|
21
|
-
if self.isSymbol():
|
|
22
|
-
symbolRecord = self.getSymbolRecord()
|
|
23
|
-
name = symbolRecord['name']
|
|
24
|
-
keyword = symbolRecord['keyword']
|
|
25
|
-
if keyword == 'layout':
|
|
26
|
-
command['args'] = name
|
|
27
|
-
elif keyword in ['column', 'frame', 'tab']:
|
|
28
|
-
command['name'] = name
|
|
29
|
-
command['type'] = token
|
|
30
|
-
if self.peek() == 'to':
|
|
31
|
-
command['args'] = []
|
|
32
|
-
else:
|
|
33
|
-
command['args'] = self.utils.getArgs(self)
|
|
34
|
-
else:
|
|
35
|
-
command['type'] = token
|
|
36
|
-
command['args'] = self.utils.getArgs(self)
|
|
37
|
-
if self.nextIs('to'):
|
|
38
|
-
if self.nextIsSymbol():
|
|
39
|
-
symbolRecord = self.getSymbolRecord()
|
|
40
|
-
if symbolRecord['keyword'] in ['column', 'frame', 'layout', 'tab']:
|
|
41
|
-
command['target'] = symbolRecord['name']
|
|
42
|
-
self.addCommand(command)
|
|
43
|
-
return True
|
|
44
|
-
return False
|
|
45
|
-
|
|
46
|
-
def r_add(self, command):
|
|
47
|
-
target = self.getVariable(command['target'])
|
|
48
|
-
type = command['type']
|
|
49
|
-
args = command['args']
|
|
50
|
-
param= None
|
|
51
|
-
if not 'layout' in target:
|
|
52
|
-
target['layout'] = []
|
|
53
|
-
if args[0] == '{':
|
|
54
|
-
if type in ['Column', 'Frame', 'Tab']:
|
|
55
|
-
record = self.getVariable(command['name'])
|
|
56
|
-
param = record['layout']
|
|
57
|
-
layout = json.loads(self.getRuntimeValue(json.loads(args)))
|
|
58
|
-
default = self.utils.getDefaultArgs(type)
|
|
59
|
-
for n in range(0, len(layout)):
|
|
60
|
-
args = self.utils.decode(default, layout[n])
|
|
61
|
-
item = self.utils.createElement(type, param, args)
|
|
62
|
-
target['layout'].append(item)
|
|
63
|
-
else:
|
|
64
|
-
v = self.getVariable(args)
|
|
65
|
-
target['layout'].append(v['layout'])
|
|
66
|
-
return self.nextPC()
|
|
67
|
-
|
|
68
|
-
def k_capture(self, command):
|
|
69
|
-
if self.nextIs('event'):
|
|
70
|
-
if self.nextIs('as'):
|
|
71
|
-
if self.nextIsSymbol():
|
|
72
|
-
record = self.getSymbolRecord()
|
|
73
|
-
command['target'] = record['name']
|
|
74
|
-
self.addCommand(command)
|
|
75
|
-
return True
|
|
76
|
-
return False
|
|
77
|
-
|
|
78
|
-
def r_capture(self, command):
|
|
79
|
-
target = self.getVariable(command['target'])
|
|
80
|
-
self.putSymbolValue(target, self.getConstant(self.eventValues))
|
|
81
|
-
return self.nextPC()
|
|
82
|
-
|
|
83
|
-
def k_close(self, command):
|
|
84
|
-
if self.nextIsSymbol():
|
|
85
|
-
symbolRecord = self.getSymbolRecord()
|
|
86
|
-
if symbolRecord['keyword'] == 'window':
|
|
87
|
-
command['target'] = symbolRecord['name']
|
|
88
|
-
self.add(command)
|
|
89
|
-
return True
|
|
90
|
-
return False
|
|
91
|
-
|
|
92
|
-
def r_close(self, command):
|
|
93
|
-
target = self.getVariable(command['target'])
|
|
94
|
-
target['window'].close()
|
|
95
|
-
return self.nextPC()
|
|
96
|
-
|
|
97
|
-
def k_column(self, command):
|
|
98
|
-
return self.compileVariable(command)
|
|
99
|
-
|
|
100
|
-
def r_column(self, command):
|
|
101
|
-
return self.nextPC()
|
|
102
|
-
|
|
103
|
-
# create {window} layout {layout}
|
|
104
|
-
# create {element} {args...}
|
|
105
|
-
def k_create(self, command):
|
|
106
|
-
if self.nextIsSymbol():
|
|
107
|
-
symbolRecord = self.getSymbolRecord()
|
|
108
|
-
type = symbolRecord['keyword']
|
|
109
|
-
command['type'] = type
|
|
110
|
-
command['name'] = symbolRecord['name']
|
|
111
|
-
if type == 'window':
|
|
112
|
-
command['title'] = self.nextValue()
|
|
113
|
-
if self.nextIs('layout'):
|
|
114
|
-
if self.nextIsSymbol():
|
|
115
|
-
symbolRecord = self.getSymbolRecord()
|
|
116
|
-
if symbolRecord['keyword'] == 'layout':
|
|
117
|
-
command['layout'] = symbolRecord['name']
|
|
118
|
-
self.addCommand(command)
|
|
119
|
-
return True
|
|
120
|
-
return False
|
|
121
|
-
|
|
122
|
-
def r_create(self, command):
|
|
123
|
-
type = command['type']
|
|
124
|
-
record = self.getVariable(command['name'])
|
|
125
|
-
if type == 'window':
|
|
126
|
-
layout = self.getVariable(command['layout'])
|
|
127
|
-
title = self.getRuntimeValue(command['title'])
|
|
128
|
-
record['window'] = psg.Window(title, layout['layout'], finalize=True)
|
|
129
|
-
record['eventHandlers'] = {}
|
|
130
|
-
self.program.windowRecord = record
|
|
131
|
-
self.program.run(self.nextPC())
|
|
132
|
-
self.mainLoop()
|
|
133
|
-
# self.program.kill()
|
|
134
|
-
return 0
|
|
135
|
-
else:
|
|
136
|
-
RuntimeError(self.program, 'Variable is not a window or an element')
|
|
137
|
-
|
|
138
|
-
def k_init(self, command):
|
|
139
|
-
if self.nextIsSymbol():
|
|
140
|
-
symbolRecord = self.getSymbolRecord()
|
|
141
|
-
if symbolRecord['keyword'] in ['column', 'frame', 'layout', 'tab']:
|
|
142
|
-
command['target'] = symbolRecord['name']
|
|
143
|
-
self.add(command)
|
|
144
|
-
return True
|
|
145
|
-
return False
|
|
146
|
-
|
|
147
|
-
def r_init(self, command):
|
|
148
|
-
target = self.getVariable(command['target'])
|
|
149
|
-
target['layout'] = []
|
|
150
|
-
return self.nextPC()
|
|
151
|
-
|
|
152
|
-
def k_layout(self, command):
|
|
153
|
-
return self.compileVariable(command)
|
|
154
|
-
|
|
155
|
-
def r_layout(self, command):
|
|
156
|
-
return self.nextPC()
|
|
157
|
-
|
|
158
|
-
def k_on(self, command):
|
|
159
|
-
token = self.nextToken()
|
|
160
|
-
if token == 'event':
|
|
161
|
-
command['key'] = self.nextValue()
|
|
162
|
-
if self.nextIs('in'):
|
|
163
|
-
if self.nextIsSymbol():
|
|
164
|
-
record = self.getSymbolRecord()
|
|
165
|
-
if record['keyword'] == 'window':
|
|
166
|
-
command['window'] = record['name']
|
|
167
|
-
command['goto'] = self.getPC() + 2
|
|
168
|
-
self.add(command)
|
|
169
|
-
self.nextToken()
|
|
170
|
-
pcNext = self.getPC()
|
|
171
|
-
cmd = {}
|
|
172
|
-
cmd['domain'] = 'core'
|
|
173
|
-
cmd['lino'] = command['lino']
|
|
174
|
-
cmd['keyword'] = 'gotoPC'
|
|
175
|
-
cmd['goto'] = 0
|
|
176
|
-
cmd['debug'] = False
|
|
177
|
-
self.addCommand(cmd)
|
|
178
|
-
self.compileOne()
|
|
179
|
-
cmd = {}
|
|
180
|
-
cmd['domain'] = 'core'
|
|
181
|
-
cmd['lino'] = command['lino']
|
|
182
|
-
cmd['keyword'] = 'stop'
|
|
183
|
-
cmd['debug'] = False
|
|
184
|
-
self.addCommand(cmd)
|
|
185
|
-
# Fixup the link
|
|
186
|
-
self.getCommandAt(pcNext)['goto'] = self.getPC()
|
|
187
|
-
return True
|
|
188
|
-
return False
|
|
189
|
-
|
|
190
|
-
def r_on(self, command):
|
|
191
|
-
key = self.getRuntimeValue(command['key'])
|
|
192
|
-
window = self.getVariable(command['window'])
|
|
193
|
-
window['eventHandlers'][key] = lambda: self.run(command['goto'])
|
|
194
|
-
return self.nextPC()
|
|
195
|
-
|
|
196
|
-
def k_popup(self, command):
|
|
197
|
-
command['message'] = self.nextValue()
|
|
198
|
-
self.addCommand(command)
|
|
199
|
-
return True
|
|
200
|
-
|
|
201
|
-
def r_popup(self, command):
|
|
202
|
-
psg.popup(self.getRuntimeValue(command['message']))
|
|
203
|
-
return self.nextPC()
|
|
204
|
-
|
|
205
|
-
def k_set(self, command):
|
|
206
|
-
if self.nextIsSymbol():
|
|
207
|
-
record = self.getSymbolRecord()
|
|
208
|
-
keyword = record['keyword']
|
|
209
|
-
if keyword == 'layout':
|
|
210
|
-
command['target'] = record['name']
|
|
211
|
-
if self.peek() == 'to':
|
|
212
|
-
self.nextToken()
|
|
213
|
-
command['type'] = self.nextToken()
|
|
214
|
-
command['args'] = self.utils.getArgs(self)
|
|
215
|
-
else: command['args'] = None
|
|
216
|
-
self.addCommand(command)
|
|
217
|
-
return True
|
|
218
|
-
elif keyword == 'event':
|
|
219
|
-
pass
|
|
220
|
-
return False
|
|
221
|
-
|
|
222
|
-
def r_set(self, command):
|
|
223
|
-
target = self.getVariable(command['target'])
|
|
224
|
-
target['layout'] = []
|
|
225
|
-
type = command['type']
|
|
226
|
-
args = command['args']
|
|
227
|
-
if args != None:
|
|
228
|
-
if args[0] == '{':
|
|
229
|
-
layout = json.loads(self.getRuntimeValue(json.loads(args)))
|
|
230
|
-
default = self.utils.getDefaultArgs(type)
|
|
231
|
-
for n in range(0, len(layout)):
|
|
232
|
-
args = self.utils.decode(default, layout[n])
|
|
233
|
-
target['layout'].append(self.utils.createElement(type, args))
|
|
234
|
-
else:
|
|
235
|
-
v = self.getVariable(args)
|
|
236
|
-
target['layout'].append(v['layout'])
|
|
237
|
-
return self.nextPC()
|
|
238
|
-
|
|
239
|
-
def k_window(self, command):
|
|
240
|
-
return self.compileVariable(command)
|
|
241
|
-
|
|
242
|
-
def r_window(self, command):
|
|
243
|
-
return self.nextPC()
|
|
244
|
-
|
|
245
|
-
#############################################################################
|
|
246
|
-
# Compile a value in this domain
|
|
247
|
-
def compileValue(self):
|
|
248
|
-
value = {}
|
|
249
|
-
value['domain'] = self.getName()
|
|
250
|
-
token = self.getToken()
|
|
251
|
-
if self.isSymbol():
|
|
252
|
-
value['name'] = token
|
|
253
|
-
symbolRecord = self.getSymbolRecord()
|
|
254
|
-
keyword = symbolRecord['keyword']
|
|
255
|
-
if keyword == 'event':
|
|
256
|
-
value['type'] = 'symbol'
|
|
257
|
-
return value
|
|
258
|
-
return None
|
|
259
|
-
|
|
260
|
-
if self.getToken() == 'the':
|
|
261
|
-
self.nextToken()
|
|
262
|
-
|
|
263
|
-
token = self.getToken()
|
|
264
|
-
value['type'] = token
|
|
265
|
-
|
|
266
|
-
if token == 'event':
|
|
267
|
-
return value
|
|
268
|
-
|
|
269
|
-
return None
|
|
270
|
-
|
|
271
|
-
#############################################################################
|
|
272
|
-
# Modify a value or leave it unchanged.
|
|
273
|
-
def modifyValue(self, value):
|
|
274
|
-
return value
|
|
275
|
-
|
|
276
|
-
#############################################################################
|
|
277
|
-
# Value handlers
|
|
278
|
-
|
|
279
|
-
# This is used by the expression evaluator to get the value of a symbol
|
|
280
|
-
def v_symbol(self, symbolRecord):
|
|
281
|
-
if symbolRecord['keyword'] == 'event':
|
|
282
|
-
return self.getSymbolValue(symbolRecord)
|
|
283
|
-
else:
|
|
284
|
-
return None
|
|
285
|
-
|
|
286
|
-
def v_event(self, v):
|
|
287
|
-
v['type'] = 'text'
|
|
288
|
-
v['content'] = self.eventValues
|
|
289
|
-
return v
|
|
290
|
-
|
|
291
|
-
#############################################################################
|
|
292
|
-
# Compile a condition
|
|
293
|
-
def compileCondition(self):
|
|
294
|
-
condition = {}
|
|
295
|
-
return condition
|
|
296
|
-
|
|
297
|
-
#############################################################################
|
|
298
|
-
# Condition handlers
|
|
299
|
-
|
|
300
|
-
#############################################################################
|
|
301
|
-
# The main loop
|
|
302
|
-
def mainLoop(self):
|
|
303
|
-
windowRecord = self.program.windowRecord
|
|
304
|
-
window = windowRecord['window']
|
|
305
|
-
eventHandlers = windowRecord['eventHandlers']
|
|
306
|
-
while True:
|
|
307
|
-
event, values = window.Read(timeout=100)
|
|
308
|
-
if event == psg.WINDOW_CLOSED or event == "EXIT":
|
|
309
|
-
break
|
|
310
|
-
if event == '__TIMEOUT__': self.program.flushCB()
|
|
311
|
-
else:
|
|
312
|
-
if event in eventHandlers:
|
|
313
|
-
self.eventValues = values
|
|
314
|
-
eventHandlers[event]()
|
easycoder/ec_gutils.py
DELETED
|
@@ -1,84 +0,0 @@
|
|
|
1
|
-
import PySimpleGUI as psg
|
|
2
|
-
import json
|
|
3
|
-
|
|
4
|
-
class GUtils:
|
|
5
|
-
|
|
6
|
-
# Parse a set of compile-time arguments
|
|
7
|
-
def getArgs(self, handler):
|
|
8
|
-
args = []
|
|
9
|
-
while True:
|
|
10
|
-
key = handler.nextToken()
|
|
11
|
-
value = json.dumps(handler.nextValue())
|
|
12
|
-
args.append(f'{key}={value}')
|
|
13
|
-
if handler.peek() == 'and':
|
|
14
|
-
handler.nextToken()
|
|
15
|
-
else: break
|
|
16
|
-
v = {}
|
|
17
|
-
v['type'] = 'text'
|
|
18
|
-
v['content'] = json.dumps(args)
|
|
19
|
-
return json.dumps(v)
|
|
20
|
-
|
|
21
|
-
# Get the default args for a graphic element
|
|
22
|
-
def getDefaultArgs(self, type):
|
|
23
|
-
args = {}
|
|
24
|
-
if type == 'Button':
|
|
25
|
-
args['button_text'] = '(empty)'
|
|
26
|
-
args['size'] = (None, None)
|
|
27
|
-
if type == 'Checkbox':
|
|
28
|
-
args['text'] = ''
|
|
29
|
-
args['key'] = None
|
|
30
|
-
args['size'] = (None, None)
|
|
31
|
-
args['expand_x'] = False
|
|
32
|
-
elif type == 'Column':
|
|
33
|
-
args['expand_x'] = False
|
|
34
|
-
args['pad'] = (0, 0)
|
|
35
|
-
elif type == 'Input':
|
|
36
|
-
args['key'] = None
|
|
37
|
-
args['size'] = (None, None)
|
|
38
|
-
elif type == 'Multiline':
|
|
39
|
-
args['default_text'] = ''
|
|
40
|
-
args['key'] = None
|
|
41
|
-
args['size'] = (None, None)
|
|
42
|
-
elif type == 'Text':
|
|
43
|
-
args['text'] = '(empty)'
|
|
44
|
-
args['size'] = (None, None)
|
|
45
|
-
args['expand_x'] = False
|
|
46
|
-
return args
|
|
47
|
-
|
|
48
|
-
# Decode an argument at runtime
|
|
49
|
-
def decode(self, args, text):
|
|
50
|
-
p = text.find('=')
|
|
51
|
-
if p > 0:
|
|
52
|
-
key = text[0:p]
|
|
53
|
-
value = json.loads(text[p+1:])['content']
|
|
54
|
-
args[key] = value
|
|
55
|
-
return args
|
|
56
|
-
return None
|
|
57
|
-
|
|
58
|
-
# Create an element
|
|
59
|
-
def createElement(self, type, param, args):
|
|
60
|
-
if type == 'Button':
|
|
61
|
-
size = self.getSize(args)
|
|
62
|
-
return psg.Button(button_text=args['button_text'], size=size)
|
|
63
|
-
if type == 'Checkbox':
|
|
64
|
-
size = self.getSize(args)
|
|
65
|
-
return psg.Checkbox(args['text'], key=args['key'], expand_x=args['expand_x'], size=size)
|
|
66
|
-
if type == 'Column':
|
|
67
|
-
return psg.Column(param, expand_x=args['expand_x'], pad=args['pad'])
|
|
68
|
-
elif type == 'Input':
|
|
69
|
-
size = self.getSize(args)
|
|
70
|
-
return psg.Input(key=args['key'], size=size)
|
|
71
|
-
elif type == 'Multiline':
|
|
72
|
-
size = self.getSize(args)
|
|
73
|
-
return psg.Multiline(default_text=args['default_text'], key=args['key'], size=size)
|
|
74
|
-
elif type == 'Text':
|
|
75
|
-
size = self.getSize(args)
|
|
76
|
-
return psg.Text(text=args['text'], size=size, expand_x=args['expand_x'])
|
|
77
|
-
else: return None
|
|
78
|
-
|
|
79
|
-
def getSize(self, args):
|
|
80
|
-
size = args['size']
|
|
81
|
-
if size == (None, None):
|
|
82
|
-
return size
|
|
83
|
-
size = size.split()
|
|
84
|
-
return (size[0], size[1])
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
easycoder/README.md,sha256=PYqOc_SkIGiFbyCNs90y7JqoqWe4aO1xYIW-6bOnFKU,573
|
|
2
|
-
easycoder/__init__.py,sha256=eHRjGvRE1Q4gkU7LU7u5U422z1Krs_a2AdY1PHd2sQw,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=t4snx4DPIPvj1sLE7uPCrikGZaLajc5Rsq8M_RJiOIw,86727
|
|
7
|
-
easycoder/ec_graphics.py,sha256=W2IE6vCg5h8HPjxuaJQ4ftqCNnhwAnX5CSaeHi0nEG0,11239
|
|
8
|
-
easycoder/ec_gutils.py,sha256=6vO0yJbWc4sYMp2wR8LAwF4CZc5yqYERFfXUnHnFZxU,2819
|
|
9
|
-
easycoder/ec_handler.py,sha256=IJvxcrJJSR53d6DS_8H5qPHKhp9y5-GV4WXAjhZxu_o,2250
|
|
10
|
-
easycoder/ec_program.py,sha256=wU-vWRWAYK2Ie4EFnp8HeSPUL0bxz-j9HLQSNplObcc,9919
|
|
11
|
-
easycoder/ec_timestamp.py,sha256=_3QFJPzIWZ9Rzk3SQOQJ-gwmvB07pg78k23SPntoZtY,288
|
|
12
|
-
easycoder/ec_value.py,sha256=zgDJTJhIg3yOvmnnKIfccIizmIhGbtvL_ghLTL1T5fg,2516
|
|
13
|
-
easycoder-250118.1.dist-info/entry_points.txt,sha256=JXAZbenl0TnsIft2FcGJbJ-4qoztVu2FuT8PFmWFexM,44
|
|
14
|
-
easycoder-250118.1.dist-info/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
|
|
15
|
-
easycoder-250118.1.dist-info/WHEEL,sha256=Sgu64hAMa6g5FdzHxXv9Xdse9yxpGGMeagVtPMWpJQY,99
|
|
16
|
-
easycoder-250118.1.dist-info/METADATA,sha256=UvUpqmF2I9xQP44f6RKcYtsNPI9Y7eTbd128KE9QMZs,6162
|
|
17
|
-
easycoder-250118.1.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|