Skip to content

Commit 970dcbf

Browse files
committed
250221.1
1 parent 76079c4 commit 970dcbf

File tree

8 files changed

+80
-47
lines changed

8 files changed

+80
-47
lines changed
Binary file not shown.

easycoder/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,4 @@
99
from .ec_timestamp import *
1010
from .ec_value import *
1111

12-
__version__ = "250220.1"
12+
__version__ = "250221.1"

easycoder/ec_core.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1393,8 +1393,8 @@ def k_split(self, command):
13931393
self.nextToken()
13941394
else:
13951395
command['on'] = self.nextValue()
1396-
self.add(command)
1397-
return True
1396+
self.add(command)
1397+
return True
13981398
return False
13991399

14001400
def r_split(self, command):

easycoder/ec_graphics.py

Lines changed: 47 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -98,29 +98,54 @@ def k_column(self, command):
9898
def r_column(self, command):
9999
return self.nextPC()
100100

101+
# create layout {name} from {spec}
101102
# create {window} layout {layout}
102-
# create {element} {args...}
103103
def k_create(self, command):
104-
if self.nextIsSymbol():
104+
token = self.nextToken()
105+
if token == 'layout':
106+
if self.nextIsSymbol():
107+
record = self.getSymbolRecord()
108+
if record['keyword'] == 'layout':
109+
command['layout'] = record['name']
110+
if self.nextIs('from'):
111+
command['spec'] = self.nextValue()
112+
self.addCommand(command)
113+
return True
114+
elif self.isSymbol():
105115
symbolRecord = self.getSymbolRecord()
106-
type = symbolRecord['keyword']
107-
command['type'] = type
108116
command['name'] = symbolRecord['name']
109-
if type == 'window':
110-
command['title'] = self.nextValue()
111-
if self.nextIs('layout'):
112-
if self.nextIsSymbol():
113-
symbolRecord = self.getSymbolRecord()
114-
if symbolRecord['keyword'] == 'layout':
115-
command['layout'] = symbolRecord['name']
116-
self.addCommand(command)
117-
return True
117+
command['title'] = self.nextValue()
118+
if self.nextIs('layout'):
119+
if self.nextIsSymbol():
120+
symbolRecord = self.getSymbolRecord()
121+
if symbolRecord['keyword'] == 'layout':
122+
command['layout'] = symbolRecord['name']
123+
self.addCommand(command)
124+
return True
118125
return False
119126

120127
def r_create(self, command):
121-
type = command['type']
122-
record = self.getVariable(command['name'])
123-
if type == 'window':
128+
def processItem(name, item):
129+
print(name, item['type'])
130+
children = item['#']
131+
if isinstance(children, list):
132+
print("List")
133+
for child in children:
134+
print(child)
135+
else:
136+
print("Single:", children)
137+
138+
if 'spec' in command:
139+
spec = self.getRuntimeValue(command['spec'])
140+
layout = self.getVariable(command['layout'])
141+
for key in spec.keys():
142+
item = spec[key]
143+
print(key, item['type'])
144+
if item['type'] == 'column':
145+
for child in item['#']: processItem(child, item[child])
146+
return self.nextPC()
147+
else:
148+
record = self.getVariable(command['name'])
124149
title = self.getRuntimeValue(command['title'])
125150
layout = self.getVariable(command['layout'])['layout']
126151
window = psg.Window(title, layout, finalize=True)
@@ -130,8 +155,12 @@ def r_create(self, command):
130155
self.program.run(self.nextPC())
131156
self.mainLoop()
132157
return 0
133-
else:
134-
RuntimeError(self.program, 'Variable is not a window or an element')
158+
159+
def k_frame(self, command):
160+
return self.compileVariable(command)
161+
162+
def r_frame(self, command):
163+
return self.nextPC()
135164

136165
def k_init(self, command):
137166
if self.nextIsSymbol():

