easycoder 250422.3__py2.py3-none-any.whl → 250423.2__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.

Potentially problematic release.


This version of easycoder might be problematic. Click here for more details.

easycoder/__init__.py CHANGED
@@ -9,4 +9,4 @@ from .ec_program import *
9
9
  from .ec_timestamp import *
10
10
  from .ec_value import *
11
11
 
12
- __version__ = "250422.3"
12
+ __version__ = "250423.2"
easycoder/ec_compiler.py CHANGED
@@ -114,10 +114,10 @@ class Compiler:
114
114
  def compileLabel(self, command):
115
115
  return self.compileSymbol(command, self.getToken(), False)
116
116
 
117
- def compileVariable(self, command, valueHolder = False):
118
- return self.compileSymbol(command, self.nextToken(), valueHolder)
117
+ def compileVariable(self, command, hasValue = False):
118
+ return self.compileSymbol(command, self.nextToken(), hasValue)
119
119
 
120
- def compileSymbol(self, command, name, valueHolder):
120
+ def compileSymbol(self, command, name, hasValue):
121
121
  try:
122
122
  v = self.symbols[name]
123
123
  except:
@@ -128,7 +128,7 @@ class Compiler:
128
128
  self.symbols[name] = self.getPC()
129
129
  command['program'] = self.program
130
130
  command['type'] = 'symbol'
131
- command['valueHolder'] = valueHolder
131
+ command['hasValue'] = hasValue
132
132
  command['name'] = name
133
133
  command['elements'] = 1
134
134
  command['index'] = 0
easycoder/ec_core.py CHANGED
@@ -26,7 +26,7 @@ class Core(Handler):
26
26
  if self.nextToken() == 'to':
27
27
  if self.nextIsSymbol():
28
28
  symbolRecord = self.getSymbolRecord()
29
- if symbolRecord['valueHolder']:
29
+ if symbolRecord['hasValue']:
30
30
  if self.peek() == 'giving':
31
31
  # This variable must be treated as a second value
32
32
  command['value2'] = self.getValue()
@@ -57,7 +57,7 @@ class Core(Handler):
57
57
  except:
58
58
  value2 = None
59
59
  target = self.getVariable(command['target'])
60
- if not target['valueHolder']:
60
+ if not target['hasValue']:
61
61
  self.variableDoesNotHoldAValueError(target['name'])
62
62
  targetValue = self.getSymbolValue(target)
63
63
  if targetValue == None:
@@ -87,7 +87,7 @@ class Core(Handler):
87
87
  if self.nextIs('to'):
88
88
  if self.nextIsSymbol():
89
89
  symbolRecord = self.getSymbolRecord()
90
- if symbolRecord['valueHolder']:
90
+ if symbolRecord['hasValue']:
91
91
  command['target'] = symbolRecord['name']
92
92
  self.add(command)
93
93
  return True
@@ -149,7 +149,7 @@ class Core(Handler):
149
149
  def k_clear(self, command):
150
150
  if self.nextIsSymbol():
151
151
  target = self.getSymbolRecord()
152
- if target['valueHolder']:
152
+ if target['hasValue']:
153
153
  command['target'] = target['name']
154
154
  self.add(command)
155
155
  return True
@@ -245,7 +245,7 @@ class Core(Handler):
245
245
  def k_decrement(self, command):
246
246
  if self.nextIsSymbol():
247
247
  symbolRecord = self.getSymbolRecord()
248
- if symbolRecord['valueHolder']:
248
+ if symbolRecord['hasValue']:
249
249
  command['target'] = self.getToken()
250
250
  self.add(command)
251
251
  return True
@@ -325,7 +325,7 @@ class Core(Handler):
325
325
  except:
326
326
  value2 = None
327
327
  target = self.getVariable(command['target'])
328
- if not target['valueHolder']:
328
+ if not target['hasValue']:
329
329
  self.variableDoesNotHoldAValueError(target['name'])
330
330
  return None
331
331
  value = self.getSymbolValue(target)
@@ -400,7 +400,7 @@ class Core(Handler):
400
400
  def k_get(self, command):
401
401
  if self.nextIsSymbol():
402
402
  symbolRecord = self.getSymbolRecord()
403
- if symbolRecord['valueHolder']:
403
+ if symbolRecord['hasValue']:
404
404
  command['target'] = self.getToken()
405
405
  else:
406
406
  FatalError(self.compiler, f'Variable "{symbolRecord["name"]}" does not hold a value')
@@ -610,7 +610,7 @@ class Core(Handler):
610
610
  def k_increment(self, command):
611
611
  if self.nextIsSymbol():
612
612
  symbolRecord = self.getSymbolRecord()
613
- if symbolRecord['valueHolder']:
613
+ if symbolRecord['hasValue']:
614
614
  command['target'] = self.getToken()
615
615
  self.add(command)
616
616
  return True
@@ -701,7 +701,7 @@ class Core(Handler):
701
701
  return True
702
702
  elif self.isSymbol():
703
703
  symbolRecord = self.getSymbolRecord()
704
- if symbolRecord['valueHolder']:
704
+ if symbolRecord['hasValue']:
705
705
  command['target'] = symbolRecord['name']
