Skip to content

Commit 8fa9611

Browse files
committed
250424.2
1 parent 9126b42 commit 8fa9611

File tree

8 files changed

+180
-109
lines changed

8 files changed

+180
-109
lines changed

config.ecs

Lines changed: 35 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
use graphics
66

77
window Window
8+
window Popup
89
layout MainPanel
910
layout LeftPanel
1011
layout RightPanel
@@ -24,12 +25,13 @@
2425
pushbutton UpdateSlaveButton
2526
pushbutton DeleteFileButton
2627
pushbutton ExitButton
27-
pushbutton AddSystemButton
28+
pushbutton ScanSystemsButton
2829
pushbutton RemoveSystemButton
2930
pushbutton SaveHostButton
3031
pushbutton RelayOffButton
3132
pushbutton RelayOnButton
3233
pushbutton SaveWidgetDataButton
34+
pushbutton SelectHostButton
3335
lineinput SSIDInput
3436
lineinput PasswordInput
3537
lineinput DeviceNameInput
@@ -44,8 +46,6 @@
4446
checkbox RelayInvertCheckbox
4547
dialog Dialog
4648
messagebox MessageBox
47-
variable Name
48-
variable Value
4949

5050
! debug step
5151

@@ -105,9 +105,9 @@
105105
add Layout to Group
106106
create SystemsCombo
107107
add stretch SystemsCombo to Layout
108-
create AddSystemButton text `Add`
109-
on click AddSystemButton go to AddSystem
110-
add AddSystemButton to Layout
108+
create ScanSystemsButton text `Scan`
109+
on click ScanSystemsButton go to ScanSystems
110+
add ScanSystemsButton to Layout
111111
create RemoveSystemButton text `Remove`
112112
disable RemoveSystemButton
113113
on click RemoveSystemButton go to RemoveSystem
@@ -232,12 +232,15 @@
232232

233233
start graphics
234234

235+
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
236+
237+
variable Name
238+
variable Value
239+
variable HostSSID
240+
variable Result
241+
235242
PopulateForm:
236243
log `Populate the form`
237-
add `System 1` to SystemsCombo
238-
add `System 2` to SystemsCombo
239-
add `System 3` to SystemsCombo
240-
if the count of SystemsCombo is not 0 enable RemoveSystemButton
241244
stop
242245

243246
ResetConfigFile:
@@ -273,10 +276,11 @@ Exit:
273276
close Window
274277
exit
275278

276-
AddSystem:
277-
log `Add a system`
278-
create Dialog title `Select system`
279-
show Dialog
279+
ScanSystems:
280+
log `Scan systems`
281+
if SSIDInput is empty gosub to GetHostSSID
282+
! create Dialog title `Select a system`
283+
! show Layout in Dialog
280284
stop
281285

282286
RemoveSystem:
@@ -307,3 +311,20 @@ RelayOn:
307311
log `Turn the relay ON`
308312
stop
309313

314+
GetHostSSID:
315+
create Layout type QVBoxLayout
316+
create SelectHostButton text `Select`
317+
on click SelectHostButton
318+
begin
319+
log `Select Host SSID`
320+
end
321+
on click SelectHostButton close Popup
322+
add stretch to Layout
323+
add SelectHostButton to Layout
324+
create Popup title `Host SSID` size 320 240
325+
center Popup on Window
326+
show Layout in Popup
327+
328+
! create Dialog on Window title `Host SSID` layout Layout
329+
! show Dialog giving Result
330+
return
-37.6 KB
Binary file not shown.
37.8 KB
Binary file not shown.
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__ = "250423.2"
12+
__version__ = "250424.2"

easycoder/ec_core.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -717,7 +717,7 @@ def r_load(self, command):
717717
try:
718718
with open(filename) as f: content = f.read()
719719
except:
720-
RuntimeError(self.program, f'File \'{filename}\' not found')
720+
content = ''
721721
try:
722722
if filename.endswith('.json'): content = json.loads(content)
723723
except:

easycoder/ec_pyside6.py

Lines changed: 95 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,8 @@
3030
QSpacerItem,
3131
QSizePolicy,
3232
QDialog,
33-
QMessageBox
33+
QMessageBox,
34+
QDialogButtonBox
3435
)
3536

