Example #1
0
 def on_change_dir_button(self, event):
     """
     create change directory frame
     """
     currentDirectory = self.WD #os.getcwd()
     change_dir_dialog = wx.DirDialog(self.panel,
                                      "Choose your working directory to create or edit a MagIC contribution:",
                                      defaultPath=currentDirectory,
                                      style=wx.DD_DEFAULT_STYLE | wx.DD_NEW_DIR_BUTTON | wx.DD_CHANGE_DIR)
     result = change_dir_dialog.ShowModal()
     if result == wx.ID_CANCEL:
         return
     if result == wx.ID_OK:
         self.WD = change_dir_dialog.GetPath()
         self.dir_path.SetValue(self.WD)
     change_dir_dialog.Destroy()
     wait = wx.BusyInfo('Initializing data object in new directory, please wait...')
     wx.SafeYield()
     print('-I- Initializing magic data object')
     # make new builder object, but reuse old data_model
     self.er_magic = builder.ErMagicBuilder(self.WD, self.er_magic.data_model)
     print('-I- Read in any available data from working directory')
     self.er_magic.get_all_magic_info()
     print('-I- Initializing headers')
     self.er_magic.init_default_headers()
     self.er_magic.init_actual_headers()
     del wait
Example #2
0
    def __init__(self, WD=None, name='Main Frame', dmodel=None):
        try:
            version= pmag.get_version()
        except:
            version = ""
        title = "MagIC GUI   version: %s"%version
        if sys.platform in ['win32', 'win64']:
            title += "  Powered by Enthought Canopy"
        wx.Frame.__init__(self, None, wx.ID_ANY, title, name=name)
        #
        self.grid_frame = None
        self.panel = wx.Panel(self, size=wx.GetDisplaySize(), name='main panel')
        print('-I- Fetching working directory')
        self.WD = os.path.realpath(WD) or os.getcwd()

        print('-I- Initializing magic data object')
        if dmodel is None:
            dmodel = validate_upload.get_data_model()
        self.data_model = dmodel
        self.er_magic = builder.ErMagicBuilder(self.WD, self.data_model)
        self.edited = False
        self.validation_mode = False

        # initialize magic data object
        # attempt to read magic_measurements.txt, and all er_* and pmag_* files
        print('-I- Read in any available data from working directory')
        self.er_magic.get_all_magic_info()

        # POSSIBLY RELOCATE THIS EVENTUALLY:
        print('-I- Initializing headers')
        self.er_magic.init_default_headers()
        self.er_magic.init_actual_headers()
        #
        print('-I- Initializing interface')
        self.InitUI()
Example #3
0
    def __init__(self, WD, parent, ErMagic_data=None):
        SIZE = wx.DisplaySize()
        SIZE = (SIZE[0] * .95, SIZE[1] * .95)

        wx.Frame.__init__(self,
                          parent,
                          wx.ID_ANY,
                          size=SIZE,
                          name='ErMagicBuilder')
        #self.panel = wx.Panel(self)
        self.main_frame = self.Parent
        self.panel = wx.ScrolledWindow(self)
        self.panel.SetScrollbars(1, 1, 1, 1)
        if sys.platform in ['win32', 'win64']:
            self.panel.SetScrollbars(20, 20, 50, 50)
        os.chdir(WD)
        self.WD = os.getcwd()
        self.site_lons = []
        self.site_lats = []

        # if ErMagic data object was not passed in,
        # create one based on the working directory

        if not ErMagic_data:
            self.er_magic = builder.ErMagicBuilder(self.WD)
        else:
            self.er_magic = ErMagic_data

        print('-I- Read in any available data from working directory')
        self.er_magic.get_all_magic_info()
        print('-I- Initializing headers')
        self.er_magic.init_default_headers()
        self.er_magic.init_actual_headers()
        self.SetTitle("Earth-Ref Magic Builder")
        self.InitUI()
Example #4
0
 def setUp(self):
     self.app = wx.App()
     #self.grid = GridFrame(self.ErMagic, self.WD, grid_type, grid_type, self.panel)
     self.ErMagic = builder.ErMagicBuilder(WD, DMODEL)
     self.ErMagic.init_default_headers()
     self.ErMagic.init_actual_headers()
     self.frame = magic_gui.MainFrame(WD)
Example #5
0
    def get_wd_data2(self):
        wait = wx.BusyInfo('Reading in data from current working directory, please wait...')
        #wx.Yield()
        print('-I- Read in any available data from working directory (data model 2)')

        self.er_magic = builder.ErMagicBuilder(self.WD,
                                               data_model=self.data_model)
        del wait
Example #6
0
 def setUp(self):
     self.app = wx.App()
     #self.grid = GridFrame(self.ErMagic, self.WD, grid_type, grid_type, self.panel)
     ErMagic = builder.ErMagicBuilder(WD, DMODEL)
     ErMagic.init_default_headers()
     ErMagic.init_actual_headers()
     self.frame = grid_frame.GridFrame(ErMagic, WD, "specimen", "specimen")
     self.pnl = self.frame.GetChildren()[0]
Example #7
0
 def on_clear(self, event):
     """
     initialize window to allow user to empty the working directory
     """
     dia = pmag_menu_dialogs.ClearWD(self.parent, self.parent.WD)
     clear = dia.do_clear()
     if clear:
         # clear directory, but use previously acquired data_model
         self.parent.er_magic = builder.ErMagicBuilder(self.parent.WD, self.parent.er_magic.data_model)
