def add_spectrum(self, spectrum, table, row):

        pat_name, pat_axes = expectedpeaks.recall_pattern(spectrum)

        #
        # Make spectrum checkbutton
        #
        cb = tkutil.checkbutton(table.frame, spectrum.name, 0)
        cb.button['selectcolor'] = sputil.spectrum_color(spectrum)
        choose_cb = pyutil.precompose(sputil.choose_spectrum_cb, spectrum,
                                      table.chosen_spectra)
        cb.add_callback(choose_cb)
        cb.button.grid(row=row, column=0, sticky='w')
        if pat_name:
            cb.set_state(1)
        table.spectrum_to_checkbutton[spectrum] = cb

        #
        # Make peak pattern menu
        #
        epeak_types = expectedpeaks.expected_peak_descriptions.keys()
        pm = tkutil.option_menu(table.frame, '', epeak_types)
        pm.frame.grid(row=row, column=1, sticky='w')
        table.spectrum_epeak_menus[spectrum] = pm

        #
        # Get default spectrum peak pattern and axis order
        #
        if pat_name == None:
            pat_name = expectedpeaks.default_spectrum_pattern_name(spectrum)
            if pat_name == None:
                pat_name = pm.get()
            pat_list = expectedpeaks.expected_peak_descriptions[pat_name]
            pat_nuclei = expectedpeaks.pattern_nuclei(pat_list[0])
            pat_axes = pyutil.order(pat_nuclei, spectrum.nuclei)

        #
        # Make axis order menu
        #
        aom = axes.axis_order_menu(table.frame,
                                   spectrum.nuclei,
                                   initial_order=pat_axes)
        aom.frame.grid(row=row, column=2, sticky='w')
        table.axis_order_menu[spectrum] = aom

        #
        # Register a callback to limit the menu choices for axis order.
        #
        def restrict_axis_order_cb(pat_name, aom=aom):
            import expectedpeaks
            pat_list = expectedpeaks.expected_peak_descriptions[pat_name]
            pat_nuclei = expectedpeaks.pattern_nuclei(pat_list[0])
            aom.restrict_menu_permutations(pat_nuclei)

        pm.add_callback(restrict_axis_order_cb)

        pm.set(pat_name)
Esempio n. 2
0
  def add_spectrum(self, spectrum, table, row):

    pat_name, pat_axes = expectedpeaks.recall_pattern(spectrum)

    #
    # Make spectrum checkbutton
    #
    cb = tkutil.checkbutton(table.frame, spectrum.name, 0)
    cb.button['selectcolor'] = sputil.spectrum_color(spectrum)
    choose_cb = pyutil.precompose(sputil.choose_spectrum_cb, spectrum,
                                  table.chosen_spectra)
    cb.add_callback(choose_cb)
    cb.button.grid(row = row, column = 0, sticky = 'w')
    if pat_name:
      cb.set_state(1)
    table.spectrum_to_checkbutton[spectrum] = cb

    #
    # Make peak pattern menu
    #
    epeak_types = expectedpeaks.expected_peak_descriptions.keys()
    pm = tkutil.option_menu(table.frame, '', epeak_types)
    pm.frame.grid(row = row, column = 1, sticky = 'w')
    table.spectrum_epeak_menus[spectrum] = pm

    #
    # Get default spectrum peak pattern and axis order
    #
    if pat_name == None:
      pat_name = expectedpeaks.default_spectrum_pattern_name(spectrum)
      if pat_name == None:
        pat_name = pm.get()
      pat_list = expectedpeaks.expected_peak_descriptions[pat_name]
      pat_nuclei = expectedpeaks.pattern_nuclei(pat_list[0])
      pat_axes = pyutil.order(pat_nuclei, spectrum.nuclei)

    #
    # Make axis order menu
    #
    aom = axes.axis_order_menu(table.frame, spectrum.nuclei,
                               initial_order = pat_axes)
    aom.frame.grid(row = row, column = 2, sticky = 'w')
    table.axis_order_menu[spectrum] = aom

    #
    # Register a callback to limit the menu choices for axis order.
    #
    def restrict_axis_order_cb(pat_name, aom=aom):
      import expectedpeaks
      pat_list = expectedpeaks.expected_peak_descriptions[pat_name]
      pat_nuclei = expectedpeaks.pattern_nuclei(pat_list[0])
      aom.restrict_menu_permutations(pat_nuclei)
    pm.add_callback(restrict_axis_order_cb)

    pm.set(pat_name)
Esempio n. 3
0
 def restrict_axis_order_cb(pat_name, aom=aom):
   import expectedpeaks
   pat_list = expectedpeaks.expected_peak_descriptions[pat_name]
   pat_nuclei = expectedpeaks.pattern_nuclei(pat_list[0])
   aom.restrict_menu_permutations(pat_nuclei)
 def restrict_axis_order_cb(pat_name, aom=aom):
     import expectedpeaks
     pat_list = expectedpeaks.expected_peak_descriptions[pat_name]
     pat_nuclei = expectedpeaks.pattern_nuclei(pat_list[0])
     aom.restrict_menu_permutations(pat_nuclei)