示例#1
0
 def onOpenCompositeWorker(self, event):
     if not self._wxPyphantApp.pathToRecipe:
         if pltform == 'Linux' or pltform == 'Darwin':
             osMessage = "Choose an existing recipe or cancel to create "\
                         "a new recipe"
         elif pltform == 'Windows':
             osMessage = "Choose existing recipe to open or name a new "\
                         "recipe to create"
         else:
             raise OSError, "Operating System %s not supported!" % pltform
         wc = "Pyphant Recipe(*.h5)|*.h5"
         dlg = wx.FileDialog(self, message=osMessage, defaultDir=os.getcwd(),
                             defaultFile="", wildcard=wc, style=wx.OPEN)
         if dlg.ShowModal() == wx.ID_OK:
             self._wxPyphantApp.pathToRecipe = dlg.GetPath()
         else:
             dlg.Destroy()
             dlg = wx.FileDialog(self, message='Create a new recipe',
                                 defaultDir=os.getcwd(), defaultFile="",
                                 wildcard=wc, style=wx.SAVE)
             if dlg.ShowModal() == wx.ID_OK:
                 path = dlg.GetPath()
                 if not path[:-3] == '.h5':
                     path += '.h5'
                 self._wxPyphantApp.pathToRecipe = path
         dlg.Destroy()
     import PyphantCanvas
     if self._wxPyphantApp.pathToRecipe[-3:] == '.h5':
         if os.path.exists(self._wxPyphantApp.pathToRecipe):
             try:
                 with H5FileHandler(self._wxPyphantApp.pathToRecipe, 'r') \
                          as handler:
                     recipe = handler.loadRecipe()
                 self._remainingSpace = PyphantCanvas.PyphantCanvas(
                     self, recipe)
             except:
                 self._wxPyphantApp._logger.debug(
                     u"An exception occured while loading a recipe.",
                     exc_info=sys.exc_info())
                 wx.MessageBox(
                     "An error has occurred while opening "\
                     "the recipe.\nRecipe has been set to an "\
                     "empty file in order to prevent data loss.\n"\
                     "Please investigate the logfile "\
                     "for further details.\nThe logfile is located at %s"\
                     % os.path.join(LOGDIR, 'pyphant.log'),
                     "Recipe broken, unknown format or outdated!")
                 self._wxPyphantApp.pathToRecipe += ".error.h5"
                 self._remainingSpace = PyphantCanvas.PyphantCanvas(self)
         else:
             self._remainingSpace = PyphantCanvas.PyphantCanvas(self)
         from pyphant.core.WebInterface import shorten
         self.SetTitle(self.titleStr \
                       % shorten(self._wxPyphantApp.pathToRecipe, 30, 30))
     else:
         raise IOError('Unknown file format in file "%s"'\
                           % self._wxPyphantApp.pathToRecipe)
     self.recipeState = 'clean'
     self._remainingSpace.diagram.recipe.registerListener(self.recipeChanged)
示例#2
0
 def onSaveAsCompositeWorker(self, event=None):
     msg = "Select file to save recipe."
     wc = "Pyphant recipe (*.h5)|*.h5"
     dlg = wx.FileDialog(self, message=msg, defaultDir=os.getcwd(),
                         defaultFile="", wildcard=wc, style=wx.SAVE)
     if dlg.ShowModal() == wx.ID_OK:
         filename = dlg.GetPath()
         if not filename.endswith(".h5"):
             filename += ".h5"
         with H5FileHandler(filename, 'w') as handler:
             handler.saveRecipe(
                 self._remainingSpace.diagram.recipe,
                 self._fileMenu.IsChecked(wx.ID_FILE4))
         self._wxPyphantApp.pathToRecipe = filename
         self.recipeState = 'clean'
         from pyphant.core.WebInterface import shorten
         self.SetTitle(self.titleStr % shorten(filename, 30, 30))
     else:
         dlg.Destroy()