Example #8
0
 def setUp(self):
     self.app = wx.App()
     #self.grid = GridFrame(self.ErMagic, self.WD, grid_type, grid_type, self.panel)
     self.method_WD = os.path.join(WD, 'data_files', 'testing', 'methods')
     self.ErMagic = builder.ErMagicBuilder(self.method_WD, DMODEL)
     self.ErMagic.get_all_magic_info()
     self.ErMagic.init_default_headers()
     self.ErMagic.init_actual_headers()
     self.frame = grid_frame.GridFrame(self.ErMagic, self.method_WD,
                                       "specimen", "specimen")
Example #9
0
 def on_clear(self, event):
     """
     initialize window to allow user to empty the working directory
     """
     dia = pmag_menu_dialogs.ClearWD(self.parent, self.parent.WD)
     clear = dia.do_clear()
     if clear:
         print('-I- Clear data object')
         self.parent.er_magic = builder.ErMagicBuilder(self.parent.WD, self.parent.data_model)
         print('-I- Initializing headers')
         self.parent.er_magic.init_default_headers()
         self.parent.er_magic.init_actual_headers()
Example #10
0
 def on_clear(self, event):
     """
     initialize window to allow user to empty the working directory
     """
     dia = pmag_menu_dialogs.ClearWD(self.parent, self.parent.WD)
     clear = dia.do_clear()
     if clear:
         # clear directory, but use previously acquired data_model
         if self.data_model_num == 2.5:
             self.parent.er_magic = builder.ErMagicBuilder(
                 self.parent.WD, self.parent.er_magic.data_model)
         elif self.data_model_num == 3:
             self.parent.contribution = nb.Contribution(
                 self.parent.WD, dmodel=self.parent.contribution.data_model)
Example #11
0
 def test_without_codes(self):
     other_WD = os.path.join(WD, 'data_files', 'testing', 'my_project')
     self.other_er_magic = builder.ErMagicBuilder(other_WD)
     self.other_er_magic.init_default_headers()
     self.other_er_magic.init_actual_headers()
     self.other_er_magic.get_all_magic_info()
     #self.frame = magic_gui.MainFrame(self.method_WD)
     self.other_frame = grid_frame.GridFrame(self.other_er_magic, other_WD,
                                             "specimen", "specimen")
     spec = self.other_er_magic.specimens[0]
     self.assertNotIn('magic_method_codes',
                      self.other_frame.grid.col_labels)
     self.assertNotIn('magic_method_codes++',
                      self.other_frame.grid.col_labels)
Example #12
0
    def __init__(self, WD=None, DM=None, dmodel=None):
        """
        Input working directory, data model number (2.5 or 3),
        and data model (optional).
        """
        wx.Frame.__init__(self,
                          None,
                          wx.ID_ANY,
                          self.title,
                          name='pmag_gui mainframe')
        # if DM was provided:
        if DM:
            self.data_model_num = int(DM)
        # try to get DM from command line args
        if not DM:
            self.data_model_num = int(pmag.get_named_arg_from_sys("-DM", 0))
            DM = self.data_model_num
        # if you still don't have DM, make the user choose
        if not DM:
            from dialogs import demag_dialogs
            ui_dialog = demag_dialogs.user_input(
                self, ['data_model'],
                parse_funcs=[float],
                heading=
                "Please input prefered data model (2.5,3.0).  Note: 2.5 is for legacy projects only, if you are have new data please use 3.0.",
                values=[3])
            res = ui_dialog.ShowModal()
            vals = ui_dialog.get_values()
            self.data_model_num = int(vals[1]['data_model'])
        self.data_model = dmodel
        self.FIRST_RUN = True

        self.panel = wx.Panel(self, name='pmag_gui main panel')
        self.InitUI()

        # for use as module:
        self.resource_dir = os.getcwd()

        if not WD:
            self.get_DIR()  # choose directory dialog
        else:
            self.WD = WD
        self.HtmlIsOpen = False
        self.Bind(wx.EVT_CLOSE, self.on_menu_exit)
        if self.data_model_num == 2:
            self.er_magic = builder.ErMagicBuilder(self.WD,
                                                   data_model=self.data_model)
        elif self.data_model_num == 3:
            wx.CallAfter(self.get_wd_data)
Example #13
0
 def on_finish_change_dir(self, dialog, show=True):
     if not show:
         self.WD = dialog.GetPath()
         os.chdir(self.WD)
         self.dir_path.SetValue(self.WD)
     elif dialog.ShowModal() == wx.ID_OK:
         self.WD = dialog.GetPath()
         os.chdir(self.WD)
         self.dir_path.SetValue(self.WD)
         dialog.Destroy()
         #self.ErMagic_data = ErMagicBuilder.ErMagicBuilder(self.WD)
         self.er_magic = builder.ErMagicBuilder(self.WD,
                                                self.er_magic.data_model)
     else:
         dialog.Destroy()
Example #14
0
    def get_wd_data2(self):
        """
        Get 2.5 data from self.WD and put it into
        ErMagicBuilder object.
        Called by get_dm_and_wd
        """
        wait = wx.BusyInfo(
            'Reading in data from current working directory, please wait...')
        #wx.Yield()
        print(
            '-I- Read in any available data from working directory (data model 2)'
        )

        self.er_magic = builder.ErMagicBuilder(self.WD,
                                               data_model=self.data_model)
        del wait
Example #15
0
    def __init__(self, WD=None, dmodel=None):

        self.FIRST_RUN = True
        wx.Frame.__init__(self,
                          None,
                          wx.ID_ANY,
                          self.title,
                          name='pmag_gui mainframe')
        self.panel = wx.Panel(self, name='pmag_gui main panel')
        self.InitUI()

        # for use as module:
        self.resource_dir = os.getcwd()

        if not WD:
            self.get_DIR()  # choose directory dialog
        else:
            self.WD = WD
        self.HtmlIsOpen = False
        self.Bind(wx.EVT_CLOSE, self.on_menu_exit)
        self.er_magic = builder.ErMagicBuilder(self.WD, dmodel)