def InitSampCheck(self):
        """make an interactive grid in which users can edit sample names
        as well as which site a sample belongs to"""
        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()
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 ) 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 ) if self . sample_window == 1 : 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 ) 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 ) 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 ) 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 ) self . hbox_all . Fit ( self ) self . Centre ( ) self . Show ( ) self . panel . Refresh ( ) self . samp_grid . ForceRefresh ( ) self . panel . Refresh ( ) self . Refresh ( ) self . Hide ( ) self . Show ( )
make an interactive grid in which users can edit sample names
        as well as which site a sample belongs to