make an interactive grid in which users can edit sample names
        as well as which site a sample belongs to
198919
def InitSampCheck(self):
        """"""
        self.sample_window += 1
        self.panel = wx.Panel(self, style=wx.SIMPLE_BORDER)

        if self.sample_window == 1:
            text = """Step 2:
Check that all samples are correctly named,
and that they belong to the correct site
(if site name is simply wrong, that will be fixed in step 3)"""
            step_label = wx.StaticText(self.panel, label=text)#, size=(900, 100))
        else:
            text = """Step 4:
Some of the data from the er_sites table has propogated into er_samples.
Check that these data are correct, and fill in missing cells using controlled vocabularies.
The columns for class, lithology, and type can take multiple values in the form of a colon-delimited list.
You may use the drop-down menus to add as many values as needed in these columns.
(see Help button for more details)\n\n** Denotes controlled vocabulary"""
            step_label = wx.StaticText(self.panel, label=text)#, size=(900, 100))

        if self.sample_window == 1:
            # provide no extra headers
            headers = {'sample': {'er': [[], [], []],
                                  'pmag': [[], [], []]}}
            self.grid_builder = grid_frame2.GridBuilder(self.er_magic_data, 'sample',
                                                       headers, self.panel,
                                                       'site')

        if self.sample_window > 1:
            self.grid_builder = grid_frame2.GridBuilder(self.er_magic_data, 'sample',
                                           self.er_magic_data.headers, self.panel,
                                           'site')

        self.samp_grid = self.grid_builder.make_grid(incl_pmag=False)
        self.samp_grid.InitUI()
        self.grid_builder.add_data_to_grid(self.samp_grid, 'sample', incl_pmag=False)
        self.grid = self.samp_grid

        sites = sorted(self.er_magic_data.make_name_list(self.er_magic_data.sites))
        self.drop_down_menu = drop_down_menus.Menus("sample", self, self.samp_grid, sites) # initialize all needed drop-down menus

        ### Create Buttons ###
        hbox_one = wx.BoxSizer(wx.HORIZONTAL)
        self.addSiteButton = wx.Button(self.panel, label="Add a new site")
        self.Bind(wx.EVT_BUTTON, self.on_addSiteButton, self.addSiteButton)
        hbox_one.Add(self.addSiteButton, flag=wx.RIGHT, border=10)
        if self.sample_window == 1:
            html_help = "ErMagicSampleHelp1.html"
        if self.sample_window > 1:
            html_help = "ErMagicSampleHelp.html"
        self.helpButton = wx.Button(self.panel, label="Help")
        self.Bind(wx.EVT_BUTTON, lambda event: self.on_helpButton(event, html_help), self.helpButton)
        hbox_one.Add(self.helpButton)

        hboxok = wx.BoxSizer(wx.HORIZONTAL)
        self.saveButton = wx.Button(self.panel, id=-1, label='Save')
        self.Bind(wx.EVT_BUTTON, lambda event: self.on_saveButton(event, self.samp_grid), self.saveButton)
        self.cancelButton = wx.Button(self.panel, wx.ID_CANCEL, '&Cancel')
        self.Bind(wx.EVT_BUTTON, self.on_cancelButton, self.cancelButton)
        self.continueButton = wx.Button(self.panel, id=-1, label='Save and continue')
        next_dia = self.InitSiteCheck if self.sample_window < 2 else self.InitLocCheck
        self.Bind(wx.EVT_BUTTON, lambda event: self.on_continueButton(event, self.samp_grid, next_dia=next_dia), self.continueButton)
        self.backButton = wx.Button(self.panel, wx.ID_ANY, "&Back")
        previous_dia = self.InitSpecCheck if self.sample_window < 2 else self.InitSiteCheck
        self.Bind(wx.EVT_BUTTON, lambda event: self.on_backButton(event, previous_dia=previous_dia), self.backButton)

        hboxok.Add(self.saveButton, flag=wx.RIGHT, border=10)
        hboxok.Add(self.cancelButton, flag=wx.RIGHT, border=10)
        hboxok.Add(self.continueButton, flag=wx.RIGHT, border=10)
        hboxok.Add(self.backButton)

        hboxgrid = pw.hbox_grid(self.panel, self.onDeleteRow, 'sample', self.grid)
        self.deleteRowButton = hboxgrid.deleteRowButton

        self.Bind(wx.grid.EVT_GRID_LABEL_LEFT_CLICK, self.onLeftClickLabel, self.grid)

        ### Make Containers ###
        vbox = wx.BoxSizer(wx.VERTICAL)
        vbox.Add(step_label, flag=wx.ALIGN_LEFT|wx.TOP|wx.BOTTOM, border=20)

        vbox.Add(hbox_one, flag=wx.BOTTOM|wx.LEFT, border=10)
        vbox.Add(hboxok, flag=wx.BOTTOM|wx.LEFT, border=10)
        vbox.Add(hboxgrid, flag=wx.BOTTOM|wx.LEFT, border=10)
        vbox.Add(self.samp_grid, flag=wx.ALL, border=10) # using wx.EXPAND or not does not affect re-size problem
        vbox.AddSpacer(20)

        self.hbox_all = wx.BoxSizer(wx.HORIZONTAL)
        self.hbox_all.AddSpacer(20)
        self.hbox_all.Add(vbox)
        self.hbox_all.AddSpacer(20)

        self.panel.SetSizer(self.hbox_all)
        #if sys.platform in ['win32', 'win64']:
        #    self.panel.SetScrollbars(20, 20, 50, 50)
        self.hbox_all.Fit(self)

        self.Centre()
        self.Show()

        ## this combination may prevent a display error that (without the fix) only resolves on manually resizing the window
        self.panel.Refresh()
        self.samp_grid.ForceRefresh()
        self.panel.Refresh()
        self.Refresh()

        # this prevents display errors
        self.Hide()
        self.Show()
