@@ -18,17 +18,18 @@ def getName(self):
18
18
19
19
def k_add (self , command ):
20
20
elements = []
21
- while True :
22
- if self .nextIsSymbol ():
23
- symbolRecord = self .getSymbolRecord ()
24
- name = symbolRecord ['name' ]
25
- if 'iselement' in symbolRecord :
26
- elements .append (name )
27
- if self .peek () != 'and' : break
28
- else : FatalError (self .program .compiler , f'"{ name } " is not a graphic element' )
29
- else : FatalError (self .program .compiler , f'Element expected; got "{ self .getToken ()} "' )
30
- self .nextToken ()
31
- command ['elements' ] = json .dumps (elements )
21
+ token = self .nextToken ()
22
+ if self .isSymbol ():
23
+ symbolRecord = self .getSymbolRecord ()
24
+ name = symbolRecord ['name' ]
25
+ if symbolRecord ['keyword' ] == 'layout' :
26
+ elements .append (name )
27
+ command ['args' ] = name
28
+ else : FatalError (self .compiler .program , f'\' { name } \' is not a layout' )
29
+ elif token [0 :2 ] == 'g_' :
30
+ command ['type' ] = token
31
+ command ['args' ] = self .utils .getArgs (self )
32
+ else : return False
32
33
if self .nextIs ('to' ):
33
34
if self .nextIsSymbol ():
34
35
symbolRecord = self .getSymbolRecord ()
@@ -40,11 +41,18 @@ def k_add(self, command):
40
41
41
42
def r_add (self , command ):
42
43
target = self .getVariable (command ['target' ])
43
- elements = json .loads (command ['elements' ])
44
+ type = command ['type' ]
45
+ args = command ['args' ]
44
46
if not 'layout' in target :
45
47
target ['layout' ] = []
46
- for element in elements :
47
- v = self .getVariable (element )
48
+ if args [0 ] == '{' :
49
+ layout = json .loads (self .getRuntimeValue (json .loads (args )))
50
+ default = self .utils .getDefaultArgs (type )
51
+ for n in range (0 , len (layout )):
52
+ args = self .utils .decode (default , layout [n ])
53
+ target ['layout' ].append (self .utils .createElement (type , args ))
54
+ else :
55
+ v = self .getVariable (args )
48
56
target ['layout' ].append (v ['layout' ])
49
57
return self .nextPC ()
50
58
@@ -108,65 +116,6 @@ def r_create(self, command):
108
116
else :
109
117
RuntimeError (self .program , 'Variable is not a window or an element' )
110
118
111
- def k_g_button (self , command ):
112
- command ['iselement' ] = True
113
- return self .compileVariable (command )
114
-
115
- def r_g_button (self , command ):
116
- return self .nextPC ()
117
-
118
- def k_g_input (self , command ):
119
- command ['iselement' ] = True
120
- return self .compileVariable (command )
121
-
122
- def r_g_input (self , command ):
123
- return self .nextPC ()
124
-
125
- def k_g_text (self , command ):
126
- command ['iselement' ] = True
127
- return self .compileVariable (command )
128
-
129
- def r_g_text (self , command ):
130
- return self .nextPC ()
131
-
132
- def k_init (self , command ):
133
- if self .nextIsSymbol ():
134
- record = self .getSymbolRecord ()
135
- if record ['keyword' ] == 'layout' :
136
- command ['target' ] = record ['name' ]
137
- if self .peek () == 'with' :
138
- self .nextToken ()
139
- if self .nextIsSymbol ():
140
- record = self .getSymbolRecord ()
141
- name = record ['name' ]
142
- if record ['iselement' ]:
143
- command ['args' ] = name
144
- else : FatalError (self .program .compiler , f'\' { name } \' is not a graphic element' )
145
- else :
146
- command ['type' ] = self .getToken ()
147
- command ['args' ] = self .utils .getArgs (self )
148
- else : command ['args' ] = None
149
- self .addCommand (command )
150
- return True
151
- return False
152
-
153
- def r_init (self , command ):
154
- record = self .getVariable (command ['target' ])
155
- record ['layout' ] = []
156
- type = command ['type' ]
157
- args = command ['args' ]
158
- if args != None :
159
- if args [0 ] == '{' :
160
- layout = json .loads (self .getRuntimeValue (json .loads (args )))
161
- args = self .utils .getDefaultArgs (type )
162
- for n in range (0 , len (layout )):
163
- args = self .utils .decode (args , layout [n ])
164
- record ['layout' ].append (self .utils .createElement (type , args ))
165
- else :
166
- v = self .getVariable (args )
167
- record ['layout' ].append (v ['layout' ])
168
- return self .nextPC ()
169
-
170
119
def k_layout (self , command ):
171
120
command ['iselement' ] = True
172
121
return self .compileVariable (command )
@@ -259,9 +208,34 @@ def r_popup(self, command):
259
208
return self .nextPC ()
260
209
261
210
def k_set (self , command ):
262
- return True
211
+ if self .nextIsSymbol ():
212
+ record = self .getSymbolRecord ()
213
+ if record ['keyword' ] == 'layout' :
214
+ command ['target' ] = record ['name' ]
215
+ if self .peek () == 'to' :
216
+ self .nextToken ()
217
+ command ['type' ] = self .nextToken ()
218
+ command ['args' ] = self .utils .getArgs (self )
219
+ else : command ['args' ] = None
220
+ self .addCommand (command )
221
+ return True
222
+ return False
263
223
264
224
def r_set (self , command ):
225
+ target = self .getVariable (command ['target' ])
226
+ target ['layout' ] = []
227
+ type = command ['type' ]
228
+ args = command ['args' ]
229
+ if args != None :
230
+ if args [0 ] == '{' :
231
+ layout = json .loads (self .getRuntimeValue (json .loads (args )))
232
+ default = self .utils .getDefaultArgs (type )
233
+ for n in range (0 , len (layout )):
234
+ args = self .utils .decode (default , layout [n ])
235
+ target ['layout' ].append (self .utils .createElement (type , args ))
236
+ else :
237
+ v = self .getVariable (args )
238
+ target ['layout' ].append (v ['layout' ])
265
239
return self .nextPC ()
266
240
267
241
def k_window (self , command ):
0 commit comments