本文整理汇总了Python中pyface.api.FileDialog.open方法的典型用法代码示例。如果您正苦于以下问题:Python FileDialog.open方法的具体用法?Python FileDialog.open怎么用?Python FileDialog.open使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pyface.api.FileDialog
的用法示例。
在下文中一共展示了FileDialog.open方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _show_open_dialog
# 需要导入模块: from pyface.api import FileDialog [as 别名]
# 或者: from pyface.api.FileDialog import open [as 别名]
def _show_open_dialog(self, parent):
"""
Show the dialog to open a project.
"""
# Determine the starting point for browsing. It is likely most
# projects will be stored in the default path used when creating new
# projects.
default_path = self.model_service.get_default_path()
project_class = self.model_service.factory.PROJECT_CLASS
if self.model_service.are_projects_files():
dialog = FileDialog(parent=parent, default_directory=default_path,
title='Open Project')
if dialog.open() == OK:
path = dialog.path
else:
path = None
else:
dialog = DirectoryDialog(parent=parent, default_path=default_path,
message='Open Project')
if dialog.open() == OK:
path = project_class.get_pickle_filename(dialog.path)
if File(path).exists:
path = dialog.path
else:
error(parent, 'Directory does not contain a recognized '
'project')
path = None
else:
path = None
return path
示例2: save
# 需要导入模块: from pyface.api import FileDialog [as 别名]
# 或者: from pyface.api.FileDialog import open [as 别名]
def save(self):
extensions = [ '*.bmp', '*.gif', '*.jpg', '*.pdf',
'*.png', '*.svg', '*.tif', '*.xbm' ]
wildcard = FileDialog.create_wildcard('From file name', extensions)
dialog = FileDialog(action = 'save as',
default_directory = self.default_directory,
parent = self.window.control,
wildcard = wildcard)
if dialog.open() == OK:
filename = dialog.path
extension = os.path.splitext(filename)[1]
if not extension:
extension = '.png'
filename += extension
try:
# FIXME: Expose size and background color?
self.editor_area.active_editor.save(filename, bgcolor='white')
except Exception as exc:
msg = 'Failed to save image in %s format' % extension.upper()
dialog = MessageDialog(title = 'Error saving',
message = msg,
detail = str(exc),
parent = self.window.control,
severity = 'error')
dialog.open()
示例3: action_save
# 需要导入模块: from pyface.api import FileDialog [as 别名]
# 或者: from pyface.api.FileDialog import open [as 别名]
def action_save(self, info):
# First make a copy of the frame we will save
save_frame = info.object.camera.frame.copy()
# Then find out where to save it
dialog = FileDialog(parent=info.ui.control, action="save as", modal=True, title="Save Image")
try:
dialog.default_directory = info.object._current_folder
except TraitError:
pass # thrown if _current_folder is None
dialog.open()
path = dialog.path
# Store the directory for the next time
info.object._current_folder = dialog.directory
if dialog.return_code != OK:
return
# Default is PNG
if "." not in path:
path += ".png"
# Save it
scipy.misc.imsave(path, save_frame)
示例4: OpenFileDialog
# 需要导入模块: from pyface.api import FileDialog [as 别名]
# 或者: from pyface.api.FileDialog import open [as 别名]
def OpenFileDialog(action, wildcard, self):
from pyface.api import FileDialog, OK
doaction = action
if action == "new":
doaction = "save as"
dialog = FileDialog(action=doaction, wildcard=wildcard)
dialog.open()
if dialog.return_code == OK:
self.filedir = dialog.directory
self.filename = dialog.filename
self.Configuration_File = os.path.join(dialog.directory, dialog.filename)
if action == "open":
self._config = load_config(dialog.path, self.config_class)
self._config.configure_traits(view=self.config_view())
self.saved = False
self.config_changed = True
if action == "new":
self._config = self.config_class()
self._config.configure_traits(view=self.config_view())
self._save_to_file()
self.saved = False
self.config_changed = True
if action == "save as":
self._save_to_file()
self.saved = True
self.config_changed = False
示例5: _save_as_fired
# 需要导入模块: from pyface.api import FileDialog [as 别名]
# 或者: from pyface.api.FileDialog import open [as 别名]
def _save_as_fired(self):
# create raw
try:
raw = self.model.get_raw()
except Exception as err:
error(None, str(err), "Error Creating KIT Raw")
raise
# find default path
stem, _ = os.path.splitext(self.sqd_file)
if not stem.endswith('raw'):
stem += '-raw'
default_path = stem + '.fif'
# save as dialog
dlg = FileDialog(action="save as",
wildcard="fiff raw file (*.fif)|*.fif",
default_path=default_path)
dlg.open()
if dlg.return_code != OK:
return
fname = dlg.path
if not fname.endswith('.fif'):
fname += '.fif'
if os.path.exists(fname):
answer = confirm(None, "The file %r already exists. Should it "
"be replaced?", "Overwrite File?")
if answer != YES:
return
self.queue.put((raw, fname))
self.queue_len += 1
示例6: save_as
# 需要导入模块: from pyface.api import FileDialog [as 别名]
# 或者: from pyface.api.FileDialog import open [as 别名]
def save_as(self):
dlg = FileDialog( action='save as', wildcard='*.rep')
dlg.open()
if dlg.filename!='':
fi = file(dlg.filename,'w')
dump(self,fi)
fi.close()
示例7: save_config_file
# 需要导入模块: from pyface.api import FileDialog [as 别名]
# 或者: from pyface.api.FileDialog import open [as 别名]
def save_config_file(self, ui_info):
dialog = FileDialog(action="save as", default_filename="config.ini")
dialog.open()
if dialog.return_code == OK:
save_config(self.pipeline, ui_info.ui.context["object"].project_info.config_file)
if dialog.path != ui_info.ui.context["object"].project_info.config_file:
shutil.copy(ui_info.ui.context["object"].project_info.config_file, dialog.path)
示例8: load_config_file
# 需要导入模块: from pyface.api import FileDialog [as 别名]
# 或者: from pyface.api.FileDialog import open [as 别名]
def load_config_file(self, ui_info):
dialog = FileDialog(action="open", wildcard="*.ini")
dialog.open()
if dialog.return_code == OK:
if dialog.path != ui_info.ui.context["object"].project_info.config_file:
shutil.copy(dialog.path, ui_info.ui.context["object"].project_info.config_file)
load_config(self.pipeline, ui_info.ui.context["object"].project_info.config_file)
示例9: load
# 需要导入模块: from pyface.api import FileDialog [as 别名]
# 或者: from pyface.api.FileDialog import open [as 别名]
def load(self):
dlg = FileDialog( action='open', wildcard='*.rep')
dlg.open()
if dlg.filename!='':
fi = file(dlg.filename,'rb')
s = load(fi)
self.copy_traits(s)
fi.close()
示例10: _choose_fw_fired
# 需要导入模块: from pyface.api import FileDialog [as 别名]
# 或者: from pyface.api.FileDialog import open [as 别名]
def _choose_fw_fired(self):
dialog = FileDialog(label='Choose Firmware File',
action='open', wildcard=self.file_wildcard)
dialog.open()
if dialog.return_code == OK:
filepath = os.path.join(dialog.directory, dialog.filename)
self.load_ihx(filepath)
else:
self.set_status('Error while selecting file')
示例11: run_script
# 需要导入模块: from pyface.api import FileDialog [as 别名]
# 或者: from pyface.api.FileDialog import open [as 别名]
def run_script(self):
dlg = FileDialog( action='open', wildcard='*.py')
dlg.open()
if dlg.filename!='':
#~ try:
rx = self
b = rx.Beamformer
script = dlg.path
execfile(dlg.path)
示例12: _open
# 需要导入模块: from pyface.api import FileDialog [as 别名]
# 或者: from pyface.api.FileDialog import open [as 别名]
def _open():
if open_show_dialog:
open_dlg = FileDialog(action='open')
open_dlg.open()
self.editor_area.active_tabwidget = self
if open_dlg.return_code == OK:
open_file_action(open_dlg.path)
else:
open_file_action()
示例13: ask_user_for_loadfile
# 需要导入模块: from pyface.api import FileDialog [as 别名]
# 或者: from pyface.api.FileDialog import open [as 别名]
def ask_user_for_loadfile(title=None):
from pyface.api import FileDialog, OK
dialog = FileDialog(action='open')
if title is not None:
dialog.title = title
dialog.open()
if dialog.return_code != OK:
return
return os.path.join( dialog.directory, dialog.filename )
示例14: _choose_fw_fired
# 需要导入模块: from pyface.api import FileDialog [as 别名]
# 或者: from pyface.api.FileDialog import open [as 别名]
def _choose_fw_fired(self):
""" Activate file dialog window to choose IntelHex firmware file. """
dialog = FileDialog(label='Choose Firmware File',
action='open', wildcard=self.file_wildcard)
dialog.open()
if dialog.return_code == OK:
filepath = os.path.join(dialog.directory, dialog.filename)
self.load_ihx(filepath)
else:
self.clear('Error while selecting file')
示例15: filedialog
# 需要导入模块: from pyface.api import FileDialog [as 别名]
# 或者: from pyface.api.FileDialog import open [as 别名]
def filedialog():
"""
Open a simple file dialog to pick a file
"""
from pyface.api import FileDialog, OK, confirm, YES
dialog = FileDialog(action="open")
dialog.open()
if dialog.return_code == OK:
return dialog.path
else:
quit()