706
706
  if self.nextIs('from'):
707
707
  command['file'] = self.nextValue()
@@ -785,7 +785,7 @@ class Core(Handler):
785
785
  except:
786
786
  value2 = None
787
787
  target = self.getVariable(command['target'])
788
- if not target['valueHolder']:
788
+ if not target['hasValue']:
789
789
  self.variableDoesNotHoldAValueError(target['name'])
790
790
  return None
791
791
  value = self.getSymbolValue(target)
@@ -810,7 +810,7 @@ class Core(Handler):
810
810
  def k_negate(self, command):
811
811
  if self.nextIsSymbol():
812
812
  symbolRecord = self.getSymbolRecord()
813
- if symbolRecord['valueHolder']:
813
+ if symbolRecord['hasValue']:
814
814
  command['target'] = self.getToken()
815
815
  self.add(command)
816
816
  return True
@@ -819,7 +819,7 @@ class Core(Handler):
819
819
 
820
820
  def r_negate(self, command):
821
821
  symbolRecord = self.getVariable(command['target'])
822
- if not symbolRecord['valueHolder']:
822
+ if not symbolRecord['hasValue']:
823
823
  RuntimeError(self.program, f'{symbolRecord["name"]} does not hold a value')
824
824
  return None
825
825
  value = self.getSymbolValue(symbolRecord)
@@ -921,7 +921,7 @@ class Core(Handler):
921
921
 
922
922
  def r_pop(self, command):
923
923
  symbolRecord = self.getVariable(command['target'])
924
- if not symbolRecord['valueHolder']:
924
+ if not symbolRecord['hasValue']:
925
925
  RuntimeError(self.program, f'{symbolRecord["name"]} does not hold a value')
926
926
  stackRecord = self.getVariable(command['from'])
927
927
  stack = self.getSymbolValue(stackRecord)
@@ -1060,7 +1060,7 @@ class Core(Handler):
1060
1060
  if self.nextIsSymbol():
1061
1061
  symbolRecord = self.getSymbolRecord()
1062
1062
  command['target'] = symbolRecord['name']
1063
- if 'valueholder' in symbolRecord and symbolRecord['valueHolder'] == False:
1063
+ if 'hasValue' in symbolRecord and symbolRecord['hasValue'] == False:
1064
1064
  FatalError(self.compiler, f'Symbol {symbolRecord["name"]} is not a value holder')
1065
1065
  else:
1066
1066
  self.add(command)
@@ -1074,7 +1074,7 @@ class Core(Handler):
1074
1074
  if value == None:
1075
1075
  return -1
1076
1076
  symbolRecord = self.getVariable(command['target'])
1077
- if not symbolRecord['valueHolder']:
1077
+ if not symbolRecord['hasValue']:
1078
1078
  RuntimeError(self.program, f'{symbolRecord["name"]} does not hold a value')
1079
1079
  return -1
1080
1080
  self.putSymbolValue(symbolRecord, value)
@@ -1090,7 +1090,7 @@ class Core(Handler):
1090
1090
  command['line'] = False
1091
1091
  if self.nextIsSymbol():
1092
1092
  symbolRecord = self.getSymbolRecord()
1093
- if symbolRecord['valueHolder']:
1093
+ if symbolRecord['hasValue']:
1094
1094
  if self.peek() == 'from':
1095
1095
  self.nextToken()
1096
1096
  if self.nextIsSymbol():
@@ -1259,7 +1259,7 @@ class Core(Handler):
1259
1259
  def k_set(self, command):
1260
1260
  if self.nextIsSymbol():
1261
1261
  target = self.getSymbolRecord()
1262
- if target['valueHolder']:
1262
+ if target['hasValue']:
1263
1263
  command['type'] = 'set'
1264
1264
  command['target'] = target['name']
1265
1265
  self.add(command)
@@ -1384,7 +1384,7 @@ class Core(Handler):
1384
1384
  def k_split(self, command):
1385
1385
  if self.nextIsSymbol():
1386
1386
  symbolRecord = self.getSymbolRecord()
1387
- if symbolRecord['valueHolder']:
1387
+ if symbolRecord['hasValue']:
1388
1388
  command['target'] = symbolRecord['name']
1389
1389
  value = {}
1390
1390
  value['type'] = 'text'
@@ -1423,7 +1423,7 @@ class Core(Handler):
1423
1423
  def k_shuffle(self, command):
1424
1424
  if self.nextIsSymbol():
1425
1425
  symbolRecord = self.getSymbolRecord()
1426
- if symbolRecord['valueHolder']:
1426
+ if symbolRecord['hasValue']:
1427
1427
  command['target'] = self.getToken()
1428
1428
  self.add(command)
1429
1429
  return True
@@ -1432,7 +1432,7 @@ class Core(Handler):
1432
1432
 
1433
1433
  def r_shuffle(self, command):
1434
1434
  symbolRecord = self.getVariable(command['target'])
1435
- if not symbolRecord['valueHolder']:
1435
+ if not symbolRecord['hasValue']:
1436
1436
  RuntimeError(self.program, f'{symbolRecord["name"]} does not hold a value')
