def __init__(self, data_type, ErMagicCheck, grid, belongs_to): """ take: data_type (string), ErMagicCheck (top level class object for ErMagic steps 1-6), grid (grid object), belongs_to (list of options for data object to belong to, i.e. locations for the site Menus) """ # if controlled vocabularies haven't already been grabbed from earthref # do so now if not any(vocab.vocabularies): vocab.get_stuff() self.data_type = data_type self.check = ErMagicCheck # check is top level class object for entire ErMagic steps 1-6 self.grid = grid self.window = grid.Parent # parent window in which grid resides self.belongs_to = [] # belongs_to can either be a list of strings OR a list of Pmag_objects if belongs_to: for item in belongs_to: try: self.belongs_to.append(item.name) except AttributeError: self.belongs_to.append(item) #self.headers = headers self.selected_col = None self.selection = [] # [(row, col), (row, col)], sequentially down a column self.dispersed_selection = [] # [(row, col), (row, col)], not sequential self.col_color = None self.colon_delimited_lst = ['specimen_type', 'specimen_class', 'specimen_lithology', 'sample_type', 'sample_class', 'sample_lithology', 'site_type', 'site_class', 'site_lithology', 'er_specimen_names', 'er_sample_names', 'er_site_names', 'er_location_names', 'magic_method_codes', 'magic_method_codes++'] self.InitUI()
def validate_for_controlled_vocab(key, value, complete_ref): if not any(vocab.vocabularies): vocab.get_stuff() # cv = False stripped_key = '' for level in ['specimen_', 'sample_', 'site_']: if key.startswith(level): #stripped_key = key.strip(level) stripped_key = key[len(level):] break #print 'key', key #print 'stripped_key', stripped_key if key in vocab.possible_vocabularies or key in vocab.vocabularies: cv = True elif stripped_key in vocab.possible_vocabularies or stripped_key in vocab.vocabularies: cv = True key = stripped_key #return key #if there is a controlled vocabulary for the given header, # check and see if all values provided are legitimate if cv: # make sure colon-delimited lists are split values = value.split(':') values = [v.strip() for v in values] #print 'key', key #print 'values', values # if we don't have the options for the needed controlled vocabulary, # fetch them from earthref if key not in vocab.vocabularies: add = vocab.get_controlled_vocabularies((key,)) vocab.vocabularies = pd.concat((vocab.vocabularies, add[0])) ## for each value from a controlled vocabulary header, ## make sure it is within the controlled vocabulary list ## and that the value is not null for val in values: if val not in vocab.vocabularies[key] and val: if isinstance(vocab.vocabularies[key], dict): if val not in vocab.vocabularies[key][val[0].upper()]: return key else: return key
def __init__(self, contribution, WD=None, frame_name="grid frame", panel_name="grid panel", parent=None): self.parent = parent wx.GetDisplaySize() title = 'Edit {} data'.format(panel_name) #wx.Frame.__init__(self, parent=parent, id=wx.ID_ANY, name=frame_name, title=title) #wx.ScrolledWindow.__init__(self, parent=parent, id=wx.ID_ANY, name=frame_name)#, title=title) super(GridFrame, self).__init__(parent=parent, id=wx.ID_ANY, name=frame_name, title=title) # if controlled vocabularies haven't already been grabbed from earthref # do so now if not any(vocab.vocabularies): vocab.get_stuff() self.remove_cols_mode = False self.deleteRowButton = None self.selected_rows = set() self.contribution = contribution self.panel = wx.Panel(self, name=panel_name, size=wx.GetDisplaySize()) self.grid_type = panel_name if self.parent: self.Bind(wx.EVT_WINDOW_DESTROY, self.parent.Parent.on_close_grid_frame) if self.grid_type == 'age': ancestry_ind = self.contribution.ancestry.index(self.er_magic.age_type) self.child_type = self.contribution.ancestry[ancestry_ind-1] self.parent_type = self.contribution.ancestry[ancestry_ind+1] else: try: child_ind = self.contribution.ancestry.index(self.grid_type) - 1 self.child_type = self.contribution.ancestry[child_ind] parent_ind = self.er_magic.contribution.index(self.grid_type) + 1 self.parent_type = self.contribution.ancestry[parent_ind] except ValueError: self.child_type = None self.parent_type = None self.WD = WD self.InitUI()
def __init__(self, parent): self.box = wx.StaticBox(parent, wx.ID_ANY, "") super(MethodCodeDemystifier, self).__init__(self.box, orient=wx.VERTICAL) grid_sizer = wx.GridSizer(0, 5, 3, 3) if not any(vocab.code_types): vocab.get_stuff() types = vocab.code_types.index types = vocab.code_types['label'] type_ind = vocab.code_types.index for method_type in types: name = str(vocab.code_types[vocab.code_types.label == method_type].index[0]) # make button & add to sizer btn = wx.Button(parent, label=method_type, name=name) grid_sizer.Add(btn, 0, wx.EXPAND) parent.Bind(wx.EVT_BUTTON, self.on_code_button, btn) self.Add(grid_sizer) width, height = grid_sizer.Size self.descriptions = wx.TextCtrl(parent, size=(800, 140), style=wx.TE_READONLY|wx.TE_MULTILINE|wx.HSCROLL)#, value=init_text) self.Add(self.descriptions, flag=wx.ALIGN_CENTRE|wx.ALL, border=10) self.on_code_button(None, 'anisotropy_estimation')