3637
class Graphics(Handler):
@@ -136,10 +137,36 @@ def r_add(self, command):
136137
def k_checkbox(self, command):
137138
return self.compileVariable(command, False)
138139

140+
# Center one window on another
141+
# center {window2} on {window1}
142+
def k_center(self, command):
143+
if self.nextIsSymbol():
144+
record = self.getSymbolRecord()
145+
if record['keyword'] == 'window':
146+
command['window2'] = record['name']
147+
if self.nextIs('on'):
148+
if self.nextIsSymbol():
149+
record = self.getSymbolRecord()
150+
if record['keyword'] == 'window':
151+
command['window1'] = record['name']
152+
self.add(command)
153+
return True
154+
return False
155+
156+
def r_center(self, command):
157+
window1 = self.getVariable(command['window1'])['window']
158+
window2 = self.getVariable(command['window2'])['window']
159+
geo1 = window1.geometry()
160+
geo2 = window2.geometry()
161+
geo1.moveCenter(geo2.center())
162+
window1.setGeometry(geo1)
163+
return self.nextPC()
164+
139165
def r_checkbox(self, command):
140166
return self.nextPC()
141167

142168
# Close a window
169+
# close {window}
143170
def k_close(self, command):
144171
if self.nextIsSymbol():
145172
record = self.getSymbolRecord()
@@ -165,8 +192,8 @@ def k_createWindow(self, command):
165192
command['title'] = 'Default'
166193
x = None
167194
y = None
168-
w = 640
169-
h = 480
195+
w = self.compileConstant(640)
196+
h = self.compileConstant(480)
170197
while True:
171198
token = self.peek()
172199
if token in ['title', 'at', 'size']:
@@ -179,8 +206,6 @@ def k_createWindow(self, command):
179206
command['w'] = self.nextValue()
180207
command['h'] = self.nextValue()
181208
else: break
182-
command['w'] = self.compileConstant(w)
183-
command['h'] = self.compileConstant(h)
184209
command['x'] = x
185210
command['y'] = y
186211
self.add(command)
@@ -260,38 +285,50 @@ def k_createComboBox(self, command):
260285
return True
261286

262287
def k_createDialog(self, command):
263-
if self.peek() == 'title':
288+
if self.peek() == 'on':
264289
self.nextToken()
265-
title = self.nextValue()
266-
else: title = ''
290+
if self.nextIsSymbol():
291+
command['window'] = self.getSymbolRecord()['name']
292+
else: command['window'] = None
293+
title = ''
294+
while True:
295+
if self.peek() == 'title':
296+
self.nextToken()
297+
title = self.nextValue()
298+
elif self.peek() == 'layout':
299+
self.nextToken()
300+
if self.nextIsSymbol():
301+
command['layout'] = self.getSymbolRecord()['name']
302+
else: break
267303
command['title'] = title
268304
self.add(command)
269305
return True
270306

271307
def k_createMessageBox(self, command):
272-
if self.nextIs('on'):
308+
if self.peek() == 'on':
309+
self.nextToken()
273310
if self.nextIsSymbol():
274311
command['window'] = self.getSymbolRecord()['name']
275-
style = 'question'
276-
title = ''
277-
message = ''
278-
while True:
279-
if self.peek() == 'style':
280-
self.nextToken()
281-
style = self.nextToken()
282-
elif self.peek() == 'title':
283-
self.nextToken()
284-
title = self.nextValue()
285-
elif self.peek() == 'message':
286-
self.nextToken()
287-
message = self.nextValue()
288-
else: break
289-
command['style'] = style
290-
command['title'] = title
291-
command['message'] = message
292-
self.add(command)
293-
return True
294-
return False
312+
else: command['window'] = None
313+
style = 'question'
314+
title = ''
315+
message = ''
316+
while True:
317+
if self.peek() == 'style':
318+
self.nextToken()
319+
style = self.nextToken()
320+
elif self.peek() == 'title':
321+
self.nextToken()
322+
title = self.nextValue()
323+
elif self.peek() == 'message':
324+
self.nextToken()
325+
message = self.nextValue()
326+
else: break
327+
command['style'] = style
328+
command['title'] = title
329+
command['message'] = message
330+
self.add(command)
331+
return True
295332