1437
1437
  return None
1438
1438
  value = self.getSymbolValue(symbolRecord)
@@ -1495,7 +1495,7 @@ class Core(Handler):
1495
1495
  if self.nextToken() == 'from':
1496
1496
  if self.nextIsSymbol():
1497
1497
  symbolRecord = self.getSymbolRecord()
1498
- if symbolRecord['valueHolder']:
1498
+ if symbolRecord['hasValue']:
1499
1499
  if self.peek() == 'giving':
1500
1500
  # This variable must be treated as a second value
1501
1501
  command['value2'] = self.getValue()
@@ -1530,7 +1530,7 @@ class Core(Handler):
1530
1530
  except:
1531
1531
  value2 = None
1532
1532
  target = self.getVariable(command['target'])
1533
- if not target['valueHolder']:
1533
+ if not target['hasValue']:
1534
1534
  self.variableDoesNotHoldAValueError(target['name'])
1535
1535
  return None
1536
1536
  value = self.getSymbolValue(target)
@@ -1552,7 +1552,7 @@ class Core(Handler):
1552
1552
  def k_toggle(self, command):
1553
1553
  if self.nextIsSymbol():
1554
1554
  target = self.getSymbolRecord()
1555
- if target['valueHolder']:
1555
+ if target['hasValue']:
1556
1556
  command['target'] = target['name']
1557
1557
  self.add(command)
1558
1558
  return True
@@ -1712,7 +1712,7 @@ class Core(Handler):
1712
1712
 
1713
1713
  def incdec(self, command, mode):
1714
1714
  symbolRecord = self.getVariable(command['target'])
1715
- if not symbolRecord['valueHolder']:
1715
+ if not symbolRecord['hasValue']:
1716
1716
  RuntimeError(self.program, f'{symbolRecord["name"]} does not hold a value')
1717
1717
  return None
1718
1718
  value = self.getSymbolValue(symbolRecord)
@@ -1781,7 +1781,7 @@ class Core(Handler):
1781
1781
  if self.nextToken() == 'of':
1782
1782
  if self.nextIsSymbol():
1783
1783
  symbolRecord = self.getSymbolRecord()
1784
- if symbolRecord['valueHolder']:
1784
+ if symbolRecord['hasValue']:
1785
1785
  value['target'] = symbolRecord['name']
1786
1786
  return value
1787
1787
  self.warning(f'Core.compileValue: Token \'{self.getToken()}\' does not hold a value')
@@ -1792,7 +1792,7 @@ class Core(Handler):
1792
1792
  if self.nextToken() == 'of':
1793
1793
  if self.nextIsSymbol():
1794
1794
  symbolRecord = self.getSymbolRecord()
1795
- if symbolRecord['valueHolder']:
1795
+ if symbolRecord['hasValue']:
1796
1796
  value['target'] = symbolRecord['name']
1797
1797
  return value
1798
1798
  FatalError(self.compiler, 'Variable does not hold a value')
@@ -1838,8 +1838,9 @@ class Core(Handler):
1838
1838
  if token == 'count':
1839
1839
  if self.nextIs('of'):
1840
1840
  if self.nextIsSymbol():
1841
- value['name'] = self.getToken()
1842
- return value
1841
+ if self.getSymbolRecord()['hasValue']:
1842
+ value['name'] = self.getToken()
1843
+ return value
1843
1844
  return None
1844
1845
 
1845
1846
  if token == 'index':
easycoder/ec_graphics.py CHANGED
@@ -165,11 +165,11 @@ class Graphics(Handler):
165
165
  def k_get(self, command):
166
166
  if self.nextIsSymbol():
167
167
  symbolRecord = self.getSymbolRecord()
168
- if symbolRecord['valueHolder']:
168
+ if symbolRecord['hasValue']:
169
169
  command['target'] = self.getToken()
170
170
  else:
171
171
  FatalError(self.compiler, f'Variable "{symbolRecord["name"]}" does not hold a value')
172
- if symbolRecord['valueHolder']:
172
+ if symbolRecord['hasValue']:
173
173
  if self.nextIs('from'):
174
174
  if self.nextIs('popup'):
175
175
  command['ptype'] = self.nextToken()
easycoder/ec_program.py CHANGED
@@ -149,7 +149,7 @@ class Program:
149
149
  elif valType == 'symbol':
150
150
  name = value['name']
151
151
  symbolRecord = self.getSymbolRecord(name)
152
- if symbolRecord['valueHolder']:
152
+ if symbolRecord['hasValue']:
153
153
  handler = self.domainIndex[symbolRecord['domain']].valueHandler('symbol')
154
154
  result = handler(symbolRecord)
155
155
  else:
easycoder/ec_pyside6.py CHANGED
@@ -28,7 +28,9 @@ from PySide6.QtWidgets import (
28
28
  QGroupBox,
29
29
  QWidget,
30
30
  QSpacerItem,
31
- QSizePolicy
31
+ QSizePolicy,
32
+ QDialog,
33
+ QMessageBox
32
34
  )
33
35
 
34
36
  class Graphics(Handler):
