Skip to content

Commit 9808a9a

Browse files
committed
250422.3
1 parent 1e9dde5 commit 9808a9a

File tree

2 files changed

+107
-8
lines changed

2 files changed

+107
-8
lines changed

config.ecs

Lines changed: 58 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,14 @@
88
layout MainPanel
99
layout LeftPanel
1010
layout RightPanel
11+
layout DeviceHPanel
1112
layout OuterLayout
1213
layout Layout
1314
groupbox Group
1415
label Label
1516
label MasterDeviceLabel
17+
label RelayStateLabel
18+
label StatusLabel
1619
pushbutton ResetConfigButton
1720
pushbutton ScanNetworkButton
1821
pushbutton SelectMasterButton
@@ -22,6 +25,10 @@
2225
pushbutton DeleteFileButton
2326
pushbutton ExitButton
2427
pushbutton SelectSystemButton
28+
pushbutton SaveHostButton
29+
pushbutton RelayOffButton
30+
pushbutton RelayOnButton
31+
pushbutton SaveWidgetDataButton
2532
lineinput SSIDInput
2633
lineinput PasswordInput
2734
lineinput DeviceNameInput
@@ -31,12 +38,14 @@
3138
lineinput DHT22PinInput
3239
lineinput PathInput
3340
listbox SlaveList
41+
checkbox LEDInvertCheckbox
42+
checkbox RelayInvertCheckbox
3443

3544
! debug step
3645

3746
log `Starting`
3847
init graphics
39-
create Window title `RBR-Now configurator` size 600 500
48+
create Window title `RBR-Now configurator` size 700 500
4049
create MainPanel type QHBoxLayout
4150

4251
create LeftPanel type QVBoxLayout
@@ -69,12 +78,12 @@
6978
add DeleteSlaveButton to LeftPanel
7079
on click DeleteSlaveButton go to DeleteSlave
7180

81+
add stretch to LeftPanel
82+
7283
create ExitButton text `Exit`
7384
add ExitButton to LeftPanel
7485
on click ExitButton go to Exit
7586

76-
add stretch to LeftPanel
77-
7887
create RightPanel type QVBoxLayout
7988
add stretch RightPanel to MainPanel
8089

@@ -104,6 +113,9 @@
104113
add Label to Layout
105114
create PasswordInput size 40
106115
add PasswordInput to Layout
116+
create SaveHostButton text `Save`
117+
on click SaveHostButton go to SaveHostInfo
118+
add SaveHostButton to Layout
107119

108120
! Create the Master Device group
109121
create Group title `Master device`
@@ -128,8 +140,11 @@
128140
set the height of Group to 150
129141
add Group to RightPanel
130142

143+
create DeviceHPanel type QHBoxLayout
144+
add DeviceHPanel to Group
145+
131146
create OuterLayout type QVBoxLayout
132-
add OuterLayout to Group
147+
add OuterLayout to DeviceHPanel
133148

134149
create Layout type QHBoxLayout
135150
add Layout to OuterLayout
@@ -149,6 +164,8 @@
149164
add Label to Layout
150165
create LEDPinInput size 5
151166
add LEDPinInput to Layout
167+
create LEDInvertCheckbox text `Inverted`
168+
add LEDInvertCheckbox to Layout
152169
add stretch to Layout
153170

154171
create Layout type QHBoxLayout
@@ -157,6 +174,16 @@
157174
add Label to Layout
158175
create RelayPinInput size 5
159176
add RelayPinInput to Layout
177+
create RelayInvertCheckbox text `Inverted`
178+
add RelayInvertCheckbox to Layout
179+
create RelayOffButton size 5 text `-`
180+
on click RelayOffButton go to RelayOff
181+
add RelayOffButton to Layout
182+
create RelayOnButton size 5 text `+`
183+
on click RelayOnButton go to RelayOn
184+
add RelayOnButton to Layout
185+
create RelayStateLabel size 5 text `???`
186+
add RelayStateLabel to Layout
160187
add stretch to Layout
161188

162189
create Layout type QHBoxLayout
@@ -174,6 +201,16 @@
174201
create PathInput size 60
175202
add PathInput to Layout
176203
add stretch to Layout
204+
205+
! The 'Save' button
206+
create Layout type QVBoxLayout
207+
add Layout to DeviceHPanel
208+
create SaveWidgetDataButton text `Save`
209+
on click SaveWidgetDataButton go to SaveWidgetData
210+
add SaveWidgetDataButton to Layout
211+
212+
create StatusLabel text `<font color="#00ff00">OK</font>`
213+
add StatusLabel to RightPanel
177214

178215
add stretch to RightPanel
179216

