本文整理汇总了Python中javax.swing.JFileChooser.setMultiSelectionEnabled方法的典型用法代码示例。如果您正苦于以下问题:Python JFileChooser.setMultiSelectionEnabled方法的具体用法?Python JFileChooser.setMultiSelectionEnabled怎么用?Python JFileChooser.setMultiSelectionEnabled使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.swing.JFileChooser
的用法示例。
在下文中一共展示了JFileChooser.setMultiSelectionEnabled方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: MultiFileDialog
# 需要导入模块: from javax.swing import JFileChooser [as 别名]
# 或者: from javax.swing.JFileChooser import setMultiSelectionEnabled [as 别名]
def MultiFileDialog(title):
#hide/show debug prints
verbose = 0
# Choose image file(s) to open
fc = JFileChooser()
fc.setMultiSelectionEnabled(True)
fc.setDialogTitle(title)
sdir = OpenDialog.getDefaultDirectory()
if sdir!=None:
fdir = File(sdir)
if fdir!=None:
fc.setCurrentDirectory(fdir)
returnVal = fc.showOpenDialog(IJ.getInstance())
if returnVal!=JFileChooser.APPROVE_OPTION:
return
files = fc.getSelectedFiles()
paths = []
for i in range(len(files)):
paths.append(os.path.join(files[i].getParent(), files[i].getName()))
if verbose > 0:
for i in range(len(files)):
path = os.path.join(files[i].getParent(), files[i].getName())
print "Path: " + path
return paths
示例2: createFileChooserDialog
# 需要导入模块: from javax.swing import JFileChooser [as 别名]
# 或者: from javax.swing.JFileChooser import setMultiSelectionEnabled [as 别名]
def createFileChooserDialog(filters, filename, prefs, prefkey, multiselect):
"""
Creates a file chooser dialog that remembers its last directory.
"""
fileChooser = JFileChooser()
# Add filters
if not hasattr(filters, '__iter__'):
filters = (filters,)
if filters:
for filter in filters:
fileChooser.addChoosableFileFilter(filter)
fileChooser.fileFilter = filters[0]
# Enable/disable multiple file select
fileChooser.setMultiSelectionEnabled(multiselect)
# Restore the last directory
if prefs and prefkey:
defaultDirName = prefs.get(prefkey, None)
if defaultDirName:
defaultDirectory = File(defaultDirName)
if defaultDirectory.exists():
fileChooser.currentDirectory = defaultDirectory
# Preset the file name
if filename:
fileChooser.selectedFile = File(fileChooser.currentDirectory, filename)
return fileChooser
示例3: FolderDialog
# 需要导入模块: from javax.swing import JFileChooser [as 别名]
# 或者: from javax.swing.JFileChooser import setMultiSelectionEnabled [as 别名]
def FolderDialog(title, folder):
fc = JFileChooser()
fc.setMultiSelectionEnabled(False)
fc.setDialogTitle(title)
fc.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
fc.setAcceptAllFileFilterUsed(False);
if folder ==None:
sdir = OpenDialog.getDefaultDirectory()
else:
sdir = folder
if sdir!=None:
fdir = File(sdir)
if fdir!=None:
fc.setCurrentDirectory(fdir)
returnVal = fc.showOpenDialog(IJ.getInstance())
if returnVal!=JFileChooser.APPROVE_OPTION:
return
folder = fc.getSelectedFile();
path = os.path.join(folder.getParent(), folder.getName())
return path
示例4: actionPerformed
# 需要导入模块: from javax.swing import JFileChooser [as 别名]
# 或者: from javax.swing.JFileChooser import setMultiSelectionEnabled [as 别名]
def actionPerformed(self, actionEvent):
global yara_rules
global yara_path
if actionEvent.getSource() is self.menuItem:
yara_path = self._yara_exe_txtField.getText()
yara_rules = self._yara_rules_files
t = Thread(self)
t.start()
elif actionEvent.getSource() is self._yara_clear_button:
# Delete the LogEntry objects from the log
row = self._log.size()
self._lock.acquire()
self._log.clear()
# Update the Table
self.fireTableRowsDeleted(0, row)
# Clear data regarding any selected LogEntry objects from the request / response viewers
self._requestViewer.setMessage([], True)
self._responseViewer.setMessage([], False)
self._currentlyDisplayedItem = None
self._lock.release()
elif actionEvent.getSource() is self._yara_rules_select_files_button:
fileChooser = JFileChooser()
yarFilter = FileNameExtensionFilter("Yara Rules", ["yar"])
fileChooser.addChoosableFileFilter(yarFilter)
fileChooser.setFileFilter(yarFilter)
fileChooser.setMultiSelectionEnabled(True)
fileChooser.setFileSelectionMode(JFileChooser.FILES_ONLY)
ret = fileChooser.showOpenDialog(None)
if ret == JFileChooser.APPROVE_OPTION:
self._yara_rules_files.clear()
for file in fileChooser.getSelectedFiles():
self._yara_rules_files.add(file.getPath())
self._yara_rules_fileList.setListData(self._yara_rules_files)
else:
stdout.println("Unknown Event Received.")
示例5: BurpExtender
# 需要导入模块: from javax.swing import JFileChooser [as 别名]
# 或者: from javax.swing.JFileChooser import setMultiSelectionEnabled [as 别名]
class BurpExtender(IBurpExtender, IMessageEditorTabFactory, ITab, IExtensionStateListener):
EXTENSION_NAME = "Protobuf Editor"
def __init__(self):
self.descriptors = OrderedDict()
self.chooser = JFileChooser()
self.chooser.addChoosableFileFilter(PROTO_FILENAME_EXTENSION_FILTER)
self.chooser.setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES)
self.chooser.setMultiSelectionEnabled(True)
def registerExtenderCallbacks(self, callbacks):
self.callbacks = callbacks
self.helpers = callbacks.getHelpers()
self.enabled = False
try:
process = subprocess.Popen(['protoc', '--version'],
stdin=subprocess.PIPE,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE)
output, error = process.communicate()
self.enabled = output.startswith('libprotoc')
if error:
raise RuntimeError(error)
except (OSError, RuntimeError) as error:
self.callbacks.getStderr().write(
"Error calling protoc: %s\n" % (error.message, ))
if not self.enabled:
return
rules = []
saved_rules = callbacks.loadExtensionSetting('rules')
if saved_rules:
rules = json.loads(base64.b64decode(saved_rules))
# For checkboxes to be rendered in a table model, the
# type has to be java.lang.Boolean, not a Python bool.
for rule in rules:
rule[-1] = Boolean(rule[-1])
self.table = ParameterProcessingRulesTable(self, *rules)
callbacks.setExtensionName(self.EXTENSION_NAME)
callbacks.registerExtensionStateListener(self)
callbacks.registerMessageEditorTabFactory(self)
callbacks.addSuiteTab(self)
return
def createNewInstance(self, controller, editable):
return ProtobufEditorTab(self, controller, editable)
def getTabCaption(self):
return self.EXTENSION_NAME
def getUiComponent(self):
return self.table
def extensionUnloaded(self):
if not self.table.rules:
return
rules = self.table.rules
# The default JSONENcoder cannot dump a java.lang.Boolean type,
# so convert it to a Python bool. (We'll have to change it back
# when loading the rules again.
for rule in rules:
rule[-1] = bool(rule[-1])
self.callbacks.saveExtensionSetting(
'rules', base64.b64encode(json.dumps(rules)))
return