@@ -42,7 +44,7 @@ class Graphics(Handler):
42
44
  Handler.__init__(self, compiler)
43
45
 
44
46
  def getName(self):
45
- return 'pyside6'
47
+ return 'graphics'
46
48
 
47
49
  def closeEvent(self):
48
50
  print('window closed')
@@ -50,54 +52,84 @@ class Graphics(Handler):
50
52
  #############################################################################
51
53
  # Keyword handlers
52
54
 
53
- # Add a widget to a layout
54
- # add [stretch] {widget} to {layout}
55
- # add stretch to {layout}
55
+ # (1) add {value} to {widget}
56
+ # (2) add {widget} to {layout}
57
+ # (3) add stretch {widget} to {layout}
58
+ # (4) add stretch to {layout}
56
59
  def k_add(self, command):
60
+ def addToLayout():
61
+ if self.nextIsSymbol():
62
+ record = self.getSymbolRecord()
63
+ command['layout'] = record['name']
64
+ self.add(command)
65
+ return True
66
+ return False
67
+
57
68
  command['stretch'] = False
58
69
  if self.nextIs('stretch'):
59
- if self.peek() == 'to':
70
+ # It's either (3) or (4)
71
+ self.nextToken()
72
+ if self.tokenIs('to'):
73
+ # (4)
60
74
  command['widget'] = 'stretch'
61
- elif self.nextIsSymbol():
75
+ return addToLayout()
76
+ # (3)
77
+ if self.isSymbol():
62
78
  record = self.getSymbolRecord()
63
79
  command['widget'] = record['name']
64
80
  command['stretch'] = True
65
- else: return False
81
+ if self.nextIs('to'):
82
+ return addToLayout()
83
+ return False
84
+
85
+ # Here it's either (1) or (2)
66
86
  elif self.isSymbol():
67
- record = self.getSymbolRecord()
68
- command['widget'] = record['name']
69
- else: return False
70
- if self.nextIs('to'):
71
- if self.nextIsSymbol():
87
+ if self.peek() == 'to':
88
+ # (2)
72
89
  record = self.getSymbolRecord()
73
- command['layout'] = record['name']
74
- self.add(command)
75
- return True
90
+ command['widget'] = record['name']
91
+ self.nextToken()
92
+ return addToLayout()
93
+ else:
94
+ # (1)
95
+ command['value'] = self.getValue()
96
+ if self.nextIs('to'):
97
+ if self.nextIsSymbol():
98
+ record = self.getSymbolRecord()
99
+ command['widget'] = record['name']
100
+ self.add(command)
101
+ return True
76
102
  return False
77
103
 
78
104
  def r_add(self, command):
79
- layoutRecord = self.getVariable(command['layout'])
80
- widget = command['widget']
81
- if widget == 'stretch':
82
- layoutRecord['widget'].addStretch()
105
+ if 'value' in command:
106
+ value = self.getRuntimeValue(command['value'])
107
+ widget = self.getVariable(command['widget'])
108
+ if widget['keyword'] == 'combobox':
109
+ widget['widget'].addItem(value)
83
110
  else:
84
- widgetRecord = self.getVariable(widget)
85
111
  layoutRecord = self.getVariable(command['layout'])
86
- widget = widgetRecord['widget']
87
- layout = layoutRecord['widget']
88
- stretch = command['stretch']
89
- if widgetRecord['keyword'] == 'layout':
90
- if layoutRecord['keyword'] == 'groupbox':
91
- if widgetRecord['keyword'] == 'layout':
92
- layout.setLayout(widget)
112
+ widget = command['widget']
113
+ if widget == 'stretch':
114
+ layoutRecord['widget'].addStretch()
115
+ else:
116
+ widgetRecord = self.getVariable(widget)
117
+ layoutRecord = self.getVariable(command['layout'])
118
+ widget = widgetRecord['widget']
119
+ layout = layoutRecord['widget']
120
+ stretch = command['stretch']
121
+ if widgetRecord['keyword'] == 'layout':
122
+ if layoutRecord['keyword'] == 'groupbox':
123
+ if widgetRecord['keyword'] == 'layout':
124
+ layout.setLayout(widget)
125
+ else:
126
+ RuntimeError(self.program, 'Can only add a layout to a groupbox')
93
127
  else:
94
- RuntimeError(self.program, 'Can only add a layout to a groupbox')
128
+ if stretch: layout.addLayout(widget, stretch=1)
129
+ else: layout.addLayout(widget)
95
130
  else:
96
- if stretch: layout.addLayout(widget, stretch=1)
97
- else: layout.addLayout(widget)
98
- else:
99
- if stretch: layout.addWidget(widget, stretch=1)
100
- else: layout.addWidget(widget)
131
+ if stretch: layout.addWidget(widget, stretch=1)
132
+ else: layout.addWidget(widget)
101
133
  return self.nextPC()
102
134
 
103
135
  # Declare a checkbox variable
@@ -121,25 +153,36 @@ class Graphics(Handler):
121
153
  self.getVariable(command['name'])['window'].close()
122
154
  return self.nextPC()
123
155
 
