Example #1
0
    def __init__(self, data_type, contribution, grid):
        """
        take: data_type (string), MagIC contribution,
        & grid (grid object)
        """
        # if controlled vocabularies haven't already been grabbed from earthref
        # do so now
        self.contribution = contribution
        if not any(vocab.vocabularies):
            vocab.get_all_vocabulary()

        self.data_type = data_type
        if self.data_type in self.contribution.tables:
            self.magic_dataframe = self.contribution.tables[self.data_type]
        else:
            self.magic_dataframe = None
        if self.data_type == 'ages':
            parent_ind, parent_table, self.parent_type = None, None, None
        else:
            parent_ind = self.contribution.ancestry.index(self.data_type)
            parent_table, self.parent_type = self.contribution.get_table_name(parent_ind+1)

        self.grid = grid
        self.window = grid.Parent  # parent window in which grid resides
        #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 = ['geologic_types', 'geologic_classes',
                                    'lithologies', 'specimens', 'samples',
                                    'sites', 'locations', 'method_codes']
        self.InitUI()
Example #2
0
    def __init__(self, contribution, WD=None, frame_name="grid frame",
                 panel_name="grid panel", parent=None, exclude_cols=()):
        self.parent = parent
        wx.GetDisplaySize()
        title = 'Edit {} data'.format(panel_name)
        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_all_vocabulary()

        self.remove_cols_mode = False
        self.deleteRowButton = None
        self.selected_rows = set()

        self.contribution = contribution
        self.exclude_cols = exclude_cols

        self.panel = wx.Panel(self, name=panel_name, size=wx.GetDisplaySize())
        self.grid_type = str(panel_name)
        dm = self.contribution.data_model.dm[self.grid_type]
        dm['str_validations'] = dm['validations'].str.join(", ")
        # these are the headers that are required no matter what for this datatype
        self.reqd_headers = dm[dm['str_validations'].str.contains("required\(\)").fillna(False)].index
        self.dm = dm

        if self.parent:
            self.Bind(wx.EVT_WINDOW_DESTROY, self.parent.Parent.on_close_grid_frame)

        if self.grid_type == 'ages':
            self.child_type = None
            self.parent_type = None
        else:
            try:
                child_ind = self.contribution.ancestry.index(self.grid_type) - 1
                if child_ind < 0:
                    self.child_type = None
                self.child_type = self.contribution.ancestry[child_ind]
                parent_ind = self.contribution.ancestry.index(self.grid_type) + 1
                if parent_ind >= len(self.contribution.ancestry):
                    self.parent_type = None
                else:
                    self.parent_type = self.contribution.ancestry[parent_ind]
            except ValueError:
                self.child_type = None
                self.parent_type = None

        self.WD = WD
        self.InitUI()