mirror of
https://github.com/lalbornoz/roar.git
synced 2024-11-22 23:36:36 +00:00
libroar/RoarCanvasCommandsFile.py:_import(): handle FileNotFoundError exception.
This commit is contained in:
parent
474f3be4a7
commit
5c55c49769
@ -22,16 +22,20 @@ import io, os, wx
|
|||||||
class RoarCanvasCommandsFile():
|
class RoarCanvasCommandsFile():
|
||||||
# {{{ _import(self, f, newDirty, pathName)
|
# {{{ _import(self, f, newDirty, pathName)
|
||||||
def _import(self, f, newDirty, pathName):
|
def _import(self, f, newDirty, pathName):
|
||||||
|
rc = False
|
||||||
self.parentCanvas.SetCursor(wx.Cursor(wx.CURSOR_WAIT))
|
self.parentCanvas.SetCursor(wx.Cursor(wx.CURSOR_WAIT))
|
||||||
rc, error, newMap, newPathName, newSize = f(pathName)
|
try:
|
||||||
if rc:
|
rc, error, newMap, newPathName, newSize = f(pathName)
|
||||||
self.parentCanvas.dirty = newDirty
|
if rc:
|
||||||
self.parentCanvas.update(newSize, False, newMap)
|
self.parentCanvas.dirty = newDirty
|
||||||
self.canvasPathName = newPathName
|
self.parentCanvas.update(newSize, False, newMap)
|
||||||
self.update(dirty=self.parentCanvas.dirty, pathName=self.canvasPathName, undoLevel=-1)
|
self.canvasPathName = newPathName
|
||||||
self.parentCanvas.canvas.journal.resetCursor()
|
self.update(dirty=self.parentCanvas.dirty, pathName=self.canvasPathName, undoLevel=-1)
|
||||||
self.parentCanvas.canvas.journal.resetUndo()
|
self.parentCanvas.canvas.journal.resetCursor()
|
||||||
else:
|
self.parentCanvas.canvas.journal.resetUndo()
|
||||||
|
except FileNotFoundError as e:
|
||||||
|
rc, error, newMap, newPathName, newSize = False, str(e), None, None, None
|
||||||
|
if not rc:
|
||||||
with wx.MessageDialog(self.parentCanvas, "Error: {}".format(error), "", wx.OK | wx.OK_DEFAULT) as dialog:
|
with wx.MessageDialog(self.parentCanvas, "Error: {}".format(error), "", wx.OK | wx.OK_DEFAULT) as dialog:
|
||||||
dialogChoice = dialog.ShowModal()
|
dialogChoice = dialog.ShowModal()
|
||||||
self.parentCanvas.SetCursor(wx.Cursor(wx.NullCursor))
|
self.parentCanvas.SetCursor(wx.Cursor(wx.NullCursor))
|
||||||
|
Loading…
Reference in New Issue
Block a user