156
+ # Declare a combobox variable
157
+ def k_combobox(self, command):
158
+ return self.compileVariable(command, False)
159
+
160
+ def r_combobox(self, command):
161
+ return self.nextPC()
162
+
124
163
  # Create a window
125
164
  def k_createWindow(self, command):
126
165
  command['title'] = 'Default'
127
- command['x'] = self.compileConstant(100)
128
- command['y'] = self.compileConstant(100)
129
- command['w'] = self.compileConstant(640)
130
- command['h'] = self.compileConstant(480)
166
+ x = None
167
+ y = None
168
+ w = 640
169
+ h = 480
131
170
  while True:
132
171
  token = self.peek()
133
172
  if token in ['title', 'at', 'size']:
134
173
  self.nextToken()
135
174
  if token == 'title': command['title'] = self.nextValue()
136
175
  elif token == 'at':
137
- command['x'] = self.nextValue()
138
- command['y'] = self.nextValue()
176
+ x = self.nextValue()
177
+ y = self.nextValue()
139
178
  elif token == 'size':
140
179
  command['w'] = self.nextValue()
141
180
  command['h'] = self.nextValue()
142
181
  else: break
182
+ command['w'] = self.compileConstant(w)
183
+ command['h'] = self.compileConstant(h)
184
+ command['x'] = x
185
+ command['y'] = y
143
186
  self.add(command)
144
187
  return True
145
188
 
@@ -212,6 +255,44 @@ class Graphics(Handler):
212
255
  self.add(command)
213
256
  return True
214
257
 
258
+ def k_createComboBox(self, command):
259
+ self.add(command)
260
+ return True
261
+
262
+ def k_createDialog(self, command):
263
+ if self.peek() == 'title':
264
+ self.nextToken()
265
+ title = self.nextValue()
266
+ else: title = ''
267
+ command['title'] = title
268
+ self.add(command)
269
+ return True
270
+
271
+ def k_createMessageBox(self, command):
272
+ if self.nextIs('on'):
273
+ if self.nextIsSymbol():
274
+ 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
295
+
215
296
  def k_create(self, command):
216
297
  if self.nextIsSymbol():
217
298
  record = self.getSymbolRecord()
@@ -225,15 +306,22 @@ class Graphics(Handler):
225
306
  elif keyword == 'checkbox': return self.k_createCheckBox(command)
226
307
  elif keyword == 'lineinput': return self.k_createLineEdit(command)
227
308
  elif keyword == 'listbox': return self.k_createListWidget(command)
309
+ elif keyword == 'combobox': return self.k_createComboBox(command)
310
+ elif keyword == 'dialog': return self.k_createDialog(command)
311
+ elif keyword == 'messagebox': return self.k_createMessageBox(command)
228
312
  return False
229
313
 
230
314
  def r_createWindow(self, command, record):
231
315
  window = self.MainWindow()
232
316
  window.setWindowTitle(self.getRuntimeValue(command['title']))
233
- x = self.getRuntimeValue(command['x'])
234
- y = self.getRuntimeValue(command['y'])
235
317
  w = self.getRuntimeValue(command['w'])
236
318
  h = self.getRuntimeValue(command['h'])
319
+ x = command['x']
320
+ y = command['y']
321
+ if x == None: x = (self.screenWidth - w) / 2
322
+ else: x = self.getRuntimeValue(x)
323
+ if y == None: y = (self.screenHeight - h) / 2
324
+ else: y = self.getRuntimeValue(x)
237
325
  window.setGeometry(x, y, w, h)
238
326
  record['window'] = window
239
327
  return self.nextPC()
@@ -292,6 +380,26 @@ class Graphics(Handler):
292
380
  def r_createListWidget(self, command, record):
293
381
  record['widget'] = QListWidget()
294
382
  return self.nextPC()
383
+
384
+ def r_createComboBox(self, command, record):
385
+ record['widget'] = QComboBox()
386
+ return self.nextPC()
387
+
388
+ def r_createDialog(self, command, record):
389
+ dialog = QDialog()
390
+ dialog.setWindowTitle(self.getRuntimeValue(command['title']))
391
+ record['dialog'] = dialog
392
+ return self.nextPC()
393
+
394
+ # Creates a message box but doesn'r run it
395
+ def r_createMessageBox(self, command, record):
396
+ data = {}
397
+ data['window'] = command['window']
398
+ data['style'] = command['style']
399
+ data['title'] = self.getRuntimeValue(command['title'])
400
+ data['message'] = self.getRuntimeValue(command['message'])
401
+ record['data'] = data
402
+ return self.nextPC()
295
403
 
296
404
  def r_create(self, command):
297
405
  record = self.getVariable(command['name'])
@@ -304,8 +412,42 @@ class Graphics(Handler):
304
412
  elif keyword == 'checkbox': return self.r_createCheckBox(command, record)
305
413
  elif keyword == 'lineinput': return self.r_createLineEdit(command, record)
306
414
  elif keyword == 'listbox': return self.r_createListWidget(command, record)
