geomagpy / magpy

MagPy (or GeomagPy) is a Python package for analysing and displaying geomagnetic data.
BSD 3-Clause "New" or "Revised" License
45 stars 27 forks source link

avoid unnecessary popup when cancel is pushed #115

Closed stephanbracke closed 2 years ago

stephanbracke commented 2 years ago

On the first menu "File' the menu items

You get an unnessary and incorrect popup when the operation is canceled. This can all be corrected with the same principle (here for Open File) https://github.com/geomagpy/magpy/blob/ae91462f1644ebf89fbe570ce1cf67d1d89eb926/magpy/gui/magpy_gui.py#L2272-L2276 We can replace it by following code

    answer = dlg.ShowModal()
    if answer == wx.ID_OK:
        self.changeStatusbar("Loading data ...")
        pathlist = dlg.GetPaths()
    dlg.Destroy()
    if answer == wx.ID_CANCEL:
        return

When we have the answer we can later on use it to check if the answer was a cancel request. If it was we can return( or break the execution) to avoid further evaluation which would cause the popup. On all four methods the best place to exit is just after the dlg.Destroy() command.

leonro commented 2 years ago

Done in fcde8df15cb01a332a77f45f7907b9a3c877aad7

stephanbracke commented 2 years ago

It still pops up in