本文整理汇总了Python中wx.FD_SAVE属性的典型用法代码示例。如果您正苦于以下问题:Python wx.FD_SAVE属性的具体用法?Python wx.FD_SAVE怎么用?Python wx.FD_SAVE使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类wx
的用法示例。
在下文中一共展示了wx.FD_SAVE属性的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __save
# 需要导入模块: import wx [as 别名]
# 或者: from wx import FD_SAVE [as 别名]
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()
示例2: Save_Template_As
# 需要导入模块: import wx [as 别名]
# 或者: from wx import FD_SAVE [as 别名]
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')
示例3: Save_Report_As
# 需要导入模块: import wx [as 别名]
# 或者: from wx import FD_SAVE [as 别名]
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')
示例4: OnSaveFig
# 需要导入模块: import wx [as 别名]
# 或者: from wx import FD_SAVE [as 别名]
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()
示例5: on_export
# 需要导入模块: import wx [as 别名]
# 或者: from wx import FD_SAVE [as 别名]
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)
示例6: compile
# 需要导入模块: import wx [as 别名]
# 或者: from wx import FD_SAVE [as 别名]
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}.")
示例7: save_app_as
# 需要导入模块: import wx [as 别名]
# 或者: from wx import FD_SAVE [as 别名]
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)
示例8: onSavePy
# 需要导入模块: import wx [as 别名]
# 或者: from wx import FD_SAVE [as 别名]
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))
示例9: OnSave
# 需要导入模块: import wx [as 别名]
# 或者: from wx import FD_SAVE [as 别名]
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)
示例10: OnSaveMesh
# 需要导入模块: import wx [as 别名]
# 或者: from wx import FD_SAVE [as 别名]
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
示例11: OnSaveScreenshot
# 需要导入模块: import wx [as 别名]
# 或者: from wx import FD_SAVE [as 别名]
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
示例12: Save_Content_As
# 需要导入模块: import wx [as 别名]
# 或者: from wx import FD_SAVE [as 别名]
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')
示例13: Save_Scan_As
# 需要导入模块: import wx [as 别名]
# 或者: from wx import FD_SAVE [as 别名]
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')
示例14: File_Save_As
# 需要导入模块: import wx [as 别名]
# 或者: from wx import FD_SAVE [as 别名]
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()
示例15: save_figure
# 需要导入模块: import wx [as 别名]
# 或者: from wx import FD_SAVE [as 别名]
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))