415
+ elif keyword == 'combobox': return self.r_createComboBox(command, record)
416
+ elif keyword == 'dialog': return self.r_createDialog(command, record)
417
+ elif keyword == 'messagebox': return self.r_createMessageBox(command, record)
307
418
  return None
308
419
 
420
+ # Declare a dialog variable
421
+ def k_dialog(self, command):
422
+ return self.compileVariable(command, False)
423
+
424
+ def r_dialog(self, command):
425
+ return self.nextPC()
426
+
427
+ # Disable a widget
428
+ def k_disable(self, command):
429
+ if self.nextIsSymbol():
430
+ command['name'] = self.getSymbolRecord()['name']
431
+ self.add(command)
432
+ return True
433
+ return False
434
+
435
+ def r_disable(self, command):
436
+ self.getVariable(command['name'])['widget'].setEnabled(False)
437
+ return self.nextPC()
438
+
439
+ # Enable a widget
440
+ def k_enable(self, command):
441
+ if self.nextIsSymbol():
442
+ command['name'] = self.getSymbolRecord()['name']
443
+ self.add(command)
444
+ return True
445
+ return False
446
+
447
+ def r_enable(self, command):
448
+ self.getVariable(command['name'])['widget'].setEnabled(True)
449
+ return self.nextPC()
450
+
309
451
  # Create a group box
310
452
  def k_groupbox(self, command):
311
453
  return self.compileVariable(command, False)
@@ -322,6 +464,10 @@ class Graphics(Handler):
322
464
 
323
465
  def r_init(self, command):
324
466
  self.app = QApplication(sys.argv)
467
+ screen = QApplication.screens()[0].size().toTuple()
468
+ self.screenWidth = screen[0]
469
+ self.screenHeight = screen[1]
470
+ print(f'Screen: {self.screenWidth}x{self.screenHeight}')
325
471
  return self.nextPC()
326
472
 
327
473
  # Declare a label variable
@@ -352,6 +498,13 @@ class Graphics(Handler):
352
498
  def r_listbox(self, command):
353
499
  return self.nextPC()
354
500
 
501
+ # Declare a messagebox variable
502
+ def k_messagebox(self, command):
503
+ return self.compileVariable(command, False)
504
+
505
+ def r_messagebox(self, command):
506
+ return self.nextPC()
507
+
355
508
  # Handle events
356
509
  def k_on(self, command):
357
510
  if self.nextIs('click'):
@@ -396,19 +549,33 @@ class Graphics(Handler):
396
549
  def r_pushbutton(self, command):
397
550
  return self.nextPC()
398
551
 
399
- # Clean exit
400
- def on_last_window_closed(self):
401
- print("Last window closed! Performing cleanup...")
402
- self.program.kill()
552
+ # remove current item from {combobox}
553
+ def k_remove(self, command):
554
+ command['variant'] = None
555
+ if self.nextIs('current'):
556
+ if self.nextIs('item'):
557
+ if self.nextIs('from'):
558
+ if self.nextIsSymbol():
559
+ record = self.getSymbolRecord()
560
+ if record['keyword'] == 'combobox':
561
+ command['variant'] = 'current'
562
+ command['name'] = record['name']
563
+ self.addCommand(command)
564
+ return True
565
+ return False
566
+
567
+ def r_remove(self, command):
568
+ variant = command['variant']
569
+ record = self.getVariable(command['name'])
570
+ if record['keyword'] == 'combobox' and variant == 'current':
571
+ widget = record['widget']
572
+ widget.removeItem(widget.currentIndex())
573
+ return self.nextPC()
403
574
 
404
575
  # This is called every 10ms to keep the main application running
405
576
  def flush(self):
406
577
  self.program.flushCB()
407
578
 
408
- # Resume execution at the line following 'start graphics'
409
- def resume(self):
410
- self.program.flush(self.nextPC())
411
-
412
579
  # Set something
413
580
  def k_set(self, command):
414
581
  token = self.nextToken()
@@ -434,12 +601,14 @@ class Graphics(Handler):
434
601
  groupbox.setFixedHeight(self.getRuntimeValue(command['value']))
435
602
  return self.nextPC()
436
603
 
437
- # Show a window with a specified layout
604
+ # Show something
438
605
  # show {name} in {window}}
606
+ # show {dialog}/{messagebox}
439
607
  def k_show(self, command):
440
608
  if self.nextIsSymbol():
441
609
  record = self.getSymbolRecord()
442
- if record['keyword'] == 'layout':
610
+ keyword = record['keyword']
611
+ if keyword == 'layout':
443
612
  command['layout'] = record['name']
444
613
  if self.nextIs('in'):
445
614
  if self.nextIsSymbol():
@@ -448,16 +617,54 @@ class Graphics(Handler):
448
617
  command['window'] = record['name']
449
618
  self.add(command)
450
619
  return True
620
+ elif keyword == 'dialog':
621
+ command['dialog'] = record['name']
622
+ self.add(command)
623
+ return True
624
+ elif keyword == 'messagebox':
625
+ command['messagebox'] = record['name']
626
+ if self.nextIs('giving'):
627
+ if self.nextIsSymbol():
628
+ command['result'] = self.getSymbolRecord()['name']
629
+ self.add(command)
630
+ return True
451
631
  return False