easycoder/ec_gutils.py

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ def getDefaultArgs(self, type):
2525
if type == 'Button': self.getDefaultButton(args)
2626
elif type == 'Checkbox': self.getDefaultCheckbox(args)
2727
elif type == 'Column': self.getDefaultColumn(args)
28+
elif type == 'Frame': self.getDefaultFrame(args)
2829
elif type == 'Input': self.getDefaultInput(args)
2930
elif type == 'Listbox': self.getDefaultListbox(args)
3031
elif type == 'Multiline': self.getDefaultMultiline(args)
@@ -61,6 +62,7 @@ def createWidget(self, type, layout, args):
6162
if type == 'Button': return self.createButton(layout, args)
6263
elif type == 'Checkbox': return self.createCheckbox(layout, args)
6364
elif type == 'Column': return self.createColumn(layout, args)
65+
elif type == 'Frame': return self.createFrame(layout, args)
6466
elif type == 'Input': return self.createInput(layout, args)
6567
elif type == 'Listbox': return self.createListbox(layout, args)
6668
elif type == 'Multiline': return self.createMultiline(layout, args)
@@ -74,6 +76,7 @@ def getWidgetValue(self, window, key):
7476
if type(widget) is psg.Button: return widget.get()
7577
elif type(widget) is psg.Checkbox: return widget.get()
7678
elif type(widget) is psg.Column: return widget.get()
79+
elif type(widget) is psg.Frame: return widget.get()
7780
elif type(widget) is psg.Input: return widget.get()
7881
elif type(widget) is psg.Listbox:
7982
items = widget.get()
@@ -95,13 +98,6 @@ def updateProperty(self, element, property, value):
9598
elif property == 'values':
9699
element.update(values=value)
97100

98-
def getPad(self, args):
99-
pad = args['pad']
100-
if pad == (None, None):
101-
return pad
102-
pad = pad.split()
103-
return (pad[0], pad[1])
104-
105101
def getSize(self, args):
106102
size = args['size']
107103
if size == (None, None):
@@ -128,10 +124,19 @@ def createCheckbox(self, layout, args):
128124

129125
def getDefaultColumn(self, args):
130126
args['expand_x'] = False
131-
args['pad'] = (None, None)
127+
args['pad'] = (0, 0)
132128

133129
def createColumn(self, layout, args):
134-
return psg.Column(layout, expand_x=args['expand_x'], pad=self.getPad(args))
130+
return psg.Column(layout, expand_x=args['expand_x'], pad=args['pad'])
131+
132+
def getDefaultFrame(self, args):
133+
args['title'] = ''
134+
args['border_width'] = 1
135+
args['expand_x'] = False
136+
args['pad'] = (0, 0)
137+
138+
def createFrame(self, layout, args):
139+
return psg.Frame(args['title'], layout, border_width=args['border_width'], expand_x=args['expand_x'], pad=args['pad'])
135140

136141
def getDefaultInput(self, args):
137142
args['default_text'] = ''
@@ -145,11 +150,11 @@ def getDefaultListbox(self, args):
145150
args['list'] = []
146151
args['key'] = [None]
147152
args['size'] = '10 2'
148-
args['pad'] = (None, None)
153+
args['pad'] = 1
149154
args['select_mode'] = None
150155

151156
def createListbox(self, layout, args):
152-
return psg.Listbox([], key=args['key'], pad=self.getPad(args), size=self.getSize(args))
157+
return psg.Listbox([], key=args['key'], pad=args['pad'], size=self.getSize(args))
153158

154159
def getDefaultMultiline(self, args):
155160
args['default_text'] = ''

scripts/test.ecs

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,3 @@
1-
! A test script
1+
variable X
2+
print X
23

3-
script Test
4-
5-
variable File
6-
variable Segment
7-
8-
set the encoding to `hex`
9-
load File from `/data/Projects/rbr/roombyroom/Controller/home/orangepi/firmware/NOW/config.py`
10-
put left 200 of File into Segment
11-
print Segment
12-
put encode Segment into Segment
13-
print Segment
14-
exit

test.ecs

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,13 @@
1-
variable X
2-
print X
1+
! Test
32

3+
script Test
4+
5+
variable Text
6+
7+
debug step
8+
9+
put `12345jj6789 S Room1` into Text
10+
! split Text on ` `
11+
! index Text to 2
12+
print Text
13+
exit

0 commit comments

Comments
 (0)