示例#3
0
 def onSaveAsCompositeWorker(self, event=None):
     msg = "Select file to save recipe."
     wc = "Pyphant recipe (*.h5)|*.h5"
     dlg = wx.FileDialog(self,
                         message=msg,
                         defaultDir=os.getcwd(),
                         defaultFile="",
                         wildcard=wc,
                         style=wx.SAVE)
     if dlg.ShowModal() == wx.ID_OK:
         filename = dlg.GetPath()
         if not filename.endswith(".h5"):
             filename += ".h5"
         with H5FileHandler(filename, 'w') as handler:
             handler.saveRecipe(self._remainingSpace.diagram.recipe,
                                self._fileMenu.IsChecked(wx.ID_FILE4))
         self._wxPyphantApp.pathToRecipe = filename
         self.recipeState = 'clean'
         from pyphant.core.WebInterface import shorten
         self.SetTitle(self.titleStr % shorten(filename, 30, 30))
     else:
         dlg.Destroy()
示例#4
0
 def onOpenCompositeWorker(self, event):
     if not self._wxPyphantApp.pathToRecipe:
         if pltform == 'Linux' or pltform == 'Darwin':
             osMessage = "Choose an existing recipe or cancel to create "\
                         "a new recipe"
         elif pltform == 'Windows':
             osMessage = "Choose existing recipe to open or name a new "\
                         "recipe to create"
         else:
             raise OSError, "Operating System %s not supported!" % pltform
         wc = "Pyphant Recipe(*.h5)|*.h5"
         dlg = wx.FileDialog(self,
                             message=osMessage,
                             defaultDir=os.getcwd(),
                             defaultFile="",
                             wildcard=wc,
                             style=wx.OPEN)
         if dlg.ShowModal() == wx.ID_OK:
             self._wxPyphantApp.pathToRecipe = dlg.GetPath()
         else:
             dlg.Destroy()
             dlg = wx.FileDialog(self,
                                 message='Create a new recipe',
                                 defaultDir=os.getcwd(),
                                 defaultFile="",
                                 wildcard=wc,
                                 style=wx.SAVE)
             if dlg.ShowModal() == wx.ID_OK:
                 path = dlg.GetPath()
                 if not path[:-3] == '.h5':
                     path += '.h5'
                 self._wxPyphantApp.pathToRecipe = path
             else:
                 dlg.Destroy()
                 raise AbortRecipeCreation
         dlg.Destroy()
     import PyphantCanvas
     if self._wxPyphantApp.pathToRecipe[-3:] == '.h5':
         if os.path.exists(self._wxPyphantApp.pathToRecipe):
             try:
                 with H5FileHandler(self._wxPyphantApp.pathToRecipe, 'r') \
                          as handler:
                     recipe = handler.loadRecipe()
                 self._remainingSpace = PyphantCanvas.PyphantCanvas(
                     self, recipe)
             except:
                 self._wxPyphantApp._logger.error(
                     u"An exception occured while loading a recipe.",
                     exc_info=sys.exc_info())
                 wx.MessageBox(
                     "An error has occurred while opening "\
                     "the recipe.\nRecipe has been set to an "\
                     "empty file in order to prevent data loss.\n"\
                     "Please investigate the logfile "\
                     "for further details.\nThe logfile is located at %s"\
                     % os.path.join(LOGDIR, 'pyphant.log'),
                     "Recipe broken, unknown format or outdated!")
                 self._wxPyphantApp.pathToRecipe += ".error.h5"
                 self._remainingSpace = PyphantCanvas.PyphantCanvas(self)
         else:
             self._remainingSpace = PyphantCanvas.PyphantCanvas(self)
         from pyphant.core.WebInterface import shorten
         self.SetTitle(self.titleStr \
                       % shorten(self._wxPyphantApp.pathToRecipe, 30, 30))
     else:
         raise IOError('Unknown file format in file "%s"'\
                           % self._wxPyphantApp.pathToRecipe)
     self.recipeState = 'clean'
     self._remainingSpace.diagram.recipe.registerListener(
         self.recipeChanged)