452
632
 
453
633
  def r_show(self, command):
454
- layoutRecord = self.getVariable(command['layout'])
455
- windowRecord = self.getVariable(command['window'])
456
- window = windowRecord['window']
457
- container = QWidget()
458
- container.setLayout(layoutRecord['widget'])
459
- window.setCentralWidget(container)
460
- window.show()
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:
641
+ data = self.getVariable(command['messagebox'])['data']
642
+ symbolRecord = self.getVariable(command['result'])
643
+ window = self.getVariable(data['window'])['window']
644
+ style = data['style']
645
+ title = data['title']
646
+ message = data['message']
647
+ if style == 'question':
648
+ button = QMessageBox.question(window, title, message)
649
+ if button == QMessageBox.Yes: result = 'Yes'
650
+ else: result = 'No'
651
+ elif style == 'warning':
652
+ button = QMessageBox.warning(window, title, message)
653
+ if button == QMessageBox.Ok: result = 'OK'
654
+ else: result = ''
655
+ else: result = 'Cancel'
656
+ v = {}
657
+ v['type'] = 'text'
658
+ v['content'] = result
659
+ self.putSymbolValue(symbolRecord, v)
660
+ else:
661
+ layoutRecord = self.getVariable(command['layout'])
662
+ windowRecord = self.getVariable(command['window'])
663
+ window = windowRecord['window']
664
+ container = QWidget()
665
+ container.setLayout(layoutRecord['widget'])
666
+ window.setCentralWidget(container)
667
+ window.show()
461
668
  return self.nextPC()
462
669
 
463
670
  # Start the graphics
@@ -468,11 +675,16 @@ class Graphics(Handler):
468
675
  return False
469
676
 
470
677
  def r_start(self, command):
678
+ def on_last_window_closed():
679
+ print("Performing cleanup...")
680
+ self.program.kill()
681
+ def resume():
682
+ self.program.flush(self.nextPC())
471
683
  timer = QTimer()
472
684
  timer.timeout.connect(self.flush)
473
685
  timer.start(10)
474
- QTimer.singleShot(500, self.resume)
475
- self.app.lastWindowClosed.connect(self.on_last_window_closed)
686
+ QTimer.singleShot(500, resume)
687
+ self.app.lastWindowClosed.connect(on_last_window_closed)
476
688
  self.app.exec()
477
689
 
478
690
  # Declare a window variable
@@ -486,12 +698,27 @@ class Graphics(Handler):
486
698
  # Compile a value in this domain
487
699
  def compileValue(self):
488
700
  value = {}
489
- value['domain'] = 'rbr'
701
+ value['domain'] = self.getName()
702
+ token = self.getToken()
703
+ if self.isSymbol():
704
+ value['name'] = token
705
+ value['type'] = 'symbol'
706
+ return value
707
+
490
708
  if self.tokenIs('the'):
491
709
  self.nextToken()
492
710
  token = self.getToken()
493
- if token == 'xxxxx':
494
- return value
711
+
712
+ if token == 'count':
713
+ if self.nextIs('of'):
714
+ if self.nextIsSymbol():
715
+ value['type'] = 'symbol'
716
+ record = self.getSymbolRecord()
717
+ keyword = record['keyword']
718
+ if keyword == 'combobox':
719
+ value['type'] = 'count'
720
+ value['name'] = record['name']
721
+ return value
495
722
 
496
723
  return None
497
724
 
@@ -503,8 +730,26 @@ class Graphics(Handler):
503
730
  #############################################################################
504
731
  # Value handlers
505
732
 
506
- def v_xxxxx(self, v):
733
+ # This is used by the expression evaluator to get the value of a symbol
734
+ def v_symbol(self, symbolRecord):
735
+ symbolRecord = self.getVariable(symbolRecord['name'])
736
+ keyword = symbolRecord['keyword']
737
+ if keyword == 'combobox':
738
+ combobox = symbolRecord['widget']
739
+ v = {}
740
+ v['type'] = 'text'
741
+ v['content'] = combobox.currentText()
742
+ return v
743
+ return None
744
+
745
+ def v_count(self, v):
746
+ record = self.getVariable(v['name'])
747
+ keyword = record['keyword']
748
+ widget = record['widget']
749
+ if keyword == 'combobox': content = widget.count()
507
750
  value = {}
751
+ value['type'] = 'int'
752
+ value['content'] = content
508
753
  return value
509
754
 
