@@ -12,10 +12,10 @@ def initialize_blockly( blockly_id='blocklyDiv', toolbox_id='toolbox', on_change
1212 defaults = []
1313 cats = {}
1414 for block_name in BlocklyBlockGenerators .keys ():
15+ b = BlocklyBlockGenerators [ block_name ]
1516 e = document .createElement ('block' )
1617 e .setAttribute ('type' , block_name )
1718
18- b = BlocklyBlockGenerators [ block_name ]
1919 if b .category :
2020 if b .category in cats :
2121 cats [ b .category ].appendChild ( e )
@@ -28,6 +28,19 @@ def initialize_blockly( blockly_id='blocklyDiv', toolbox_id='toolbox', on_change
2828 else :
2929 defaults .append ( e )
3030
31+ i = 0
32+ #for i in range(len(b.input_values)): ## TODO check why this got broken
33+ while i < len (b .input_values ):
34+ input = b .input_values [i ]
35+ v = document .createElement ('value' )
36+ v .setAttribute ('name' , input ['name' ])
37+ e .appendChild (v )
38+ nb = document .createElement ('block' )
39+ nb .setAttribute ('type' , 'logic_null' )
40+ v .appendChild (nb )
41+ i += 1
42+
43+
3144 if len (defaults ):
3245 cat = document .createElement ('category' )
3346 cat .setAttribute ('name' , 'Callbacks' )
@@ -226,7 +239,7 @@ def generator(block):
226239 code += a + ';'
227240
228241 if is_statement :
229- return code ## statements can directly return
242+ return code + ';' ## statements can directly return
230243 else :
231244 return [ code , Blockly .Python .ORDER_NONE ] ## return Array
232245
@@ -239,13 +252,13 @@ class StatementBlock( BlocklyBlock ):
239252 '''
240253 A statement-block has a previous and/or next statement notch: stack_input and/or stack_output
241254 '''
242- def __init__ (self , name , title = None , stack_input = False , stack_output = False , color = 150 , category = None ):
255+ def __init__ (self , name , title = None , stack_input = False , stack_output = False , color = 170 , category = None ):
243256 self .setup ( name , title = title , color = color , category = category )
244257 self .make_statement ( stack_input = stack_input , stack_output = stack_output )
245258
246259
247260class ValueBlock ( BlocklyBlock ):
248- def __init__ (self , name , title = None , output = None , color = 120 , category = None ):
261+ def __init__ (self , name , title = None , output = '*' , color = 100 , category = None ):
249262 if output is None : raise TypeError
250263 self .setup ( name , title = title , color = color , category = category )
251264 self .set_output ( output )
0 commit comments