本文整理汇总了Python中javax.swing.JFileChooser.setFileSelectionMode方法的典型用法代码示例。如果您正苦于以下问题:Python JFileChooser.setFileSelectionMode方法的具体用法?Python JFileChooser.setFileSelectionMode怎么用?Python JFileChooser.setFileSelectionMode使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.swing.JFileChooser
的用法示例。
在下文中一共展示了JFileChooser.setFileSelectionMode方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: onOpenFolder
# 需要导入模块: from javax.swing import JFileChooser [as 别名]
# 或者: from javax.swing.JFileChooser import setFileSelectionMode [as 别名]
def onOpenFolder(self, event):
chooseFile = JFileChooser()
chooseFile.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
ret = chooseFile.showDialog(self, "Choose folder")
if ret == JFileChooser.APPROVE_OPTION:
self.faile= chooseFile.getSelectedFile()
self.cbOutDir.addItem(self.faile.getPath())
self.cbOutDir.selectedItem= self.faile.getPath()
示例2: set_plugin_loc
# 需要导入模块: from javax.swing import JFileChooser [as 别名]
# 或者: from javax.swing.JFileChooser import setFileSelectionMode [as 别名]
def set_plugin_loc(self, event):
"""Attempts to load plugins from a specified location"""
if self.config['Plugin Folder'] is not None:
choose_plugin_location = JFileChooser(self.config['Plugin Folder'])
else:
choose_plugin_location = JFileChooser()
choose_plugin_location.setFileSelectionMode(
JFileChooser.DIRECTORIES_ONLY)
choose_plugin_location.showDialog(self.tab, "Choose Folder")
chosen_folder = choose_plugin_location.getSelectedFile()
self.config['Plugin Folder'] = chosen_folder.getAbsolutePath()
self._load_plugins(self.config['Plugin Folder'])
示例3: get_source_input
# 需要导入模块: from javax.swing import JFileChooser [as 别名]
# 或者: from javax.swing.JFileChooser import setFileSelectionMode [as 别名]
def get_source_input(self, event):
"""Sets the source dir/file for parsing"""
source_chooser = JFileChooser()
source_chooser.setFileSelectionMode(
JFileChooser.FILES_AND_DIRECTORIES)
source_chooser.showDialog(self.tab, "Choose Source Location")
chosen_source = source_chooser.getSelectedFile()
try:
self.source_input = chosen_source.getAbsolutePath()
except AttributeError:
pass
if self.source_input is not None:
self.update_scroll("[*] Source location: %s" % self.source_input)
self.curr_conf.setText(self.source_input)
示例4: browse
# 需要导入模块: from javax.swing import JFileChooser [as 别名]
# 或者: from javax.swing.JFileChooser import setFileSelectionMode [as 别名]
def browse(self, event=None):
'''
Open new dialog for the user to select a path as default working dir.
'''
default_path = self.wd_field.getText()
if not os.path.isdir(default_path):
default_path = os.getcwd()
fileChooser = JFileChooser(default_path)
fileChooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY)
# Fixed showDialog bug using showOpenDialog instead. The former was
# duplicating the last folder name in the path due to a Java bug in
# OSX in the implementation of JFileChooser!
status = fileChooser.showOpenDialog(self)
if status == JFileChooser.APPROVE_OPTION:
self.wd_field.setText(fileChooser.getSelectedFile().toString())
示例5: Find_Plaso_Dir
# 需要导入模块: from javax.swing import JFileChooser [as 别名]
# 或者: from javax.swing.JFileChooser import setFileSelectionMode [as 别名]
def Find_Plaso_Dir(self, e):
chooseFile = JFileChooser()
filter = FileNameExtensionFilter("All", ["*.*"])
chooseFile.addChoosableFileFilter(filter)
chooseFile.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY)
ret = chooseFile.showDialog(self.panel0, "Find Plaso Directory")
if ret == JFileChooser.APPROVE_OPTION:
file = chooseFile.getSelectedFile()
Canonical_file = file.getCanonicalPath()
#text = self.readPath(file)
self.local_settings.setSetting('Plaso_Directory', Canonical_file)
self.Program_Executable_TF.setText(Canonical_file)
示例6: openGVL
# 需要导入模块: from javax.swing import JFileChooser [as 别名]
# 或者: from javax.swing.JFileChooser import setFileSelectionMode [as 别名]
def openGVL():
from javax.swing import JFileChooser
GUIUtil=PluginServices.getPluginServices("com.iver.cit.gvsig.cad").getClassLoader().loadClass("com.iver.cit.gvsig.gui.GUIUtil")
chooser = JFileChooser()
chooser.setFileFilter(GUIUtil().createFileFilter("GVL Legend File",["gvl"]))
from java.util.prefs import Preferences
lastPath = Preferences.userRoot().node("gvsig.foldering").get("DataFolder", "null")
chooser.setCurrentDirectory(File(lastPath))
chooser.setFileSelectionMode(JFileChooser.FILES_ONLY)
returnVal = chooser.showOpenDialog(None)
if returnVal == chooser.APPROVE_OPTION:
gvlPath = chooser.getSelectedFile().getPath()
elif returnVal == chooser.CANCEL_OPTION:
JOptionPane.showMessageDialog(None, "You have to open a .gvl file. Retry!","Batch Legend",JOptionPane.WARNING_MESSAGE)
gvlPath = ""
return gvlPath
示例7: FolderDialog
# 需要导入模块: from javax.swing import JFileChooser [as 别名]
# 或者: from javax.swing.JFileChooser import setFileSelectionMode [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
示例8: actionPerformed
# 需要导入模块: from javax.swing import JFileChooser [as 别名]
# 或者: from javax.swing.JFileChooser import setFileSelectionMode [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.")
示例9: check_directory
# 需要导入模块: from javax.swing import JFileChooser [as 别名]
# 或者: from javax.swing.JFileChooser import setFileSelectionMode [as 别名]
def check_directory(path):
if (os.path.lexists(path)):
contents=os.listdir(path)
if (contents.count("install-birch")==0):
print_console("The selected directory "+path+" does NOT contain a BIRCH installation!")
message="The selected path does NOT contain a BIRCH installation.\nPlease select the base directory of the installation that you wish to update,\nOr click \"no\" to cancel update."
reload = JOptionPane.showConfirmDialog(None,message, "Input",JOptionPane.YES_NO_OPTION);
if (reload==JOptionPane.NO_OPTION):
print_console("User aborted install.")
commonlib.shutdown()
fc = JFileChooser();
fc.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
fc.showOpenDialog(None);
path = fc.getSelectedFile().getPath();
check_directory(path)
else:
ARGS.install_dir=path
print_console("The selected directory "+path+" contains a BIRCH installation, it will be updated")
示例10: BurpExtender
# 需要导入模块: from javax.swing import JFileChooser [as 别名]
# 或者: from javax.swing.JFileChooser import setFileSelectionMode [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
示例11: JFileChooser
# 需要导入模块: from javax.swing import JFileChooser [as 别名]
# 或者: from javax.swing.JFileChooser import setFileSelectionMode [as 别名]
import jmri
import java
import com.csvreader
from javax.swing import JFileChooser, JOptionPane
from javax.swing.filechooser import FileNameExtensionFilter
dialogTitle = "Class Keys Report"
print " {}".format(dialogTitle)
keyList = []
# Select a Java program or package directory to be analyzed.
fc = JFileChooser(FileUtil.getProgramPath())
fc.setDialogTitle(dialogTitle)
fc.setFileFilter(FileNameExtensionFilter("Java Program", ["java"]));
fc.setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES)
ret = fc.showOpenDialog(None)
if ret == JFileChooser.APPROVE_OPTION:
selectedItem = fc.getSelectedFile().toString()
else:
print 'No file selected, bye'
quit()
# RegEx patterns. Capture the first word after the start of the match string.
# The first one looks for a word within double quotes.
# The second one looks for a plain word.
# A word contains a-z, A-Z, 0-9 or underscore characters.
reStrKey = re.compile('\W*"(\w+)"\W*[,)]')
reVarKey = re.compile('\W*(\w+)\W')
##
示例12: FolderChooser
# 需要导入模块: from javax.swing import JFileChooser [as 别名]
# 或者: from javax.swing.JFileChooser import setFileSelectionMode [as 别名]
def FolderChooser(JFrame):
chooseFolder = JFileChooser()
chooseFolder.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY)
chooseFolder.showOpenDialog(JFrame)
return chooseFolder.selectedFile
示例13: BurpExtender
# 需要导入模块: from javax.swing import JFileChooser [as 别名]
# 或者: from javax.swing.JFileChooser import setFileSelectionMode [as 别名]
#.........这里部分代码省略.........
source = DOMSource(doc)
result = StreamResult(File(xmlPath))
transformer.transform(source, result)
def generateReport(self,event):
if self.reportType.getSelectedItem() == "HTML":
path = self.reportToHTML()
if self.reportType.getSelectedItem() == "XLSX":
path = self.reportToXLS()
if self.reportType.getSelectedItem() == "DOCX":
path = self.generateReportFromDocxTemplate('template.docx',"newfile.docx", 'word/document.xml')
n = JOptionPane.showConfirmDialog(None, "Report generated successfuly:\n%s\nWould you like to open it?" % (path), "PT Manager", JOptionPane.YES_NO_OPTION)
if n == JOptionPane.YES_OPTION:
os.system('"' + path + '"') # Bug! stucking burp until the file get closed
def exportProj(self,event):
self.chooser.setDialogTitle("Save project")
Ffilter = FileNameExtensionFilter("Zip files", ["zip"])
self.chooser.setFileFilter(Ffilter)
returnVal = self.chooser.showSaveDialog(None)
if returnVal == JFileChooser.APPROVE_OPTION:
dst = str(self.chooser.getSelectedFile())
shutil.make_archive(dst,"zip",self.getCurrentProjPath())
self.popup("Project export successfuly")
def importProj(self,event):
self.chooser.setDialogTitle("Select project zip to directory")
Ffilter = FileNameExtensionFilter("Zip files", ["zip"])
self.chooser.setFileFilter(Ffilter)
returnVal = self.chooser.showOpenDialog(None)
if returnVal == JFileChooser.APPROVE_OPTION:
zipPath = str(self.chooser.getSelectedFile())
self.chooser.setDialogTitle("Select project directory")
self.chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY)
returnVal = self.chooser.showOpenDialog(None)
if returnVal == JFileChooser.APPROVE_OPTION:
projPath = str(self.chooser.getSelectedFile()) + "/PTManager"
with zipfile.ZipFile(zipPath, "r") as z:
z.extractall(projPath)
xmlPath = projPath + "/project.xml"
document = self.getXMLDoc(xmlPath)
nodeList = document.getDocumentElement().getChildNodes()
projName = nodeList.item(0).getTextContent()
nodeList.item(1).setTextContent(projPath)
self.saveXMLDoc(document, xmlPath)
self.config.set('projects', projName, projPath)
self.saveCfg()
self.reloadProjects()
self.currentProject.getModel().setSelectedItem(projName)
self.clearVulnerabilityTab()
def reportToXLS(self):
if not xlsxwriterImported:
self.popup("xlsxwriter library is not imported")
return
workbook = xlsxwriter.Workbook(self.getCurrentProjPath() + '/PT Manager Report.xlsx')
worksheet = workbook.add_worksheet()
bold = workbook.add_format({'bold': True})
worksheet.write(0, 0, "Vulnerability Name", bold)
worksheet.write(0, 1, "Threat Level", bold)
worksheet.write(0, 2, "Description", bold)
worksheet.write(0, 3, "Mitigation", bold)
row = 1
for i in range(0,self._log.size()):
worksheet.write(row, 0, self._log.get(i).getName())