510
755
  #############################################################################
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: easycoder
3
- Version: 250422.3
3
+ Version: 250423.2
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>
@@ -0,0 +1,18 @@
1
+ easycoder/README.md,sha256=BVXmYphcTJ6q6RN_9L6HtQukgCnOjSLVIsTM3lk-9aM,587
2
+ easycoder/__init__.py,sha256=rXpc2iuRmzM8KsgUZWefLoHMii_uABr61154GK0iZ_0,262
3
+ easycoder/ec_classes.py,sha256=xnWBNak8oKydkFoxHLlq9wo3lIsB3aMnTDrqbtCfoWo,1512
4
+ easycoder/ec_compiler.py,sha256=WN4DMTU66kzOAwOGJe3KDoXj2nPvq19ACegQ-RSMglo,4780
5
+ easycoder/ec_condition.py,sha256=YXvSBQKEzKGCcgUGo3Qp8iHolXmm2BpEm0NimSDszIM,785
6
+ easycoder/ec_core.py,sha256=X66TBECPnp-82lEcCpaiJuXSy4Ex519iBK2BM-wGHaQ,90611
7
+ easycoder/ec_graphics.py,sha256=WXxKMB4GJSmxvk-FVbOTyufiUx4TYIzyDoB1PCAO3JY,16067
8
+ easycoder/ec_gutils.py,sha256=yqu4RRQ6VdRkC5B2ADBYsXzgNu76dLnekd9aUjdEgPw,6399
9
+ easycoder/ec_handler.py,sha256=K7nBuQTH8l0k8hX1o2b4KhTnhZHGdf2fkEuX4FJXJs8,2277
10
+ easycoder/ec_program.py,sha256=ZCcvI36iq9HG4o8rFwFxzVElzZ7PEeNOPMr8eqwz8ns,10010
11
+ easycoder/ec_pyside6.py,sha256=0Z-uWrCq7Uz_C6WjN-9E0TDI-IHny14-j5sTc1a3LLg,26627
12
+ easycoder/ec_timestamp.py,sha256=_3QFJPzIWZ9Rzk3SQOQJ-gwmvB07pg78k23SPntoZtY,288
13
+ easycoder/ec_value.py,sha256=zgDJTJhIg3yOvmnnKIfccIizmIhGbtvL_ghLTL1T5fg,2516
14
+ easycoder-250423.2.dist-info/entry_points.txt,sha256=JXAZbenl0TnsIft2FcGJbJ-4qoztVu2FuT8PFmWFexM,44
15
+ easycoder-250423.2.dist-info/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
16
+ easycoder-250423.2.dist-info/WHEEL,sha256=ssQ84EZ5gH1pCOujd3iW7HClo_O_aDaClUbX4B8bjKY,100
17
+ easycoder-250423.2.dist-info/METADATA,sha256=XZhRQ-0z-KpgImt8Nvyk46I6V_lZ1M2aet5VoR8hHYs,5617
18
+ easycoder-250423.2.dist-info/RECORD,,
@@ -1,18 +0,0 @@
1
- easycoder/README.md,sha256=BVXmYphcTJ6q6RN_9L6HtQukgCnOjSLVIsTM3lk-9aM,587
2
- easycoder/__init__.py,sha256=HAdBM4aowyailw2NexqgELS6KF9_8A6QEnCYy1FghmY,262
3
- easycoder/ec_classes.py,sha256=xnWBNak8oKydkFoxHLlq9wo3lIsB3aMnTDrqbtCfoWo,1512
4
- easycoder/ec_compiler.py,sha256=rtxFEWnhW0550MtWEDvYHOw9cYkeTcR0oG3t-kmgnBk,4795
5
- easycoder/ec_condition.py,sha256=YXvSBQKEzKGCcgUGo3Qp8iHolXmm2BpEm0NimSDszIM,785
6
- easycoder/ec_core.py,sha256=-nSX_KA_VBximHI1GIuXA-FhsqcyTNp9-HFrv6Dy64M,90625
7
- easycoder/ec_graphics.py,sha256=ScGLNxW_sxu0WyoO-Od-9MM0bhpVvf-vGa5UmoHYRCA,16073
8
- easycoder/ec_gutils.py,sha256=yqu4RRQ6VdRkC5B2ADBYsXzgNu76dLnekd9aUjdEgPw,6399
9
- easycoder/ec_handler.py,sha256=K7nBuQTH8l0k8hX1o2b4KhTnhZHGdf2fkEuX4FJXJs8,2277
10
- easycoder/ec_program.py,sha256=BDwU7aGHiaw6WdbQvVFDhGVaHsvwQ1CWa4wb5MPmOe8,10013
11
- easycoder/ec_pyside6.py,sha256=OOj7ikQbGQqi1wZ8VaNcX0yZUrN0KkVzZGPGbKlyGDo,17583
12
- easycoder/ec_timestamp.py,sha256=_3QFJPzIWZ9Rzk3SQOQJ-gwmvB07pg78k23SPntoZtY,288
13
- easycoder/ec_value.py,sha256=zgDJTJhIg3yOvmnnKIfccIizmIhGbtvL_ghLTL1T5fg,2516
14
- easycoder-250422.3.dist-info/entry_points.txt,sha256=JXAZbenl0TnsIft2FcGJbJ-4qoztVu2FuT8PFmWFexM,44
15
- easycoder-250422.3.dist-info/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
16
- easycoder-250422.3.dist-info/WHEEL,sha256=ssQ84EZ5gH1pCOujd3iW7HClo_O_aDaClUbX4B8bjKY,100
17
- easycoder-250422.3.dist-info/METADATA,sha256=40jnSopPCKhQMtl0N_9Hka9LT7CVXI-TV0q0DeyIQ0A,5617
18
- easycoder-250422.3.dist-info/RECORD,,