296333
def k_create(self, command):
297334
if self.nextIsSymbol():
@@ -386,8 +423,14 @@ def r_createComboBox(self, command, record):
386423
return self.nextPC()
387424

388425
def r_createDialog(self, command, record):
426+
layout = self.getVariable(command['layout'])['widget']
389427
dialog = QDialog()
390428
dialog.setWindowTitle(self.getRuntimeValue(command['title']))
429+
dialog.buttonBox = QDialogButtonBox((QDialogButtonBox.Ok | QDialogButtonBox.Cancel))
430+
dialog.buttonBox.accepted.connect(dialog.accept)
431+
dialog.buttonBox.rejected.connect(dialog.reject)
432+
layout.addWidget(dialog.buttonBox)
433+
dialog.setLayout(layout)
391434
record['dialog'] = dialog
392435
return self.nextPC()
393436

@@ -602,8 +645,9 @@ def r_set(self, command):
602645
return self.nextPC()
603646

604647
# Show something
605-
# show {name} in {window}}
606-
# show {dialog}/{messagebox}
648+
# show {name} in {window}
649+
# show {dialog} giving {result}}
650+
# show {messagebox} giving {result}}
607651
def k_show(self, command):
608652
if self.nextIsSymbol():
609653
record = self.getSymbolRecord()
@@ -619,8 +663,11 @@ def k_show(self, command):
619663
return True
620664
elif keyword == 'dialog':
621665
command['dialog'] = record['name']
622-
self.add(command)
623-
return True
666+
if self.nextIs('giving'):
667+
if self.nextIsSymbol():
668+
command['result'] = self.getSymbolRecord()['name']
669+
self.add(command)
670+
return True
624671
elif keyword == 'messagebox':
625672
command['messagebox'] = record['name']
626673
if self.nextIs('giving'):
@@ -631,13 +678,7 @@ def k_show(self, command):
631678
return False
632679

633680
def r_show(self, command):
634-
if 'dialog' in command:
635-
dialog = self.getVariable(command['dialog'])['dialog']
636-
b1 = QPushButton("ok",dialog)
637-
b1.move(50,50)
638-
dialog.setWindowModality(Qt.ApplicationModal)
639-
dialog.exec_()
640-
elif 'messagebox' in command:
681+
if 'messagebox' in command:
641682
data = self.getVariable(command['messagebox'])['data']
642683
symbolRecord = self.getVariable(command['result'])
643684
window = self.getVariable(data['window'])['window']
@@ -657,12 +698,15 @@ def r_show(self, command):
657698
v['type'] = 'text'
658699
v['content'] = result
659700
self.putSymbolValue(symbolRecord, v)
701+
elif 'dialog' in command:
702+
dialog = self.getVariable(command['dialog'])['dialog']
703+
result = dialog.exec()
704+
print('Result:',result)
660705
else:
661-
layoutRecord = self.getVariable(command['layout'])
662-
windowRecord = self.getVariable(command['window'])
663-
window = windowRecord['window']
706+
layout = self.getVariable(command['layout'])['widget']
707+
window = self.getVariable(command['window'])['window']
664708
container = QWidget()
665-
container.setLayout(layoutRecord['widget'])
709+
container.setLayout(layout)
666710
window.setCentralWidget(container)
667711
window.show()
668712
return self.nextPC()
@@ -734,7 +778,13 @@ def modifyValue(self, value):
734778
def v_symbol(self, symbolRecord):
735779
symbolRecord = self.getVariable(symbolRecord['name'])
736780
keyword = symbolRecord['keyword']
737-
if keyword == 'combobox':
781+
if keyword == 'lineinput':
782+
lineinput = symbolRecord['widget']
783+
v = {}
784+
v['type'] = 'text'
785+
v['content'] = lineinput.displayText()
786+
return v
787+
elif keyword == 'combobox':
738788
combobox = symbolRecord['widget']
739789
v = {}
740790
v['type'] = 'text'

0 commit comments

Comments
 (0)