def add_block(self,
               block_name,
               style='basic-block',
               label=None,
               special_name=None,
               default=None,
               prim_name=None,
               help_string=None,
               value_block=False,
               content_block=False,
               logo_command=None,
               hidden=False,
               colors=None,
               string_or_number=False):
     """ Add a new block to the palette """
     block = _ProtoBlock(block_name)
     block.set_style(style)
     if label is not None:
         block.set_label(label)
     if special_name is not None:
         block.set_special_name(special_name)
     if default is not None:
         if default == 'None':
             block.set_default(None)
         else:
             block.set_default(default)
     if prim_name is not None:
         block.set_prim_name(prim_name)
     if logo_command is not None:
         block.set_logo_command(logo_command)
     if help_string is not None:
         block.set_help(help_string)
         if not hidden:
             first_arg = None
             if special_name is None:
                 if isinstance(label, list):
                     first_arg = label[0]
                 else:
                     first_arg = label
             else:
                 first_arg = special_name
             if HELP_PALETTE:
                 if first_arg is None or \
                         first_arg == '' or \
                         first_arg == ' ':
                     add_paragraph(self._help_box, '%s' % (help_string))
                 else:
                     add_paragraph(self._help_box,
                                   '%s: %s' % (first_arg, help_string))
     if colors is not None:
         block.set_colors(colors)
     if string_or_number:
         block.set_string_or_number()
     block.set_value_block(value_block)
     block.set_content_block(content_block)
     block.set_palette(self._name)
     if hidden:
         block.set_hidden()
     block.add_block()
Esempio n. 2
0
 def add_block(self, block_name, style='basic-block', label=None,
               special_name=None, default=None, prim_name=None,
               help_string=None, value_block=False, content_block=False,
               logo_command=None, hidden=False, colors=None,
               string_or_number=False, before=None, after=None,
               private=None):
     """ Add a new block to the palette """
     block = _ProtoBlock(block_name)
     block.set_style(style)
     if label is not None:
         block.set_label(label)
     if special_name is not None:
         block.set_special_name(special_name)
     if default is not None:
         if default == 'None':
             block.set_default(None)
         else:
             block.set_default(default)
     if prim_name is not None:
         block.set_prim_name(prim_name)
     if logo_command is not None:
         block.set_logo_command(logo_command)
     if help_string is not None:
         block.set_help(help_string)
         if not hidden:
             first_arg = None
             if special_name is None:
                 if isinstance(label, list):
                     first_arg = label[0]
                 else:
                     first_arg = label
             else:
                 first_arg = special_name
             if HELP_PALETTE:
                 if first_arg is None or \
                         first_arg == '' or \
                         first_arg == ' ':
                     add_paragraph(self._help_box, '%s' % (help_string))
                 else:
                     add_paragraph(self._help_box, '%s: %s' % (first_arg,
                                                               help_string))
     if colors is not None:
         block.set_colors(colors)
     if string_or_number:
         block.set_string_or_number()
     if before is not None:
         block.before = before
     if after is not None:
         block.after = after
     if private is not None:
         block.private = private
     block.set_value_block(value_block)
     block.set_content_block(content_block)
     block.set_palette(self._name)
     if hidden:
         block.set_hidden()
     block.add_block()