@@ -219,3 +256,20 @@ Exit:
219256
SelectSystem:
220257
log `Select the system`
221258
stop
259+
260+
SaveHostInfo:
261+
log `Save the host information`
262+
stop
263+
264+
SaveWidgetData:
265+
log `Save the widget data`
266+
stop
267+
268+
RelayOff:
269+
log `Turn the relay OFF`
270+
stop
271+
272+
RelayOn:
273+
log `Turn the relay ON`
274+
stop
275+

easycoder/ec_pyside6.py

Lines changed: 49 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,13 @@ def r_add(self, command):
100100
else: layout.addWidget(widget)
101101
return self.nextPC()
102102

103+
# Declare a checkbox variable
104+
def k_checkbox(self, command):
105+
return self.compileVariable(command, False)
106+
107+
def r_checkbox(self, command):
108+
return self.nextPC()
109+
103110
# Close a window
104111
def k_close(self, command):
105112
if self.nextIsSymbol():
@@ -154,15 +161,36 @@ def k_createGroupBox(self, command):
154161
return True
155162

156163
def k_createLabel(self, command):
157-
if self.peek() == 'text':
158-
self.nextToken()
159-
text = self.nextValue()
160-
else: text = ''
164+
text = ''
165+
while True:
166+
token = self.peek()
167+
if token == 'text':
168+
self.nextToken()
169+
text = self.nextValue()
170+
elif token == 'size':
171+
self.nextToken()
172+
command['size'] = self.nextValue()
173+
else: break
161174
command['text'] = text
162175
self.add(command)
163176
return True
164177

165178
def k_createPushbutton(self, command):
179+
text = ''
180+
while True:
181+
token = self.peek()
182+
if token == 'text':
183+
self.nextToken()
184+
text = self.nextValue()
185+
elif token == 'size':
186+
self.nextToken()
187+
command['size'] = self.nextValue()
188+
else: break
189+
command['text'] = text
190+
self.add(command)
191+
return True
192+
193+
def k_createCheckBox(self, command):
166194
if self.peek() == 'text':
167195
self.nextToken()
168196
text = self.nextValue()
@@ -194,6 +222,7 @@ def k_create(self, command):
194222
elif keyword == 'groupbox': return self.k_createGroupBox(command)
195223
elif keyword == 'label': return self.k_createLabel(command)
196224
elif keyword == 'pushbutton': return self.k_createPushbutton(command)
225+
elif keyword == 'checkbox': return self.k_createCheckBox(command)
197226
elif keyword == 'lineinput': return self.k_createLineEdit(command)
198227
elif keyword == 'listbox': return self.k_createListWidget(command)
199228
return False
@@ -227,14 +256,29 @@ def r_createGroupBox(self, command, record):
227256

228257
def r_createLabel(self, command, record):
229258
label = QLabel(self.getRuntimeValue(command['text']))
259+
if 'size' in command:
260+
fm = label.fontMetrics()
261+
c = label.contentsMargins()
262+
w = fm.horizontalAdvance('x') * self.getRuntimeValue(command['size']) +c.left()+c.right()
263+
label.setMaximumWidth(w)
230264
record['widget'] = label
231265
return self.nextPC()
232266

233267
def r_createPushbutton(self, command, record):
234268
pushbutton = QPushButton(self.getRuntimeValue(command['text']))
269+
if 'size' in command:
270+
fm = pushbutton.fontMetrics()
271+
c = pushbutton.contentsMargins()
272+
w = fm.horizontalAdvance('x') * self.getRuntimeValue(command['size']) +c.left()+c.right()
273+
pushbutton.setMaximumWidth(w)
235274
record['widget'] = pushbutton
236275
return self.nextPC()
237276

277+
def r_createCheckBox(self, command, record):
278+
checkbox = QCheckBox(self.getRuntimeValue(command['text']))
279+
record['widget'] = checkbox
280+
return self.nextPC()
281+
238282
def r_createLineEdit(self, command, record):
239283
lineinput = QLineEdit()
240284
fm = lineinput.fontMetrics()
@@ -257,6 +301,7 @@ def r_create(self, command):
257301
elif keyword == 'groupbox': return self.r_createGroupBox(command, record)
258302
elif keyword == 'label': return self.r_createLabel(command, record)
259303
elif keyword == 'pushbutton': return self.r_createPushbutton(command, record)
304+
elif keyword == 'checkbox': return self.r_createCheckBox(command, record)
260305
elif keyword == 'lineinput': return self.r_createLineEdit(command, record)
261306
elif keyword == 'listbox': return self.r_createListWidget(command, record)
262307
return None

0 commit comments

Comments
 (0)