Exemplo n.º 1
0
    def __on_ok(self, _event):
        self.isExporting = True
        extent = Extent(self.spectrum)
        dlgProgress = wx.ProgressDialog('Exporting', '', len(self.sweeps),
                                        style=wx.PD_AUTO_HIDE |
                                        wx.PD_CAN_ABORT |
                                        wx.PD_REMAINING_TIME)

        try:
            count = 1
            for timeStamp, sweep in self.sweeps.items():
                name = '{0:.0f}.png'.format(timeStamp)
                directory = self.editDir.GetValue()
                filename = os.path.join(directory, name)

                thread = self.plot.set_plot({timeStamp: sweep}, extent, False)
                thread.join()
                filename = os.path.join(directory, '{}.png'.format(timeStamp))
                export_image(filename, File.ImageType.PNG,
                             self.figure,
                             self.settings)

                cont, _skip = dlgProgress.Update(count, name)
                if not cont:
                    break
                count += 1
        except IOError as error:
            wx.MessageBox(error.strerror, 'Error', wx.OK | wx.ICON_WARNING)
        finally:
            dlgProgress.Destroy()
            self.EndModal(wx.ID_OK)
Exemplo n.º 2
0
    def __on_export_image(self, _event):
        dlgFile = wx.FileDialog(
            self,
            "Export image to file",
            self.settings.dirExport,
            self.filename,
            File.get_type_filters(File.Types.IMAGE),
            wx.SAVE | wx.OVERWRITE_PROMPT,
        )
        dlgFile.SetFilterIndex(File.ImageType.PNG)
        if dlgFile.ShowModal() == wx.ID_OK:
            dlgImg = DialogImageSize(self, self.settings)
            if dlgImg.ShowModal() != wx.ID_OK:
                dlgFile.Destroy()
                return

            self.status.set_general("Exporting...")
            fileName = dlgFile.GetFilename()
            dirName = dlgFile.GetDirectory()
            self.settings.dirExport = dirName
            fileName = extension_add(fileName, dlgFile.GetFilterIndex(), File.Types.IMAGE)
            fullName = os.path.join(dirName, fileName)
            exportType = dlgFile.GetFilterIndex()
            export_image(fullName, exportType, self.graph.get_figure(), self.settings)
            self.status.set_general("Finished")
        dlgFile.Destroy()
Exemplo n.º 3
0
 def on_export_image(self, _event):
     dlg = wx.FileDialog(self, "Export image to file",
                         self.settings.dirExport,
                         self.filename,
                         File.get_export_filters(File.Exports.IMAGE),
                         wx.SAVE | wx.OVERWRITE_PROMPT)
     dlg.SetFilterIndex(File.ImageType.PNG)
     if dlg.ShowModal() == wx.ID_OK:
         self.status.set_general("Exporting")
         dirname = dlg.GetDirectory()
         self.settings.dirExport = dirname
         filename = os.path.join(dirname, dlg.GetFilename())
         export_image(filename, dlg.GetFilterIndex(),
                      self.graph.get_figure())
         self.status.set_general("Finished")
     dlg.Destroy()
Exemplo n.º 4
0
    def __on_export_image(self, _event):
        dlgFile = wx.FileDialog(self, "Export image to file",
                                self.settings.dirExport, self.filename,
                                File.get_type_filters(File.Types.IMAGE),
                                wx.SAVE | wx.OVERWRITE_PROMPT)
        dlgFile.SetFilterIndex(File.ImageType.PNG)
        if dlgFile.ShowModal() == wx.ID_OK:
            dlgImg = DialogImageSize(self, self.settings)
            if dlgImg.ShowModal() != wx.ID_OK:
                dlgFile.Destroy()
                return

            self.status.set_general("Exporting...")
            fileName = dlgFile.GetFilename()
            dirName = dlgFile.GetDirectory()
            self.settings.dirExport = dirName
            fileName = extension_add(fileName, dlgFile.GetFilterIndex(),
                                     File.Types.IMAGE)
            fullName = os.path.join(dirName, fileName)
            exportType = dlgFile.GetFilterIndex()
            export_image(fullName, exportType, self.graph.get_figure(),
                         self.settings)
            self.status.set_general("Finished")
        dlgFile.Destroy()