easycoder 250422.2__py2.py3-none-any.whl → 250423.1__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.2"
12
+ __version__ = "250423.1"
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,18 @@ 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
+
309
427
  # Create a group box
310
428
  def k_groupbox(self, command):
311
429
  return self.compileVariable(command, False)
@@ -322,6 +440,10 @@ class Graphics(Handler):
322
440
 
323
441
  def r_init(self, command):
324
442
  self.app = QApplication(sys.argv)
443
+ screen = QApplication.screens()[0].size().toTuple()
444
+ self.screenWidth = screen[0]
445
+ self.screenHeight = screen[1]
446
+ print(f'Screen: {self.screenWidth}x{self.screenHeight}')
325
447
  return self.nextPC()
326
448
 
327
449
  # Declare a label variable
@@ -352,6 +474,13 @@ class Graphics(Handler):
352
474
  def r_listbox(self, command):
353
475
  return self.nextPC()
354
476
 
477
+ # Declare a messagebox variable
478
+ def k_messagebox(self, command):
479
+ return self.compileVariable(command, False)
480
+
481
+ def r_messagebox(self, command):
482
+ return self.nextPC()
483
+
355
484
  # Handle events
356
485
  def k_on(self, command):
357
486
  if self.nextIs('click'):
@@ -434,12 +563,14 @@ class Graphics(Handler):
434
563
  groupbox.setFixedHeight(self.getRuntimeValue(command['value']))
435
564
  return self.nextPC()
436
565
 
437
- # Show a window with a specified layout
566
+ # Show something
438
567
  # show {name} in {window}}
568
+ # show {dialog}/{messagebox}
439
569
  def k_show(self, command):
440
570
  if self.nextIsSymbol():
441
571
  record = self.getSymbolRecord()
442
- if record['keyword'] == 'layout':
572
+ keyword = record['keyword']
573
+ if keyword == 'layout':
443
574
  command['layout'] = record['name']
444
575
  if self.nextIs('in'):
445
576
  if self.nextIsSymbol():
@@ -448,16 +579,54 @@ class Graphics(Handler):
448
579
  command['window'] = record['name']
449
580
  self.add(command)
450
581
  return True
582
+ elif keyword == 'dialog':
583
+ command['dialog'] = record['name']
584
+ self.add(command)
585
+ return True
586
+ elif keyword == 'messagebox':
587
+ command['messagebox'] = record['name']
588
+ if self.nextIs('giving'):
589
+ if self.nextIsSymbol():
590
+ command['result'] = self.getSymbolRecord()['name']
591
+ self.add(command)
592
+ return True
451
593
  return False
452
594
 
453
595
  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()
596
+ if 'dialog' in command:
597
+ dialog = self.getVariable(command['dialog'])['dialog']
598
+ b1 = QPushButton("ok",dialog)
599
+ b1.move(50,50)
600
+ dialog.setWindowModality(Qt.ApplicationModal)
601
+ dialog.exec_()
602
+ elif 'messagebox' in command:
603
+ data = self.getVariable(command['messagebox'])['data']
604
+ symbolRecord = self.getVariable(command['result'])
605
+ window = self.getVariable(data['window'])['window']
606
+ style = data['style']
607
+ title = data['title']
608
+ message = data['message']
609
+ if style == 'question':
610
+ button = QMessageBox.question(window, title, message)
611
+ if button == QMessageBox.Yes: result = 'Yes'
612
+ else: result = 'No'
613
+ elif style == 'warning':
614
+ button = QMessageBox.warning(window, title, message)
615
+ if button == QMessageBox.Ok: result = 'OK'
616
+ else: result = ''
617
+ else: result = 'Cancel'
618
+ v = {}
619
+ v['type'] = 'text'
620
+ v['content'] = result
621
+ self.putSymbolValue(symbolRecord, v)
622
+ else:
623
+ layoutRecord = self.getVariable(command['layout'])
624
+ windowRecord = self.getVariable(command['window'])
625
+ window = windowRecord['window']
626
+ container = QWidget()
627
+ container.setLayout(layoutRecord['widget'])
628
+ window.setCentralWidget(container)
629
+ window.show()
461
630
  return self.nextPC()
462
631
 
463
632
  # Start the graphics
@@ -486,7 +655,13 @@ class Graphics(Handler):
486
655
  # Compile a value in this domain
487
656
  def compileValue(self):
488
657
  value = {}
489
- value['domain'] = 'rbr'
658
+ value['domain'] = self.getName()
659
+ token = self.getToken()
660
+ if self.isSymbol():
661
+ value['name'] = token
662
+ value['type'] = 'symbol'
663
+ return value
664
+
490
665
  if self.tokenIs('the'):
491
666
  self.nextToken()
492
667
  token = self.getToken()
@@ -503,6 +678,33 @@ class Graphics(Handler):
503
678
  #############################################################################
504
679
  # Value handlers
505
680
 
