Skip to content

Commit 026ca9a

Browse files
committed
250424.3
1 parent 8fa9611 commit 026ca9a

File tree

5 files changed

+99
-54
lines changed

5 files changed

+99
-54
lines changed

config.ecs

Lines changed: 64 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,15 @@
55
use graphics
66

77
window Window
8-
window Popup
8+
window Dialog
99
layout MainPanel
1010
layout LeftPanel
1111
layout RightPanel
1212
layout DeviceHPanel
1313
layout OuterLayout
1414
layout Layout
15+
layout VLayout
16+
layout HLayout
1517
groupbox Group
1618
label Label
1719
label MasterDeviceLabel
@@ -32,6 +34,9 @@
3234
pushbutton RelayOnButton
3335
pushbutton SaveWidgetDataButton
3436
pushbutton SelectHostButton
37+
pushbutton OKButton
38+
pushbutton CancelButton
39+
lineinput LineInput
3540
lineinput SSIDInput
3641
lineinput PasswordInput
3742
lineinput DeviceNameInput
@@ -44,14 +49,12 @@
4449
combobox SystemsCombo
4550
checkbox LEDInvertCheckbox
4651
checkbox RelayInvertCheckbox
47-
dialog Dialog
4852
messagebox MessageBox
4953

5054
! debug step
5155

5256
log `Starting`
5357
init graphics
54-
create Window title `RBR-Now configurator` size 700 500
5558
create MainPanel type QHBoxLayout
5659

5760
! Do the left-hand panel
@@ -228,23 +231,29 @@
228231

229232
add stretch to RightPanel
230233

231-
show MainPanel in Window
234+
create Window title `RBR-Now configurator` size 700 500 layout MainPanel
235+
show Window
232236

233237
start graphics
234238

235239
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
236240

241+
variable Config
237242
variable Name
238243
variable Value
239-
variable HostSSID
244+
variable ReturnValue
245+
variable Title
240246
variable Result
241247

242-
PopulateForm:
243-
log `Populate the form`
248+
LoadConfigFile:
249+
log `Load the config file`
250+
load Config from `~/.rbr.conf`
251+
if Config is empty put json `{}` into Config
244252
stop
245253

246254
ResetConfigFile:
247255
log `Reset the configuration file`
256+
put json `{}` into Config
248257
stop
249258

250259
ScanNetwork:
@@ -278,7 +287,19 @@ Exit:
278287

279288
ScanSystems:
280289
log `Scan systems`
281-
if SSIDInput is empty gosub to GetHostSSID
290+
if Config does not have property `host-ssid`
291+
begin
292+
put `Enter host SSID` into Title
293+
gosub to GetRequestedText
294+
if Result is `OK` set property `host-ssid` of Config to ReturnValue
295+
if Config does not have property `host-password`
296+
begin
297+
put `Enter host password` into Title
298+
gosub to GetRequestedText
299+
if Result is `OK` set property `host-password` of Config to ReturnValue
300+
end
301+
end
302+
log Config
282303
! create Dialog title `Select a system`
283304
! show Layout in Dialog
284305
stop
@@ -311,20 +332,47 @@ RelayOn:
311332
log `Turn the relay ON`
312333
stop
313334

314-
GetHostSSID:
335+
! Get requested text
336+
GetRequestedText:
337+
create VLayout type QVBoxLayout
338+
create HLayout type QHBoxLayout
339+
add HLayout to VLayout
340+
create LineInput size 40
341+
add stretch LineInput to HLayout
342+
create HLayout type QHBoxLayout
343+
add HLayout to VLayout
344+
create OKButton text `OK` size 6
345+
on click OKButton
346+
begin
347+
put LineInput into ReturnValue
348+
put `OK` into Result
349+
close Dialog
350+
return
351+
end
352+
add OKButton to HLayout
353+
create CancelButton text `Cancel` size 6
354+
on click CancelButton
355+
begin
356+
put `Cancel` into Result
357+
close Dialog
358+
return
359+
end
360+
add CancelButton to HLayout
361+
create Dialog title Title layout VLayout size 300 80
362+
center Dialog on Window
363+
show Dialog
364+
stop
365+
366+
SelectSystemFromList:
315367
create Layout type QVBoxLayout
316368
create SelectHostButton text `Select`
317369
on click SelectHostButton
318370
begin
319371
log `Select Host SSID`
372+
close Dialog
320373
end
321-
on click SelectHostButton close Popup
322374
add stretch to Layout
323375
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
376+
create Dialog title `Host SSID` layout Layout
377+
show Dialog
330378
return
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__ = "250424.2"
12+
__version__ = "250424.3"

easycoder/ec_pyside6.py

Lines changed: 34 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -133,10 +133,6 @@ def r_add(self, command):
133133
else: layout.addWidget(widget)
134134
return self.nextPC()
135135

136-
# Declare a checkbox variable
137-
def k_checkbox(self, command):
138-
return self.compileVariable(command, False)
139-
140136
# Center one window on another
141137
# center {window2} on {window1}
142138
def k_center(self, command):
@@ -158,10 +154,14 @@ def r_center(self, command):
158154
window2 = self.getVariable(command['window2'])['window']
159155
geo1 = window1.geometry()
160156
geo2 = window2.geometry()
161-
geo1.moveCenter(geo2.center())
162-
window1.setGeometry(geo1)
157+
geo2.moveCenter(geo1.center())
158+
window2.setGeometry(geo2)
163159
return self.nextPC()
164160