604519
def grid_html(grid, options, rendering, reuse_last_column_for_filter_buttons) #:nodoc:
      table_html_attrs, header_tr_html = options[:html], options[:header_tr_html]

      Wice::WgHash.add_or_append_class_value!(table_html_attrs, 'wice-grid', true)

      if Array === Defaults::DEFAULT_TABLE_CLASSES
        Defaults::DEFAULT_TABLE_CLASSES.each do |default_class|
          Wice::WgHash.add_or_append_class_value!(table_html_attrs, default_class, true)
        end
      end

      if options[:class]
        Wice::WgHash.add_or_append_class_value!(table_html_attrs, options[:class])
        options.delete(:class)
      end

      cycle_class = nil
      sorting_dependant_row_cycling = options[:sorting_dependant_row_cycling]

      grid.output_buffer = GridOutputBuffer.new

      # Ruby 1.9.x
      grid.output_buffer.force_encoding('UTF-8') if grid.output_buffer.respond_to?(:force_encoding)

      grid.output_buffer << %(<div class="wice-grid-container table-responsive" data-grid-name="#{grid.name}" id="#{grid.name}"><div id="#{grid.name}_title">)
      grid.output_buffer << content_tag(:h3, grid.saved_query.name) if grid.saved_query
      grid.output_buffer << "</div><table #{public_tag_options(table_html_attrs, true)}>"
      grid.output_buffer << "<caption>#{rendering.kaption}</caption>" if rendering.kaption
      grid.output_buffer << '<thead>'

      no_filters_at_all = (options[:show_filters] == :no || rendering.no_filter_needed?)

      if no_filters_at_all
        no_rightmost_column = no_filter_row = no_filters_at_all
      else
        no_rightmost_column = no_filter_row = (options[:show_filters] == :no || rendering.no_filter_needed_in_main_table?) ? true : false
      end

      no_rightmost_column = true if reuse_last_column_for_filter_buttons

      number_of_columns = rendering.number_of_columns(:in_html)
      number_of_columns -= 1 if no_rightmost_column

      number_of_columns_for_extra_rows = number_of_columns + 1

      pagination_panel_content_html = nil
      if options[:upper_pagination_panel]
        grid.output_buffer << rendering.pagination_panel(number_of_columns, options[:hide_csv_button]) do
          pagination_panel_content_html =
            pagination_panel_content(grid, options[:extra_request_parameters], options[:allow_showing_all_records], options[:pagination_theme])
          pagination_panel_content_html
        end
      end

      title_row_attrs = header_tr_html.clone
      Wice::WgHash.add_or_append_class_value!(title_row_attrs, 'wice-grid-title-row', true)

      grid.output_buffer << %(<tr #{public_tag_options(title_row_attrs, true)}>)

      filter_row_id = grid.name + '_filter_row'

      # first row of column labels with sorting links

      filter_shown = if options[:show_filters] == :when_filtered
        grid.filtering_on?
      elsif options[:show_filters] == :always
        true
      end

      rendering.each_column_aware_of_one_last_one(:in_html) do |column, last|
        column_name = column.name

        opts = column.html

        opts = opts ? opts.clone : {}

        Wice::WgHash.add_or_append_class_value!(opts, column.css_class)

        if column.attribute && column.ordering

          column.add_css_class('active-filter') if grid.filtered_by?(column)

          direction = 'asc'
          link_style = nil
          arrow_class = nil

          if grid.ordered_by?(column)
            column.add_css_class('sorted')
            Wice::WgHash.add_or_append_class_value!(opts, 'sorted')
            link_style = grid.order_direction

            case grid.order_direction
            when 'asc'
              direction = 'desc'
              arrow_class = 'down'
            when 'desc'
              direction = 'asc'
              arrow_class = 'up'
            end
          end

          col_link = link_to(
            (column_name +
              if arrow_class
                ' ' + content_tag(:i, '', class: "fa fa-arrow-#{arrow_class}")
              else
                ''
              end).html_safe,

            rendering.column_link(
              column,
              direction,
              params,
              options[:extra_request_parameters]
            ),
            class: link_style)

          grid.output_buffer << content_tag(:th, col_link, opts)

        else
          if reuse_last_column_for_filter_buttons && last
            grid.output_buffer << content_tag(:th,
                                              hide_show_icon(filter_row_id, grid, filter_shown, no_filter_row, options[:show_filters], rendering), opts
            )
          else
            grid.output_buffer << content_tag(:th, column_name, opts)
          end
        end
      end

      grid.output_buffer << content_tag(:th,
                                        hide_show_icon(filter_row_id, grid, filter_shown, no_filter_row, options[:show_filters], rendering)
      ) unless no_rightmost_column

      grid.output_buffer << '</tr>'
      # rendering first row end

      unless no_filters_at_all # there are filters, we don't know where, in the table or detached
        if no_filter_row # they are all detached
          rendering.each_column(:in_html) do |column|
            if column.filter_shown?
              filter_html_code = column.render_filter.html_safe
              grid.output_buffer.add_filter(column.detach_with_id, filter_html_code)
            end
          end

        else # some filters are present in the table

          filter_row_attrs = header_tr_html.clone
          Wice::WgHash.add_or_append_class_value!(filter_row_attrs, 'wg-filter-row', true)
          filter_row_attrs['id'] = filter_row_id

          grid.output_buffer << %(<tr #{public_tag_options(filter_row_attrs, true)} )
          grid.output_buffer << 'style="display:none"' unless filter_shown
          grid.output_buffer << '>'

          rendering.each_column_aware_of_one_last_one(:in_html) do |column, last|
            opts = column.html ? column.html.clone : {}
            Wice::WgHash.add_or_append_class_value!(opts, column.css_class)

            if column.filter_shown?

              filter_html_code = column.render_filter.html_safe
              if column.detach_with_id
                grid.output_buffer << content_tag(:th, '', opts)
                grid.output_buffer.add_filter(column.detach_with_id, filter_html_code)
              else
                grid.output_buffer << content_tag(:th, filter_html_code, opts)
              end
            else
              if reuse_last_column_for_filter_buttons && last
                grid.output_buffer << content_tag(:th,
                                                  reset_submit_buttons(options, grid, rendering),
                                                  Wice::WgHash.add_or_append_class_value!(opts, 'filter_icons')
                )
              else
                grid.output_buffer << content_tag(:th, '', opts)
              end
            end
          end
          unless no_rightmost_column
            grid.output_buffer << content_tag(:th, reset_submit_buttons(options, grid, rendering), class: 'filter_icons')
          end
          grid.output_buffer << '</tr>'
        end
      end

      grid.output_buffer << '</thead><tfoot>'
      grid.output_buffer << rendering.pagination_panel(number_of_columns, options[:hide_csv_button]) do
        if pagination_panel_content_html
          pagination_panel_content_html
        else
          pagination_panel_content_html =
            pagination_panel_content(grid, options[:extra_request_parameters], options[:allow_showing_all_records], options[:pagination_theme])
          pagination_panel_content_html
        end
      end

      grid.output_buffer << '</tfoot><tbody>'

      # rendering  rows
      cell_value_of_the_ordered_column = nil
      previous_cell_value_of_the_ordered_column = nil

      grid.each do |ar| # rows
        before_row_output = if rendering.before_row_handler
          call_block(rendering.before_row_handler, ar, number_of_columns_for_extra_rows)
        end

        after_row_output = if rendering.after_row_handler
          call_block(rendering.after_row_handler, ar, number_of_columns_for_extra_rows)
        end

        replace_row_output = if rendering.replace_row_handler
          call_block(rendering.replace_row_handler, ar, number_of_columns_for_extra_rows)
        end

        row_content = if replace_row_output
          no_rightmost_column = true
          replace_row_output
        else
          row_content, tmp_cell_value_of_the_ordered_column = get_row_content(rendering, ar, sorting_dependant_row_cycling)
          cell_value_of_the_ordered_column = tmp_cell_value_of_the_ordered_column if tmp_cell_value_of_the_ordered_column
          row_content
        end

        row_attributes = rendering.get_row_attributes(ar)

        if sorting_dependant_row_cycling
          cycle_class = cycle('odd', 'even', name: grid.name) if cell_value_of_the_ordered_column != previous_cell_value_of_the_ordered_column
          previous_cell_value_of_the_ordered_column = cell_value_of_the_ordered_column
        else
          cycle_class = cycle('odd', 'even', name: grid.name)
        end

        Wice::WgHash.add_or_append_class_value!(row_attributes, cycle_class)

        grid.output_buffer << before_row_output if before_row_output
        grid.output_buffer << "<tr #{public_tag_options(row_attributes)}>#{row_content}"
        grid.output_buffer << content_tag(:td, '') unless no_rightmost_column
        grid.output_buffer << '</tr>'
        grid.output_buffer << after_row_output if after_row_output
      end

      last_row_output = if rendering.last_row_handler
        call_block(rendering.last_row_handler, number_of_columns_for_extra_rows)
      end

      grid.output_buffer << last_row_output if last_row_output

      grid.output_buffer << '</tbody></table>'

      base_link_for_filter, base_link_for_show_all_records = rendering.base_link_for_filter(controller, options[:extra_request_parameters])

      link_for_export = rendering.link_for_export(controller, 'csv', options[:extra_request_parameters])

      parameter_name_for_query_loading = { grid.name => { q: '' } }.to_query
      parameter_name_for_focus = { grid.name => { foc: '' } }.to_query

      processor_initializer_arguments = [
        base_link_for_filter,
        base_link_for_show_all_records,
        link_for_export,
        parameter_name_for_query_loading,
        parameter_name_for_focus,
        Rails.env
      ]

      filter_declarations = if no_filters_at_all
        []
      else
        rendering.select_for(:in_html) do |vc|
          vc.attribute && vc.filter
        end.collect(&:yield_declaration)
      end

      wg_data = {
        'data-processor-initializer-arguments' => processor_initializer_arguments.to_json,
        'data-filter-declarations'             => filter_declarations.to_json,
        :class                                 => 'wg-data'
      }

      wg_data['data-foc'] = grid.status['foc'] if grid.status['foc']

      grid.output_buffer << content_tag(:div, '', wg_data)

      grid.output_buffer << '</div>'

      if Rails.env.development?
        grid.output_buffer << javascript_tag(%/ document.ready = function(){ \n/ +
          %$ if (typeof(WiceGridProcessor) == "undefined"){\n$ +
          %$   alert("wice_grid.js not loaded, WiceGrid cannot proceed!\\n" +\n$ +
          %(     "Make sure that you have loaded wice_grid.js.\\n" + ) +
          %(     "Add line //= require wice_grid.js " + ) +
          %$     "to app/assets/javascripts/application.js")\n$ +
          %( } ) +
          %$ } $)
      end

      grid.output_buffer
    end
724278
def interactive(plugin):
    '''
    '''
    items = [item for item in once(plugin) if not item.get_played()]
    parent_stack = []  # Keep track of parents so we can have a '..' option

    selected_item = get_user_choice(items)
    while selected_item is not None:
        if parent_stack and selected_item == parent_stack[-1]:
            # User selected the parent item, remove from list
            parent_stack.pop()
        else:
            # User selected non parent item, add current url to parent stack
            parent_stack.append(ListItem.from_dict(label='..',
                                                   path=plugin.request.url))
        patch_plugin(plugin, selected_item.get_path())

        items = [item for item in once(plugin, parent_stack=parent_stack)
                 if not item.get_played()]
        selected_item = get_user_choice(items)
121079
def make_grid_frame(self, event):
        
        if self.grid_frame:
            print('-I- You already have a grid frame open')
            pw.simple_warning("You already have a grid open")
            return

        try:
            grid_type = event.GetButtonObj().Name[:-4] # remove '_btn'
        except AttributeError:
            grid_type = self.FindWindowById(event.Id).Name[:-4] # remove ('_btn')
        wait = wx.BusyInfo('Making {} grid, please wait...'.format(grid_type))
        wx.SafeYield()
        # hide mainframe
        self.on_open_grid_frame()
        self.grid_frame = grid_frame.GridFrame(self.er_magic, self.WD, grid_type, grid_type, self.panel)
        if self.validation_mode:
            if grid_type in self.validation_mode:
                self.grid_frame.grid.paint_invalid_cells(self.warn_dict[grid_type])
                #self.grid_frame.msg_boxsizer
                current_label = self.grid_frame.msg_text.GetLabel()
                add_text = """\n\nColumns and rows with problem data have been highlighted in blue.
Cells with problem data are highlighted with different colors according to the type of problem.
Red: missing required data
Green: missing or invalid parent
Blue: non-numeric data provided in a numeric field
Gray: unrecognized column
Purple: invalid result child
Yellow: Out-of-range latitude (should be -90 - 90) or longitude (should be 0-360)
Light gray: Unrecognized term in controlled vocabulary

Note: It is possible to have a row highlighted that has no highlighted column.
This means that you are missing information higher up in the data.
For example: a specimen could be missing a site name.
However, you need to fix this in the sample grid, not the specimen grid.
Once each item in the data has its proper parent, validations will be correct.
"""
                self.grid_frame.msg_text.SetLabel(add_text)
        #self.on_finish_change_dir(self.change_dir_dialog)
        del wait
399572
def _add_grid_attributes(self, ds):
        """"""
        for name_int, names_ext in self._grid_attrs.items():
            ds_coord_name = set(names_ext).intersection(set(ds.coords) |
                                                        set(ds.data_vars))
            model_attr = getattr(self.model, name_int, None)
            if ds_coord_name and (model_attr is not None):
                # Force coords to have desired name.
                ds = ds.rename({list(ds_coord_name)[0]: name_int})
                ds = ds.set_coords(name_int)
                if not np.array_equal(ds[name_int], model_attr):
                    if np.allclose(ds[name_int], model_attr):
                        msg = ("Values for '{0}' are nearly (but not exactly) "
                               "the same in the Run {1} and the Model {2}.  "
                               "Therefore replacing Run's values with the "
                               "model's.".format(name_int, self.run,
                                                 self.model))
                        logging.info(msg)
                        ds[name_int].values = model_attr.values
                    else:
                        msg = ("Model coordinates for '{0}' do not match those"
                               " in Run: {1} vs. {2}"
                               "".format(name_int, ds[name_int], model_attr))
                        logging.info(msg)

            else:
                # Bring in coord from model object if it exists.
                ds = ds.load()
                if model_attr is not None:
                    ds[name_int] = model_attr
                    ds = ds.set_coords(name_int)
            if (self.dtype_in_vert == 'pressure' and
                    internal_names.PLEVEL_STR in ds.coords):
                self.pressure = ds.level
        return ds
737731
def main():
    """"""
    mod_choices = ('banned', 'contributor', 'moderator')
    mod_choices_dsp = ', '.join(['`{}`'.format(x) for x in mod_choices])
    msg = {
        'add': ('Add users to one of the following categories: {}'
                .format(mod_choices_dsp)),
        'clear': 'Remove users who have no flair set.',
        'css': 'Ignore the CSS field when synchronizing flair.',
        'edit': 'When adding flair templates, mark them as editable.',
        'file': 'The file containing contents for --message',
        'flair': 'List flair for the subreddit.',
        'flair_stats': 'Display the number of users with each flair.',
        'json': 'Output the results as json. Applies to --flair',
        'limit': ('The minimum number of users that must have the specified '
                  'flair in order to add as a template. default: %default'),
        'list': ('List the users in one of the following categories: '
                 '{}. May be specified more than once.'
                 .format(mod_choices_dsp)),
        'msg': ('Send message to users of one of the following categories: '
                '{}. Message subject provided via --subject, content provided '
                'via --file or STDIN.').format(mod_choices_dsp),
        'sort': ('The order to add flair templates. Available options are '
                 '`alpha` to add alphabetically, and `size` to first add '
                 'flair that is shared by the most number of users. '
                 'default: %default'),
        'static': ('Add this template when syncing flair templates. When '
                   'syncing text and css use a comma to separate the two.'),
        'subject': 'The subject of the message to send for --message.',
        'sync': 'Synchronize flair templates with current user flair.',
        'text': 'Ignore the text field when synchronizing flair.'}

    usage = 'Usage: %prog [options] SUBREDDIT'
    parser = arg_parser(usage=usage)
    parser.add_option('-a', '--add', help=msg['add'])
    parser.add_option('-l', '--list', action='append', help=msg['list'],
                      choices=mod_choices, metavar='CATEGORY', default=[])
    parser.add_option('-c', '--clear-empty', action='store_true',
                      help=msg['clear'])
    parser.add_option('-F', '--file', help=msg['file'])
    parser.add_option('-f', '--flair', action='store_true', help=msg['flair'])
    parser.add_option('', '--flair-stats', action='store_true',
                      help=msg['flair_stats'])
    parser.add_option('-m', '--message', choices=mod_choices, help=msg['msg'])
    parser.add_option('', '--subject', help=msg['subject'])

    group = OptionGroup(parser, 'Format options')
    group.add_option('-j', '--json', action='store_true', help=msg['json'])
    parser.add_option_group(group)

    group = OptionGroup(parser, 'Sync options')
    group.add_option('', '--sync', action='store_true', help=msg['sync'])
    group.add_option('-s', '--static', action='append', help=msg['static'])
    group.add_option('', '--editable', action='store_true', help=msg['edit'])
    group.add_option('', '--ignore-css', action='store_true',
                     default=False, help=msg['css'])
    group.add_option('', '--ignore-text', action='store_true',
                     default=False, help=msg['text'])
    group.add_option('', '--limit', type='int', help=msg['limit'], default=2)
    group.add_option('', '--sort', action='store', choices=('alpha', 'size'),
                     default='alpha', help=msg['sort'])
    parser.add_option_group(group)

    options, args = parser.parse_args()
    if len(args) == 0:
        parser.error('Must provide subreddit name.')
    if options.message and not options.subject:
        parser.error('Must provide --subject when providing --message.')
    subreddit = args[0]

    check_for_updates(options)

    modutils = ModUtils(subreddit, options.site, options.verbose)

    if options.add:
        modutils.add_users(options.add)
    if options.clear_empty:
        modutils.clear_empty()
    for category in options.list:
        modutils.output_list(category)
    if options.flair:
        modutils.output_current_flair(as_json=options.json)
    if options.flair_stats:
        modutils.output_flair_stats()
    if options.sync:
        modutils.flair_template_sync(editable=options.editable,
                                     limit=options.limit,
                                     static=options.static, sort=options.sort,
                                     use_css=not options.ignore_css,
                                     use_text=not options.ignore_text)
    if options.message:
        modutils.message(options.message, options.subject, options.file)
854603
private void addReadOnlyExamples() {
		add(new WHeading(HeadingLevel.H3, "Read-only WCheckBoxSelect examples"));
		add(new ExplanatoryText("These examples all use the same list of options: the states and territories list from the editable examples above."
				+ " When the readOnly state is specified only those options which are selected are output."));

		// NOTE: when there are 0 or 1 selections the frame is not rendered.
		add(new WHeading(HeadingLevel.H4, "Read only with no selection"));
		WCheckBoxSelect select = new WCheckBoxSelect("australian_state");
		add(select);
		select.setReadOnly(true);
		select.setToolTip("Read only with no selection");
		add(new WText("end of unselected read only example"));

		add(new WHeading(HeadingLevel.H4, "Read only with one selection"));
		select = new SelectWithSingleSelected("australian_state");
		add(select);
		select.setReadOnly(true);
		select.setToolTip("Read only with one selection");

		add(new WHeading(HeadingLevel.H4, "Read only with many selections and no frame"));
		select = new SelectWithSingleSelected("australian_state");
		add(select);
		select.setReadOnly(true);
		select.setToolTip("Read only with many selections");
		select.setFrameless(true);

		add(new WHeading(HeadingLevel.H4, "Read only with many selections and COLUMN layout"));
		select = new SelectWithSingleSelected("australian_state");
		add(select);
		select.setReadOnly(true);
		select.setToolTip("Read only with many selections");
		select.setButtonLayout(WCheckBoxSelect.LAYOUT_COLUMNS);
		select.setButtonColumns(3);

		// read only in a WFieldLayout
		add(new WHeading(HeadingLevel.H4, "Read only in a WFieldLayout"));
		add(new ExplanatoryText("Each read only example is preceded by an editable example with the same options and selection. This is to ensure the"
				+ " CSS works properly."));
		WFieldLayout layout = new WFieldLayout();
		layout.setLabelWidth(25);
		add(layout);

		// no selections
		select = new WCheckBoxSelect("australian_state");
		select.setFrameless(true);
		layout.addField("No selections were made", select);

		select = new WCheckBoxSelect("australian_state");
		select.setFrameless(true);
		select.setReadOnly(true);
		layout.addField("No selections were made (read only)", select);

		// one selection
		select = new SelectWithSingleSelected("australian_state");
		select.setFrameless(true);
		layout.addField("One selection was made", select);

		select = new SelectWithSingleSelected("australian_state");
		select.setFrameless(true);
		select.setReadOnly(true);
		layout.addField("One selection was made (read only)", select);

		// many selections
		select = new SelectWithManySelected("australian_state");
		layout.addField("Many selections with frame", select);

		select = new SelectWithManySelected("australian_state");
		select.setReadOnly(true);
		layout.addField("Many selections with frame (read only)", select);

		// columns with selections
		select = new SelectWithSingleSelected("australian_state");
		select.setButtonLayout(WCheckBoxSelect.LAYOUT_COLUMNS);
		select.setButtonColumns(3);
		select.setFrameless(true);
		layout.addField("many selections, frameless, COLUMN layout (3 columns)", select);

		select = new SelectWithManySelected("australian_state");
		select.setReadOnly(true);
		select.setButtonLayout(WCheckBoxSelect.LAYOUT_COLUMNS);
		select.setButtonColumns(3);
		select.setFrameless(true);
		layout.addField("many selections, frameless, COLUMN layout (3 columns) (read only)", select);

		// flat with selections
		select = new SelectWithManySelected("australian_state");
		select.setButtonLayout(WCheckBoxSelect.LAYOUT_FLAT);
		select.setFrameless(true);
		layout.addField("Many selections, frameless, FLAT layout", select);

		select = new SelectWithManySelected("australian_state");
		select.setReadOnly(true);
		select.setButtonLayout(WCheckBoxSelect.LAYOUT_FLAT);
		select.setFrameless(true);
		layout.addField("Many selections, frameless, FLAT layout (read only)", select);
	}
548180
def onContinue(self, event, grid, next_dia=None):#, age_data_type='site'):
        
        # deselect column, including remove 'EDIT ALL' label
        if self.grid_frame.drop_down_menu:
            self.grid_frame.drop_down_menu.clean_up()

        # remove '**' and '^^' from col names
        #self.remove_starred_labels(grid)
        grid.remove_starred_labels()

        grid.SaveEditControlValue() # locks in value in cell currently edited
        grid_name = str(grid.GetName())

        # save all changes to data object and write to file
        self.grid_frame.grid_builder.save_grid_data()

        # check that all required data are present
        validation_errors = self.validate(grid)
        if validation_errors:
            warn_string = ""
            for error_name, error_cols in list(validation_errors.items()):
                if error_cols:
                    warn_string += "You have {}: {}.\n\n".format(error_name, ", ".join(error_cols))
            warn_string += "Are you sure you want to continue?"
            result = pw.warning_with_override(warn_string)
            if result == wx.ID_YES:
                pass
            else:
                return False
        else:
            wx.MessageBox('Saved!', 'Info',
                          style=wx.OK | wx.ICON_INFORMATION)

        self.panel.Destroy()
        if next_dia:
            next_dia()
        else:
            # propagate any type/lithology/class data from sites to samples table
            # will only overwrite if sample values are blank or "Not Specified"
            self.contribution.propagate_lithology_cols()
            wx.MessageBox('Done!', 'Info',
                          style=wx.OK | wx.ICON_INFORMATION)
518024
function nestTwoLevels(samples) {
  return samples.reduce(function(acc, sample) {
    var page     = sample.hierarchy.length > 0 ? sample.hierarchy[0] : 'API';
    var heading  = sample.hierarchy.length > 1 ? sample.hierarchy[1] : 'Samples';
    acc[page] = acc[page] || {};
    acc[page][heading] = acc[page][heading] || [];
    acc[page][heading].push(sample);
    return acc;
  }, {});
}
1358147
def add_new_grid_headers(self, new_headers):
        
        already_present = []
        for name in new_headers:
            if name:
                if name not in self.grid.col_labels:
                    col_number = self.grid.add_col(name)
                    # add to appropriate headers list
                    # add drop down menus for user-added column
                    if name in self.contribution.vocab.vocabularies:
                        self.drop_down_menu.add_drop_down(col_number, name)
                    elif name in self.contribution.vocab.suggested:
                        self.drop_down_menu.add_drop_down(col_number, name)
                    elif name in ['specimen', 'sample', 'site',
                                  'specimens', 'samples', 'sites']:
                        self.drop_down_menu.add_drop_down(col_number, name)
                    elif name == 'experiments':
                        self.drop_down_menu.add_drop_down(col_number, name)
                    if name == "method_codes":
                        self.drop_down_menu.add_method_drop_down(col_number, name)
                else:
                    already_present.append(name)
                    #pw.simple_warning('You are already using column header: {}'.format(name))
        return already_present
550843
function (options, callback) {
			var sampleImageCategories = ['abstract', 'animals', 'business', 'cats', 'city', 'food', 'nature', 'technics', 'transport'];
			var numItems = 200;

			// build dataSource based with options
			var resp = {
				count: numItems,
				items: [],
				pages: (Math.ceil(numItems / (options.pageSize || 30))),
				page: options.pageIndex
			};

			// get start and end limits for JSON
			var i, l;
			i = options.pageIndex * (options.pageSize || 30);
			l = i + (options.pageSize || 30);
			resp.start = i + 1;
			resp.end = l;

			// add sample items to datasource
			for (i; i < l; i++) {
				resp.items.push({
					name: ('Thumbnail ' + (i + 1)),
					src: 'http://lorempixel.com/65/65/' + sampleImageCategories[Math.floor(Math.random() * 9)] + '/?_=' + i
				});
			}

			// call and simulate latency
			setTimeout(function () {
				callback(resp);
			}, loadDelays[Math.floor(Math.random() * 4)]);
		}
560008
function(member) {
            users = $module.data('users');
            if(member.id != 'anonymous' && users[ member.id ] === undefined ) {
              users[ member.id ] = member.info;
              if(settings.randomColor && member.info.color === undefined) {
                member.info.color = settings.templates.color(member.id);
              }
              html = settings.templates.userList(member.info);
              if(member.info.isAdmin) {
                $(html)
                  .prependTo($userList)
                ;
              }
              else {
                $(html)
                  .appendTo($userList)
                ;
              }
              if(settings.partingMessages) {
                $log
                  .append( settings.templates.joined(member.info) )
                ;
                module.message.scroll.test();
              }
              module.user.updateCount();
            }
          }
1297175
def submit_sample_url(self, url, params={}, _extra_params={}):
        
        self._check_user_parameters(params)
        params = copy.copy(params)
        params['sample-url'] = url
        return self._submit(params, _extra_params=_extra_params)
1208616
def change_sample(self, old_samp_name, new_samp_name, new_site_name=None,
                      new_er_data=None, new_pmag_data=None, replace_data=False):
        
        sample = self.find_by_name(old_samp_name, self.samples)
        if not sample:
            print('-W- {} is not a currently existing sample, so it cannot be updated'.format(old_samp_name))
            return False
        if new_site_name:
            new_site = self.find_by_name(new_site_name, self.sites)
            if not new_site:
                print("""-W- {} is not a currently existing site.
Adding site named: {}""".format(new_site_name, new_site_name))#sample.site or '*empty*', sample)
                new_site = self.add_site(new_site_name)
        else:
            new_site = None
        sample.change_sample(new_samp_name, new_site, new_er_data, new_pmag_data, replace_data)
        return sample
110217
def InitSiteCheck(self):
        
        # propagate average lat/lon info from samples table if
        # available in samples and missing in sites
        self.contribution.propagate_average_up(cols=['lat', 'lon', 'height'],
                                       target_df_name='sites',
                                       source_df_name='samples')
        # propagate lithology columns
        self.contribution.propagate_lithology_cols()

        site_df = self.contribution.tables['sites'].df
        self.panel = wx.Panel(self, style=wx.SIMPLE_BORDER)
        self.grid_frame = grid_frame3.GridFrame(self.contribution, self.WD,
                                                'sites', 'sites', self.panel,
                                                 main_frame=self.main_frame)
        # redefine default 'save & exit grid' button to go to next dialog instead
        self.grid_frame.exitButton.SetLabel('Save and continue')
        grid = self.grid_frame.grid
        self.grid_frame.Bind(wx.EVT_BUTTON,
                             lambda event: self.onContinue(event, grid, self.InitLocCheck),
                             self.grid_frame.exitButton)
        # add back button
        self.backButton = wx.Button(self.grid_frame.panel, id=-1, label='Back',
                                      name='back_btn')
        self.Bind(wx.EVT_BUTTON,
                  lambda event: self.onbackButton(event, self.InitSampCheck),
                  self.backButton)
        self.grid_frame.main_btn_vbox.Add(self.backButton, flag=wx.ALL, border=5)
        # re-do fit
        self.grid_frame.do_fit(None, self.min_size)
        # center
        self.grid_frame.Centre()
        return
401004
def marvcli_tag(ctx, add, remove, datasets):
    """"""
    if not any([add, remove]) or not datasets:
        click.echo(ctx.get_help())
        ctx.exit(1)

    app = create_app()
    setids = parse_setids(datasets)
    app.site.tag(setids, add, remove)
330894
def add_new_header_groups(self, groups):
        
        already_present = []
        for group in groups:
            col_names = self.dm[self.dm['group'] == group].index
            for col in col_names:
                if col not in self.grid.col_labels:
                    col_number = self.grid.add_col(col)
                    # add to appropriate headers list
                    # add drop down menus for user-added column
                    if col in self.contribution.vocab.vocabularies:
                        self.drop_down_menu.add_drop_down(col_number, col)
                    elif col in self.contribution.vocab.suggested:
                        self.drop_down_menu.add_drop_down(col_number, col)
                    elif col in ['specimen', 'sample', 'site', 'location',
                                 'specimens', 'samples', 'sites']:
                        self.drop_down_menu.add_drop_down(col_number, col)
                    elif col == 'experiments':
                        self.drop_down_menu.add_drop_down(col_number, col)
                    if col == "method_codes":
                        self.drop_down_menu.add_method_drop_down(col_number, col)
                else:
                    already_present.append(col)
        return already_present