Python wx.FD_SAVE Examples

The following are 30 code examples of wx.FD_SAVE(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module wx , or try the search function .
Example #1
Source File: gui.py    From RF-Monitor with GNU General Public License v2.0 7 votes vote down vote up
def __save(self, prompt):
        if prompt or self._filename is None:
            defDir, defFile = '', ''
            if self._filename is not None:
                defDir, defFile = os.path.split(self._filename)
            dlg = wx.FileDialog(self,
                                'Save File',
                                defDir, defFile,
                                'rfmon files (*.rfmon)|*.rfmon',
                                wx.FD_SAVE | wx.FD_OVERWRITE_PROMPT)
            if dlg.ShowModal() == wx.ID_CANCEL:
                return
            self._filename = dlg.GetPath()

        self.__update_settings()
        save_recordings(self._filename,
                        self._settings.get_freq(),
                        self._settings.get_gain(),
                        self._settings.get_cal(),
                        self._settings.get_dynamic_percentile(),
                        self._monitors)
        self.__set_title()

        self._isSaved = True
        self.__set_title() 
Example #2
Source File: score_frame.py    From dials with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
def OnSave(self, event):
        dialog = wx.FileDialog(
            self,
            defaultDir="",
            message="Save scores",
            style=wx.FD_SAVE | wx.FD_OVERWRITE_PROMPT,
            wildcard="Text files (*.txt)|*.txt",
        )
        if dialog.ShowModal() == wx.ID_OK:
            path = dialog.GetPath()
            if path != "":
                stream = open(path, "w")
                for (key, score) in _scores.items():
                    if score is None:
                        print("%s None" % (key), file=stream)
                    else:
                        print("%s %d" % (key, score), file=stream)
                stream.close()
                print("Dumped scores to", path) 
Example #3
Source File: gui.py    From report-ng with GNU General Public License v2.0 6 votes vote down vote up
def Save_Template_As(self, e):
            openFileDialog = wx.FileDialog(self, 'Save Template As', self.save_into_directory, '',
                                           'Content files (*.yaml; *.json)|*.yaml;*.json|All files (*.*)|*.*',
                                           wx.FD_SAVE | wx.wx.FD_OVERWRITE_PROMPT)
            if openFileDialog.ShowModal() == wx.ID_CANCEL:
                return
            json_ext = '.json'
            filename = openFileDialog.GetPath()
            self.status('Saving Template content...')
            h = open(filename, 'w')
            if filename[-len(json_ext):] == json_ext:
                h.write(self.report.template_dump_json().encode('utf-8'))
            else:
                h.write(self.report.template_dump_yaml().encode('utf-8'))
            h.close()
            self.status('Template content saved') 
Example #4
Source File: bomsaway.py    From Boms-Away with GNU General Public License v3.0 6 votes vote down vote up
def on_export(self, event):
        """
        Gets a file path via popup, then exports content
        """

        exporters = plugin_loader.load_export_plugins()

        wildcards = '|'.join([x.wildcard for x in exporters])

        export_dialog = wx.FileDialog(self, "Export BOM", "", "",
                                      wildcards,
                                      wx.FD_SAVE|wx.FD_OVERWRITE_PROMPT)

        if export_dialog.ShowModal() == wx.ID_CANCEL:
            return

        base, ext = os.path.splitext(export_dialog.GetPath())
        filt_idx = export_dialog.GetFilterIndex()

        exporters[filt_idx]().export(base, self.component_type_map) 
Example #5
Source File: gui.py    From report-ng with GNU General Public License v2.0 6 votes vote down vote up
def Save_Report_As(self, e):
            openFileDialog = wx.FileDialog(self, 'Save Report As', self.save_into_directory, '',
                                           'XML files (*.xml)|*.xml|All files (*.*)|*.*',
                                           wx.FD_SAVE | wx.wx.FD_OVERWRITE_PROMPT)
            if openFileDialog.ShowModal() == wx.ID_CANCEL:
                return
            filename = openFileDialog.GetPath()
            if filename == self.report._template_filename:
                wx.MessageBox('For safety reasons, template overwriting with generated report is not allowed!', 'Error',
                              wx.OK | wx.ICON_ERROR)
                return
            self.status('Generating and saving the report...')
            self.report.scan = self.scan
            self._clean_template()
            #self.report.xml_apply_meta()
            self.report.xml_apply_meta(vulnparam_highlighting=self.menu_view_v.IsChecked(), truncation=self.menu_view_i.IsChecked(), pPr_annotation=self.menu_view_p.IsChecked())
            self.report.save_report_xml(filename)
            #self._clean_template()

            # merge kb before generate
            self.ctrl_tc_k.SetValue('')
            self.menu_tools_merge_kb_into_content.Enable(False)

            self.status('Report saved') 
Example #6
Source File: wxgui.py    From pyshortcuts with MIT License 6 votes vote down vote up
def onSavePy(self, event=None):
        wildcards = "%s|%s" % (PY_FILES, ALL_FILES)
        dlg = wx.FileDialog(self,
                            message='Save Python script for creating shortcut',
                            defaultFile='make_shortcut.py',
                            wildcard=wildcards,
                            style=wx.FD_SAVE)

        if dlg.ShowModal() == wx.ID_OK:
            path = os.path.abspath(dlg.GetPath())
            opts = self.read_form(as_string=True)
            if opts is None:
                return
            buff = ['#!/usr/bin/env python',
                    'from pyshortcuts import make_shortcut',
                    """make_shortcut({script:s},
              name={name:s},
              description={description:s},
              folder={folder:s},
              icon={icon:s},
              terminal={terminal}, desktop={desktop}, startmenu={startmenu},
              executable={executable:s})""".format(**opts)]

            with open(path, 'w') as fh:
                fh.write('\n'.join(buff)) 
Example #7
Source File: elecsus_gui.py    From ElecSus with Apache License 2.0 6 votes vote down vote up
def OnSaveFig(self,event):
		""" Basically the same as saving the figure by the toolbar button. """
		#widcards for file type selection
		wilds = "PDF (*.pdf)|*.pdf|" \
				"PNG (*.png)|*.png|" \
				"EPS (*.eps)|*.eps|" \
				"All files (*.*)|*.*"
		exts = ['.pdf','.png','.eps','.pdf'] # default to pdf
		SaveFileDialog = wx.FileDialog(self,message="Save Figure", defaultDir="./", defaultFile="figure",
			wildcard=wilds, style=wx.FD_SAVE|wx.FD_OVERWRITE_PROMPT)
		SaveFileDialog.SetFilterIndex(0)
		
		if SaveFileDialog.ShowModal() == wx.ID_OK:
			output_filename = SaveFileDialog.GetPath()
			if output_filename[-4:] == exts[SaveFileDialog.GetFilterIndex()]:
				output_filename = output_filename[:-4]
			
			#save all current figures
			for fig, id in zip(self.figs, self.fig_IDs):
				fig.savefig(output_filename+'_'+str(id)+exts[SaveFileDialog.GetFilterIndex()])
				
		SaveFileDialog.Destroy() 
Example #8
Source File: main.py    From wxGlade with MIT License 6 votes vote down vote up
def save_app_as(self):
        "saves a wxGlade project onto an xml file chosen by the user"
        # both flags occurs several times
        fn = wx.FileSelector( _("Save project as..."),
                              wildcard="wxGlade files (*.wxg)|*.wxg|wxGlade Template files (*.wgt) |*.wgt|"
                              "XML files (*.xml)|*.xml|All files|*",
                              flags=wx.FD_SAVE | wx.FD_OVERWRITE_PROMPT,
                              default_filename=common.root.filename or (self.cur_dir+os.sep+"wxglade.wxg"))
        if not fn: return

        # check for file extension and add default extension if missing
        ext = os.path.splitext(fn)[1].lower()
        if not ext:
            fn = "%s.wxg" % fn

        common.root.filename = fn
        #remove the template flag so we can save the file.
        common.root.properties["is_template"].set(False)

        self.save_app()
        self.cur_dir = os.path.dirname(fn)
        self.file_history.AddFileToHistory(fn) 
Example #9
Source File: control.py    From atbswp with GNU General Public License v3.0 6 votes vote down vote up
def compile(event):
        """Return a compiled version of the capture currently loaded.

        For now it only returns a bytecode file.
        #TODO: Return a proper executable for the platform currently
        used **Without breaking the current workflow** which works both
        in development mode and in production
        """
        try:
            bytecode_path = py_compile.compile(TMP_PATH)
        except:
            wx.LogError("No capture loaded")
            return
        default_file = "capture.pyc"
        with wx.FileDialog(parent=event.GetEventObject().Parent, message="Save capture executable",
                           defaultDir=os.path.expanduser("~"), defaultFile=default_file, wildcard="*",
                           style=wx.FD_SAVE | wx.FD_OVERWRITE_PROMPT) as fileDialog:

            if fileDialog.ShowModal() == wx.ID_CANCEL:
                return     # the user changed their mind
            pathname = fileDialog.GetPath()
            try:
                shutil.copy(bytecode_path, pathname)
            except IOError:
                wx.LogError(f"Cannot save current data in file {pathname}.") 
Example #10
Source File: app.py    From thotkeeper with BSD 2-Clause "Simplified" License 5 votes vote down vote up
def _FileSaveAsMenu(self, event):
        dialog = self._GetFileDialog('Save as a new data file',
                                     wx.FD_SAVE | wx.FD_OVERWRITE_PROMPT)
        if dialog.ShowModal() == wx.ID_OK:
            path = dialog.GetPath()
            if len(path) < 5 or not path.endswith('.tkj'):
                path = path + '.tkj'
            self._SaveEntriesToPath(path)
        dialog.Destroy() 
Example #11
Source File: LapGUI.py    From laplacian-meshes with GNU General Public License v3.0 5 votes vote down vote up
def OnSaveMesh(self, evt):
        dlg = wx.FileDialog(self, "Choose a file", ".", "", "*", wx.FD_SAVE)
        if dlg.ShowModal() == wx.ID_OK:
            filename = dlg.GetFilename()
            dirname = dlg.GetDirectory()
            filepath = os.path.join(dirname, filename)
            self.glcanvas.mesh.saveFile(filepath, True)
            self.glcanvas.Refresh()
        dlg.Destroy()
        return 
Example #12
Source File: app.py    From thotkeeper with BSD 2-Clause "Simplified" License 5 votes vote down vote up
def _FileArchiveMenu(self, event):
        date = self._QueryChooseDate('Archive files before which date?')
        if date is None:
            return

        path = None
        new_basename = ''
        if self.conf.data_file is not None:
            new_base, new_ext = os.path.splitext(os.path.basename(
                self.conf.data_file))
            if not new_ext:
                new_ext = '.tkj'
            new_basename = new_base + '.archive' + new_ext
        dialog = self._GetFileDialog('Archive to a new data file',
                                     wx.FD_SAVE | wx.FD_OVERWRITE_PROMPT,
                                     new_basename)
        if dialog.ShowModal() == wx.ID_OK:
            path = dialog.GetPath()
        dialog.Destroy()
        if path is None:
            return

        if len(path) < 5 or not path.endswith('.tkj'):
            path = path + '.tkj'
        wx.Yield()
        wx.BeginBusyCursor()
        try:
            self._ArchiveEntriesBeforeDate(path,
                                           date.GetYear(),
                                           date.GetMonth() + 1,
                                           date.GetDay())
        finally:
            wx.EndBusyCursor() 
Example #13
Source File: g.gui.tangible.py    From grass-tangible-landscape with GNU General Public License v2.0 5 votes vote down vote up
def CreateNewFile(self):
        get_lib_path('g.gui.tangible')
        dlg = wx.FileDialog(self, message="Create a new file with analyses",
                            wildcard="Python source (*.py)|*.py",
                            style=wx.FD_SAVE | wx.FD_OVERWRITE_PROMPT)
        if dlg.ShowModal() == wx.ID_OK:
            path = dlg.GetPath()
            orig = os.path.join(get_lib_path('g.gui.tangible'), 'current_analyses.py')
            if not os.path.exists(orig):
                self.giface.WriteError("File with analyses not found: {}".format(orig))
            else:
                copyfile(orig, path)
                self.selectAnalyses.SetValue(path)
                self.settings['analyses']['file'] = path
        dlg.Destroy() 
Example #14
Source File: PDFLinkMaint.py    From PyMuPDF-Utilities with GNU General Public License v3.0 5 votes vote down vote up
def on_save_file(self, evt):
        indir, infile = os.path.split(self.doc.name)
        odir = indir
        ofile = infile
        if self.doc.needsPass or not self.doc.can_save_incrementally():
            ofile = ""
        sdlg = wx.FileDialog(self, "Specify Output", odir, ofile,
                                   "PDF files (*.pdf)|*.pdf", wx.FD_SAVE)
        if sdlg.ShowModal() == wx.ID_CANCEL:
            evt.Skip()
            return
        outfile = sdlg.GetPath()
        if self.doc.needsPass or not self.doc.can_save_incrementally():
            title =  "Repaired / decrypted PDF requires new output file"
            while outfile == self.doc.name:
                sdlg = wx.FileDialog(self, title, odir, "",
                                     "PDF files (*.pdf)|*.pdf", wx.FD_SAVE)
                if sdlg.ShowModal() == wx.ID_CANCEL:
                    evt.Skip()
                    return
                outfile = sdlg.GetPath()
        self.doc._delXmlMetadata()
        if outfile == self.doc.name:
            self.doc.saveIncr()                       # equal: update input file
        else:
            self.doc.save(outfile, garbage=4)
        
        sdlg.Destroy()
        self.btn_Save.Disable()
        evt.Skip()
        return 
Example #15
Source File: i2cgui.py    From i2cdriver with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def check_c(self, e):
        global StopCapture
        cm = e.EventObject.GetValue()
        # self.sd.monitor(self.monitor)
        if cm:
            openFileDialog = wx.FileDialog(self, "CSV dump to file", "", "", 
                  "CSV files (*.csv)|*.csv", 
                         wx.FD_SAVE | wx.FD_OVERWRITE_PROMPT)
            openFileDialog.ShowModal()
            self.log_csv = openFileDialog.GetPath()
            openFileDialog.Destroy()
            if self.log_csv == u"":
                e.EventObject.SetValue(False)
                return
            StopCapture = False
            self.sd.dumpcount = 0
            t = threading.Thread(target=capture_thr, args=(self.sd, self.log_csv))
            t.setDaemon(True)
            t.start()
        else:
            StopCapture = True
            wx.MessageBox("Capture finished. %d events written to \"%s\"" % (self.sd.dumpcount, self.log_csv), "Message", wx.OK | wx.ICON_INFORMATION)
            while StopCapture:
                pass
        [d.Enable(not cm) for d in self.dynamic]
        if cm:
            [self.hot(i, False) for i in self.heat]
        self.capture = cm 
Example #16
Source File: control.py    From atbswp with GNU General Public License v3.0 5 votes vote down vote up
def save_file(self, event):
        """Save the capture currently loaded."""
        with wx.FileDialog(self.parent, "Save capture file", wildcard="*",
                           style=wx.FD_SAVE | wx.FD_OVERWRITE_PROMPT) as fileDialog:

            if fileDialog.ShowModal() == wx.ID_CANCEL:
                return     # the user changed their mind

            # save the current contents in the file
            pathname = fileDialog.GetPath()
            try:
                shutil.copy(TMP_PATH, pathname)
            except IOError:
                wx.LogError(f"Cannot save current data in file {pathname}.") 
Example #17
Source File: backend_wx.py    From coffeegrindsize with MIT License 5 votes vote down vote up
def save_figure(self, *args):
        # Fetch the required filename and file type.
        filetypes, exts, filter_index = self.canvas._get_imagesave_wildcards()
        default_file = self.canvas.get_default_filename()
        dlg = wx.FileDialog(self._parent, "Save to file", "", default_file,
                            filetypes,
                            wx.FD_SAVE | wx.FD_OVERWRITE_PROMPT)
        dlg.SetFilterIndex(filter_index)
        if dlg.ShowModal() == wx.ID_OK:
            dirname = dlg.GetDirectory()
            filename = dlg.GetFilename()
            DEBUG_MSG(
                'Save file dir:%s name:%s' %
                (dirname, filename), 3, self)
            format = exts[dlg.GetFilterIndex()]
            basename, ext = os.path.splitext(filename)
            if ext.startswith('.'):
                ext = ext[1:]
            if ext in ('svg', 'pdf', 'ps', 'eps', 'png') and format != ext:
                # looks like they forgot to set the image type drop
                # down, going with the extension.
                warnings.warn(
                    'extension %s did not match the selected '
                    'image type %s; going with %s' %
                    (ext, format, ext), stacklevel=2)
                format = ext
            try:
                self.canvas.figure.savefig(
                    os.path.join(dirname, filename), format=format)
            except Exception as e:
                error_msg_wx(str(e)) 
Example #18
Source File: backend_wx.py    From coffeegrindsize with MIT License 5 votes vote down vote up
def trigger(self, *args):
        # Fetch the required filename and file type.
        filetypes, exts, filter_index = self.canvas._get_imagesave_wildcards()
        default_dir = os.path.expanduser(
            matplotlib.rcParams['savefig.directory'])
        default_file = self.canvas.get_default_filename()
        dlg = wx.FileDialog(self.canvas.GetTopLevelParent(), "Save to file",
                            default_dir, default_file, filetypes,
                            wx.FD_SAVE | wx.FD_OVERWRITE_PROMPT)
        dlg.SetFilterIndex(filter_index)
        if dlg.ShowModal() != wx.ID_OK:
            return

        dirname = dlg.GetDirectory()
        filename = dlg.GetFilename()
        DEBUG_MSG('Save file dir:%s name:%s' % (dirname, filename), 3, self)
        format = exts[dlg.GetFilterIndex()]
        basename, ext = os.path.splitext(filename)
        if ext.startswith('.'):
            ext = ext[1:]
        if ext in ('svg', 'pdf', 'ps', 'eps', 'png') and format != ext:
            # looks like they forgot to set the image type drop
            # down, going with the extension.
            warnings.warn(
                'extension %s did not match the selected '
                'image type %s; going with %s' %
                (ext, format, ext), stacklevel=2)
            format = ext
        if default_dir != "":
            matplotlib.rcParams['savefig.directory'] = dirname
        try:
            self.canvas.figure.savefig(
                os.path.join(dirname, filename), format=format)
        except Exception as e:
            error_msg_wx(str(e)) 
Example #19
Source File: backend_wx.py    From CogAlg with MIT License 5 votes vote down vote up
def save_figure(self, *args):
        # Fetch the required filename and file type.
        filetypes, exts, filter_index = self.canvas._get_imagesave_wildcards()
        default_file = self.canvas.get_default_filename()
        dlg = wx.FileDialog(self.canvas.GetParent(),
                            "Save to file", "", default_file, filetypes,
                            wx.FD_SAVE | wx.FD_OVERWRITE_PROMPT)
        dlg.SetFilterIndex(filter_index)
        if dlg.ShowModal() == wx.ID_OK:
            dirname = dlg.GetDirectory()
            filename = dlg.GetFilename()
            DEBUG_MSG(
                'Save file dir:%s name:%s' %
                (dirname, filename), 3, self)
            format = exts[dlg.GetFilterIndex()]
            basename, ext = os.path.splitext(filename)
            if ext.startswith('.'):
                ext = ext[1:]
            if ext in ('svg', 'pdf', 'ps', 'eps', 'png') and format != ext:
                # looks like they forgot to set the image type drop
                # down, going with the extension.
                _log.warning('extension %s did not match the selected '
                             'image type %s; going with %s',
                             ext, format, ext)
                format = ext
            try:
                self.canvas.figure.savefig(
                    os.path.join(dirname, filename), format=format)
            except Exception as e:
                error_msg_wx(str(e)) 
Example #20
Source File: PluginInstall.py    From EventGhost with GNU General Public License v2.0 5 votes vote down vote up
def Export(self, pluginInfo):
        pluginData = self.GetPluginData(pluginInfo)
        #dialog = PluginOverviewDialog(
        #    eg.document.frame,
        #    "Plugin Information",
        #    pluginData=pluginData,
        #    basePath=pluginInfo.path,
        #    message="Do you want to save this plugin as a plugin file?"
        #)
        #result = dialog.ShowModal()
        #dialog.Destroy()
        #if result == wx.ID_CANCEL:
        #    return
        filename = os.path.basename(pluginInfo.path)
        title = eg.text.MainFrame.Menu.Export.replace("&", "").replace(".", "")
        dialog = wx.FileDialog(
            eg.document.frame,
            defaultFile=filename,
            message=title,
            wildcard="EventGhost Plugin (*.egplugin)|*.egplugin",
            style=wx.FD_SAVE | wx.FD_OVERWRITE_PROMPT
        )
        try:
            result = dialog.ShowModal()
            if result == wx.ID_CANCEL:
                return
            targetPath = dialog.GetPath()
        finally:
            dialog.Destroy()
        self.CreatePluginPackage(pluginInfo.path, targetPath, pluginData) 
Example #21
Source File: relay_board_gui.py    From R421A08-rs485-8ch-relay-board with MIT License 5 votes vote down vote up
def OnSaveAsClick(self, event=None):
        dlg = wx.FileDialog(self, 'Save settings as...', os.getcwd(), '', '*.relay',
                            style=wx.FD_SAVE | wx.FD_OVERWRITE_PROMPT)
        if dlg.ShowModal() == wx.ID_OK:
            self.m_settings_file = dlg.GetPath()
            if not self.m_settings_file.endswith('.relay'):
                self.m_settings_file += '.relay'
            self.save_settings(self.m_settings_file)
        dlg.Destroy() 
Example #22
Source File: backend_wx.py    From twitter-stock-recommendation with MIT License 5 votes vote down vote up
def save_figure(self, *args):
        # Fetch the required filename and file type.
        filetypes, exts, filter_index = self.canvas._get_imagesave_wildcards()
        default_file = self.canvas.get_default_filename()
        dlg = wx.FileDialog(self._parent, "Save to file", "", default_file,
                            filetypes,
                            wx.FD_SAVE | wx.FD_OVERWRITE_PROMPT)
        dlg.SetFilterIndex(filter_index)
        if dlg.ShowModal() == wx.ID_OK:
            dirname = dlg.GetDirectory()
            filename = dlg.GetFilename()
            DEBUG_MSG(
                'Save file dir:%s name:%s' %
                (dirname, filename), 3, self)
            format = exts[dlg.GetFilterIndex()]
            basename, ext = os.path.splitext(filename)
            if ext.startswith('.'):
                ext = ext[1:]
            if ext in ('svg', 'pdf', 'ps', 'eps', 'png') and format != ext:
                # looks like they forgot to set the image type drop
                # down, going with the extension.
                warnings.warn(
                    'extension %s did not match the selected '
                    'image type %s; going with %s' %
                    (ext, format, ext), stacklevel=0)
                format = ext
            try:
                self.canvas.figure.savefig(
                    os.path.join(dirname, filename), format=format)
            except Exception as e:
                error_msg_wx(str(e)) 
Example #23
Source File: backend_wx.py    From twitter-stock-recommendation with MIT License 5 votes vote down vote up
def trigger(self, *args):
        # Fetch the required filename and file type.
        filetypes, exts, filter_index = self.canvas._get_imagesave_wildcards()
        default_dir = os.path.expanduser(
            matplotlib.rcParams['savefig.directory'])
        default_file = self.canvas.get_default_filename()
        dlg = wx.FileDialog(self.canvas.GetTopLevelParent(), "Save to file",
                            default_dir, default_file, filetypes,
                            wx.FD_SAVE | wx.FD_OVERWRITE_PROMPT)
        dlg.SetFilterIndex(filter_index)
        if dlg.ShowModal() != wx.ID_OK:
            return

        dirname = dlg.GetDirectory()
        filename = dlg.GetFilename()
        DEBUG_MSG('Save file dir:%s name:%s' % (dirname, filename), 3, self)
        format = exts[dlg.GetFilterIndex()]
        basename, ext = os.path.splitext(filename)
        if ext.startswith('.'):
            ext = ext[1:]
        if ext in ('svg', 'pdf', 'ps', 'eps', 'png') and format != ext:
            # looks like they forgot to set the image type drop
            # down, going with the extension.
            warnings.warn(
                'extension %s did not match the selected '
                'image type %s; going with %s' %
                (ext, format, ext), stacklevel=0)
            format = ext
        if default_dir != "":
            matplotlib.rcParams['savefig.directory'] = dirname
        try:
            self.canvas.figure.savefig(
                os.path.join(dirname, filename), format=format)
        except Exception as e:
            error_msg_wx(str(e)) 
Example #24
Source File: toolbox.py    From goreviewpartner with GNU General Public License v3.0 5 votes vote down vote up
def save_all_file(filename, parent, config, filetype):
		initialdir = grp_config.get(config[0],config[1])
		dialog = wx.FileDialog(None,_('Choose a filename'), defaultDir=initialdir,defaultFile=filename, wildcard=filetype[0]+" "+filetype[1], style=wx.FD_SAVE | wx.FD_OVERWRITE_PROMPT)
		filename = None
		if dialog.ShowModal() == wx.ID_OK:
			filename = dialog.GetPath()
		dialog.Destroy()
		if filename:
			initialdir=os.path.dirname(filename)
			grp_config.set(config[0],config[1],initialdir)
		return filename 
Example #25
Source File: LapGUI.py    From laplacian-meshes with GNU General Public License v3.0 5 votes vote down vote up
def OnSaveScreenshot(self, evt):
        dlg = wx.FileDialog(self, "Choose a file", ".", "", "*", wx.FD_SAVE)
        if dlg.ShowModal() == wx.ID_OK:
            filename = dlg.GetFilename()
            dirname = dlg.GetDirectory()
            filepath = os.path.join(dirname, filename)
            saveImageGL(self.glcanvas, filepath)
        dlg.Destroy()
        return 
Example #26
Source File: gui.py    From report-ng with GNU General Public License v2.0 5 votes vote down vote up
def Save_Content_As(self, e):
            openFileDialog = wx.FileDialog(self, 'Save Content As', self.save_into_directory, '',
                                           'Content files (*.yaml; *.json)|*.yaml;*.json|All files (*.*)|*.*',
                                           wx.FD_SAVE | wx.wx.FD_OVERWRITE_PROMPT)
            if openFileDialog.ShowModal() == wx.ID_CANCEL:
                return
            json_ext = '.json'
            filename = openFileDialog.GetPath()
            self.status('Saving Content...')
            with open(filename, 'w') as h:
                if filename[-len(json_ext):] == json_ext:
                    h.write(self.report.content_dump_json().encode('utf-8'))
                else:
                    h.write(self.report.content_dump_yaml().encode('utf-8'))
            self.status('Content saved') 
Example #27
Source File: gui.py    From report-ng with GNU General Public License v2.0 5 votes vote down vote up
def Save_Scan_As(self, e):
            openFileDialog = wx.FileDialog(self, 'Save Scan As', self.save_into_directory, '',
                                           'Content files (*.yaml; *.json)|*.yaml;*.json|All files (*.*)|*.*',
                                           wx.FD_SAVE | wx.wx.FD_OVERWRITE_PROMPT)
            if openFileDialog.ShowModal() == wx.ID_CANCEL:
                return
            json_ext = '.json'
            filename = openFileDialog.GetPath()
            h = open(filename, 'w')
            if filename[-len(json_ext):] == json_ext:
                h.write(self.scan.dump_json(truncate=self.menu_view_i.IsChecked()).encode('utf-8'))
            else:
                h.write(self.scan.dump_yaml(truncate=self.menu_view_i.IsChecked()).encode('utf-8'))
            h.close()
            self.status('Scan saved') 
Example #28
Source File: yamled.py    From report-ng with GNU General Public License v2.0 5 votes vote down vote up
def File_Save_As(self, e):
        openFileDialog = wx.FileDialog(self, 'Save Yaml As', '', '',
                                       'Yaml files (*.yaml)|*.yaml|All files (*.*)|*.*',
                                       wx.FD_SAVE | wx.wx.FD_OVERWRITE_PROMPT)
        if openFileDialog.ShowModal() == wx.ID_CANCEL:
                return
        filename = openFileDialog.GetPath()
        self.filename = os.path.abspath(filename)
        self._Save() 
Example #29
Source File: backend_wx.py    From Mastering-Elasticsearch-7.0 with MIT License 5 votes vote down vote up
def save_figure(self, *args):
        # Fetch the required filename and file type.
        filetypes, exts, filter_index = self.canvas._get_imagesave_wildcards()
        default_file = self.canvas.get_default_filename()
        dlg = wx.FileDialog(self.canvas.GetParent(),
                            "Save to file", "", default_file, filetypes,
                            wx.FD_SAVE | wx.FD_OVERWRITE_PROMPT)
        dlg.SetFilterIndex(filter_index)
        if dlg.ShowModal() == wx.ID_OK:
            dirname = dlg.GetDirectory()
            filename = dlg.GetFilename()
            DEBUG_MSG(
                'Save file dir:%s name:%s' %
                (dirname, filename), 3, self)
            format = exts[dlg.GetFilterIndex()]
            basename, ext = os.path.splitext(filename)
            if ext.startswith('.'):
                ext = ext[1:]
            if ext in ('svg', 'pdf', 'ps', 'eps', 'png') and format != ext:
                # looks like they forgot to set the image type drop
                # down, going with the extension.
                _log.warning('extension %s did not match the selected '
                             'image type %s; going with %s',
                             ext, format, ext)
                format = ext
            try:
                self.canvas.figure.savefig(
                    os.path.join(dirname, filename), format=format)
            except Exception as e:
                error_msg_wx(str(e)) 
Example #30
Source File: pyResManDialog.py    From pyResMan with GNU General Public License v2.0 5 votes vote down vote up
def _buttonDebuggerScriptSaveFileOnButtonClick(self, event):
        scriptPathName = self._textctrlDebuggerScriptFilePathName.GetValue()
        if len(scriptPathName) == 0:
            saveFileDialog = wx.FileDialog(self, "Save smartcard debugger script file ...", "", "", "SCD files (*.scd)|*.scd", wx.FD_SAVE)
            if saveFileDialog.ShowModal() == wx.ID_CANCEL:
                return
            scriptPathName = saveFileDialog.GetPath()
            self._textctrlDebuggerScriptFilePathName.SetValue(scriptPathName)
        self.__debuggerScript_Save(scriptPathName);