161+
# Declare a checkbox variable
162+
def k_checkbox(self, command):
163+
return self.compileVariable(command, False)
164+
165165
def r_checkbox(self, command):
166166
return self.nextPC()
167167

@@ -196,18 +196,26 @@ def k_createWindow(self, command):
196196
h = self.compileConstant(480)
197197
while True:
198198
token = self.peek()
199-
if token in ['title', 'at', 'size']:
199+
if token in ['title', 'at', 'size', 'layout']:
200200
self.nextToken()
201201
if token == 'title': command['title'] = self.nextValue()
202202
elif token == 'at':
203203
x = self.nextValue()
204204
y = self.nextValue()
205205
elif token == 'size':
206-
command['w'] = self.nextValue()
207-
command['h'] = self.nextValue()
206+
w = self.nextValue()
207+
h = self.nextValue()
208+
elif token == 'layout':
209+
if self.nextIsSymbol():
210+
record = self.getSymbolRecord()
211+
if record['keyword'] == 'layout':
212+
command['layout'] = record['name']
213+
else: return False
208214
else: break
209215
command['x'] = x
210216
command['y'] = y
217+
command['w'] = w
218+
command['h'] = h
211219
self.add(command)
212220
return True
213221

@@ -360,6 +368,9 @@ def r_createWindow(self, command, record):
360368
if y == None: y = (self.screenHeight - h) / 2
361369
else: y = self.getRuntimeValue(x)
362370
window.setGeometry(x, y, w, h)
371+
container = QWidget()
372+
container.setLayout(self.getVariable(command['layout'])['widget'])
373+
window.setCentralWidget(container)
363374
record['window'] = window
364375
return self.nextPC()
365376

@@ -384,7 +395,7 @@ def r_createLabel(self, command, record):
384395
if 'size' in command:
385396
fm = label.fontMetrics()
386397
c = label.contentsMargins()
387-
w = fm.horizontalAdvance('x') * self.getRuntimeValue(command['size']) +c.left()+c.right()
398+
w = fm.horizontalAdvance('m') * self.getRuntimeValue(command['size']) +c.left()+c.right()
388399
label.setMaximumWidth(w)
389400
record['widget'] = label
390401
return self.nextPC()
@@ -394,7 +405,7 @@ def r_createPushbutton(self, command, record):
394405
if 'size' in command:
395406
fm = pushbutton.fontMetrics()
396407
c = pushbutton.contentsMargins()
397-
w = fm.horizontalAdvance('x') * self.getRuntimeValue(command['size']) +c.left()+c.right()
408+
w = fm.horizontalAdvance('m') * self.getRuntimeValue(command['size']) +c.left()+c.right()
398409
pushbutton.setMaximumWidth(w)
399410
record['widget'] = pushbutton
400411
return self.nextPC()
@@ -644,30 +655,21 @@ def r_set(self, command):
644655
groupbox.setFixedHeight(self.getRuntimeValue(command['value']))
645656
return self.nextPC()
646657

647-
# Show something
648-
# show {name} in {window}
649-
# show {dialog} giving {result}}
658+
# show {window}
659+
# show {dialog}
650660
# show {messagebox} giving {result}}
651661
def k_show(self, command):
652662
if self.nextIsSymbol():
653663
record = self.getSymbolRecord()
654664
keyword = record['keyword']
655-
if keyword == 'layout':
656-
command['layout'] = record['name']
657-
if self.nextIs('in'):
658-
if self.nextIsSymbol():
659-
record = self.getSymbolRecord()
660-
if record['keyword'] == 'window':
661-
command['window'] = record['name']
662-
self.add(command)
663-
return True
665+
if keyword == 'window':
666+
command['window'] = record['name']
667+
self.add(command)
668+
return True
664669
elif keyword == 'dialog':
665670
command['dialog'] = record['name']
666-
if self.nextIs('giving'):
667-
if self.nextIsSymbol():
668-
command['result'] = self.getSymbolRecord()['name']
669-
self.add(command)
670-
return True
671+
self.add(command)
672+
return True
671673
elif keyword == 'messagebox':
672674
command['messagebox'] = record['name']
673675
if self.nextIs('giving'):
@@ -698,17 +700,12 @@ def r_show(self, command):
698700
v['type'] = 'text'
699701
v['content'] = result
700702
self.putSymbolValue(symbolRecord, v)
701-
elif 'dialog' in command:
702-
dialog = self.getVariable(command['dialog'])['dialog']
703-
result = dialog.exec()
704-
print('Result:',result)
705-
else:
706-
layout = self.getVariable(command['layout'])['widget']
703+
elif 'window' in command:
707704
window = self.getVariable(command['window'])['window']
708-
container = QWidget()
709-
container.setLayout(layout)
710-
window.setCentralWidget(container)
711705
window.show()
706+
elif 'dialog' in command:
707+
dialog = self.getVariable(command['dialog'])['dialog']
708+
dialog.exec()
712709
return self.nextPC()
713710

714711
# Start the graphics

0 commit comments

Comments
 (0)