681
+ # This is used by the expression evaluator to get the value of a symbol
682
+ def v_symbol(self, symbolRecord):
683
+ symbolRecord = self.getVariable(symbolRecord['name'])
684
+ keyword = symbolRecord['keyword']
685
+ if keyword == 'messagebox':
686
+ data = symbolRecord['data']
687
+ window = self.getVariable(data['window'])['window']
688
+ style = data['style']
689
+ title = data['title']
690
+ message = data['message']
691
+ if style == 'question':
692
+ button = QMessageBox.question(window, title, message)
693
+ elif style == 'warning':
694
+ button = QMessageBox.warning(window, title, message)
695
+ content = True if button == QMessageBox.Ok else False
696
+ v = {}
697
+ v['type'] = 'bool'
698
+ v['content'] = content
699
+ return v
700
+ elif keyword == 'combobox':
701
+ combobox = symbolRecord['widget']
702
+ v = {}
703
+ v['type'] = 'text'
704
+ v['content'] = combobox.currentText()
705
+ return v
706
+ return None
707
+
506
708
  def v_xxxxx(self, v):
507
709
  value = {}
508
710
  return value
@@ -1,12 +1,13 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: easycoder
3
- Version: 250422.2
3
+ Version: 250423.1
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>
7
7
  Description-Content-Type: text/markdown
8
8
  Classifier: License :: OSI Approved :: MIT License
9
9
  Requires-Dist: pytz
10
+ Requires-Dist: pyside6
10
11
  Project-URL: Home, https://github.com/easycoder/easycoder-py
11
12
 
12
13
  # Introduction
@@ -1,5 +1,5 @@
1
1
  easycoder/README.md,sha256=BVXmYphcTJ6q6RN_9L6HtQukgCnOjSLVIsTM3lk-9aM,587
2
- easycoder/__init__.py,sha256=bfNcwiMe7qXzuzK86vrgsO4deXt75iFKgfl0o3PH6AU,262
2
+ easycoder/__init__.py,sha256=fcdquenJKFAbAFQBvEtkEG-Mozj93phUG4RxL1kmjps,262
3
3
  easycoder/ec_classes.py,sha256=xnWBNak8oKydkFoxHLlq9wo3lIsB3aMnTDrqbtCfoWo,1512
4
4
  easycoder/ec_compiler.py,sha256=rtxFEWnhW0550MtWEDvYHOw9cYkeTcR0oG3t-kmgnBk,4795
5
5
  easycoder/ec_condition.py,sha256=YXvSBQKEzKGCcgUGo3Qp8iHolXmm2BpEm0NimSDszIM,785
@@ -8,11 +8,11 @@ easycoder/ec_graphics.py,sha256=ScGLNxW_sxu0WyoO-Od-9MM0bhpVvf-vGa5UmoHYRCA,1607
8
8
  easycoder/ec_gutils.py,sha256=yqu4RRQ6VdRkC5B2ADBYsXzgNu76dLnekd9aUjdEgPw,6399
9
9
  easycoder/ec_handler.py,sha256=K7nBuQTH8l0k8hX1o2b4KhTnhZHGdf2fkEuX4FJXJs8,2277
10
10
  easycoder/ec_program.py,sha256=BDwU7aGHiaw6WdbQvVFDhGVaHsvwQ1CWa4wb5MPmOe8,10013
11
- easycoder/ec_pyside6.py,sha256=OOj7ikQbGQqi1wZ8VaNcX0yZUrN0KkVzZGPGbKlyGDo,17583
11
+ easycoder/ec_pyside6.py,sha256=HFjUZHbVNichHnetPK2IxNSAiR01TZbeQsq3NX43SuM,25080
12
12
  easycoder/ec_timestamp.py,sha256=_3QFJPzIWZ9Rzk3SQOQJ-gwmvB07pg78k23SPntoZtY,288
13
13
  easycoder/ec_value.py,sha256=zgDJTJhIg3yOvmnnKIfccIizmIhGbtvL_ghLTL1T5fg,2516
14
- easycoder-250422.2.dist-info/entry_points.txt,sha256=JXAZbenl0TnsIft2FcGJbJ-4qoztVu2FuT8PFmWFexM,44
15
- easycoder-250422.2.dist-info/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
16
- easycoder-250422.2.dist-info/WHEEL,sha256=ssQ84EZ5gH1pCOujd3iW7HClo_O_aDaClUbX4B8bjKY,100
17
- easycoder-250422.2.dist-info/METADATA,sha256=QDsPwjhegByAXd3qXPiZA76u8_tgX7073ZSUfF1gg2I,5594
18
- easycoder-250422.2.dist-info/RECORD,,
14
+ easycoder-250423.1.dist-info/entry_points.txt,sha256=JXAZbenl0TnsIft2FcGJbJ-4qoztVu2FuT8PFmWFexM,44
15
+ easycoder-250423.1.dist-info/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
16
+ easycoder-250423.1.dist-info/WHEEL,sha256=ssQ84EZ5gH1pCOujd3iW7HClo_O_aDaClUbX4B8bjKY,100
17
+ easycoder-250423.1.dist-info/METADATA,sha256=57xCBptE9U7miwDGAm4NjL4Us_o-L5x0f9FxMRrjIPs,5617
18
+ easycoder-250423.1.dist-info/RECORD,,