本文整理汇总了Python中javax.swing.JFileChooser.getSelectedFile方法的典型用法代码示例。如果您正苦于以下问题:Python JFileChooser.getSelectedFile方法的具体用法?Python JFileChooser.getSelectedFile怎么用?Python JFileChooser.getSelectedFile使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.swing.JFileChooser
的用法示例。
在下文中一共展示了JFileChooser.getSelectedFile方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: actionPerformed
# 需要导入模块: from javax.swing import JFileChooser [as 别名]
# 或者: from javax.swing.JFileChooser import getSelectedFile [as 别名]
def actionPerformed(self, event):
option = event.getActionCommand()
if option == 'Close':
self.dispose()
elif option == 'SCI':
chooser = JFileChooser()
returnVal = chooser.showSaveDialog(self)
if returnVal == JFileChooser.APPROVE_OPTION:
fileName = chooser.getSelectedFile().getPath()
f = open(fileName, 'w')
f.write("\t".join(["Het", "Fst", "0.5(1-pval)quantile", "median", "0.5(1+pval)quantile"]) + "\n")
for line in self.confLines:
f.write('\t'.join(map(lambda x: str(x), line)) + "\n")
f.close()
elif option == 'SLL':
chooser = JFileChooser()
returnVal = chooser.showSaveDialog(self)
if returnVal == JFileChooser.APPROVE_OPTION:
fileName = chooser.getSelectedFile().getPath()
f = open(fileName, 'w')
f.write("\t".join(["Locus", "Het", "Fst", "P(Simul Fst<sample Fst)"]) + "\n")
for i in range(self.data.size()):
line = self.data.elementAt(i)
lineList = [str(line.elementAt(0))]
lineList.append(str(line.elementAt(1)))
lineList.append(str(line.elementAt(2)))
lineList.append(str(line.elementAt(3)))
f.write("\t".join(lineList) + "\n")
f.close()
示例2: chooseFile
# 需要导入模块: from javax.swing import JFileChooser [as 别名]
# 或者: from javax.swing.JFileChooser import getSelectedFile [as 别名]
def chooseFile():
global frame, dataPath
global systemPanel, chartPanel
global isTemporal
fc = JFileChooser(dataPath)
retVal = fc.showOpenDialog(frame)
if retVal != JFileChooser.APPROVE_OPTION:
return
fname = fc.getSelectedFile().getAbsolutePath()
dataPath = os.sep.join(fname.split(os.sep)[:-1])
if isTemporal:
info(frame, "We need a file with information about the temporal point of each sample")
tfc = JFileChooser(dataPath)
tRetVal = tfc.showOpenDialog(frame)
if retVal != JFileChooser.APPROVE_OPTION:
return
tname = tfc.getSelectedFile().getAbsolutePath()
systemPanel.enableChartFun = False
chartPanel.resetData()
loadGenePop(fname)
if isTemporal:
if not loadTemporal(tname):
return
updateAll()
enablePanel(empiricalPanel)
示例3: openFile
# 需要导入模块: from javax.swing import JFileChooser [as 别名]
# 或者: from javax.swing.JFileChooser import getSelectedFile [as 别名]
def openFile(self, event):
'''
1. Check if current file in text area has unsaved changes
1.1 Prompt user for file saving
1.1.1 Save file
2. Display browser for user to choose file
3. Load file in text area
'''
self.consoleController.addText("NammuController: Opening file...")
self.handleUnsaved()
fileChooser = JFileChooser()
filter = FileNameExtensionFilter("ATF files", ["atf"])
fileChooser.setFileFilter(filter)
status = fileChooser.showDialog(self.view, "Choose file")
if status == JFileChooser.APPROVE_OPTION:
atfFile = fileChooser.getSelectedFile()
filename = atfFile.getCanonicalPath()
atfText = self.readTextFile(filename)
self.currentFilename = atfFile.getCanonicalPath()
self.atfAreaController.setAtfAreaText(atfText)
#TODO: Else, prompt user to choose again before closing
self.consoleController.addText(" OK\n")
示例4: chooseFile
# 需要导入模块: from javax.swing import JFileChooser [as 别名]
# 或者: from javax.swing.JFileChooser import getSelectedFile [as 别名]
def chooseFile(self, event):
chooseFile = JFileChooser()
filter = FileNameExtensionFilter("c files", ["c"])
chooseFile.addChoosableFileFilter(filter)
chooseFile.showDialog(self.uploadPanel, "Choose File")
chosenFile = chooseFile.getSelectedFile()
self.uploadTextField.text = str(chosenFile)
开发者ID:LucaBongiorni,项目名称:Directory-File-Listing-Parser-Importer,代码行数:9,代码来源:Directory-File-Listing-Parser-Importer.py
示例5: getFilePath
# 需要导入模块: from javax.swing import JFileChooser [as 别名]
# 或者: from javax.swing.JFileChooser import getSelectedFile [as 别名]
def getFilePath(self):
chooseFile = JFileChooser()
panel = JPanel()
ret = chooseFile.showDialog(panel, "Choose output file (*.msc)")
if ret == JFileChooser.APPROVE_OPTION:
file=chooseFile.getSelectedFile()
return file
示例6: save_pdf
# 需要导入模块: from javax.swing import JFileChooser [as 别名]
# 或者: from javax.swing.JFileChooser import getSelectedFile [as 别名]
def save_pdf(self, event):
from com.itextpdf.text.pdf import PdfWriter
from com.itextpdf.text import Document
fileChooser = JFileChooser()
fileChooser.setSelectedFile(java.io.File('%s.pdf' % self.view.network.name))
if fileChooser.showSaveDialog(self) == JFileChooser.APPROVE_OPTION:
f = fileChooser.getSelectedFile()
doc = Document()
writer = PdfWriter.getInstance(doc, java.io.FileOutputStream(f))
doc.open()
cb = writer.getDirectContent()
w = self.view.area.size.width
h = self.view.area.size.height
pw = 550
ph = 800
tp = cb.createTemplate(pw, ph)
g2 = tp.createGraphicsShapes(pw, ph)
at = java.awt.geom.AffineTransform()
s = min(float(pw) / w, float(ph) / h)
at.scale(s, s)
g2.transform(at)
self.view.area.pdftemplate = tp, s
self.view.area.paint(g2)
self.view.area.pdftemplate = None
g2.dispose()
cb.addTemplate(tp, 20, 0)
doc.close()
示例7: exportToHTML
# 需要导入模块: from javax.swing import JFileChooser [as 别名]
# 或者: from javax.swing.JFileChooser import getSelectedFile [as 别名]
def exportToHTML(self, event):
parentFrame = JFrame()
fileChooser = JFileChooser()
fileChooser.setSelectedFile(File("AutorizeReprort.html"));
fileChooser.setDialogTitle("Save Autorize Report")
userSelection = fileChooser.showSaveDialog(parentFrame)
if userSelection == JFileChooser.APPROVE_OPTION:
fileToSave = fileChooser.getSelectedFile()
enforcementStatusFilter = self.exportES.getSelectedItem()
htmlContent = """<html><title>Autorize Report by Barak Tawily</title>
<style>
.datagrid table { border-collapse: collapse; text-align: left; width: 100%; }
.datagrid {font: normal 12px/150% Arial, Helvetica, sans-serif; background: #fff; overflow: hidden; border: 1px solid #006699; -webkit-border-radius: 3px; -moz-border-radius: 3px; border-radius: 3px; }
.datagrid table td, .datagrid table th { padding: 3px 10px; }
.datagrid table thead th {background:-webkit-gradient( linear, left top, left bottom, color-stop(0.05, #006699), color-stop(1, #00557F) );background:-moz-linear-gradient( center top, #006699 5%, #00557F 100% );filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#006699', endColorstr='#00557F');background-color:#006699; color:#FFFFFF; font-size: 15px; font-weight: bold; border-left: 1px solid #0070A8; } .datagrid table thead th:first-child { border: none; }.datagrid table tbody td { color: #00496B; border-left: 1px solid #E1EEF4;font-size: 12px;font-weight: normal; }.datagrid table tbody .alt td { background: #E1EEF4; color: #00496B; }.datagrid table tbody td:first-child { border-left: none; }.datagrid table tbody tr:last-child td { border-bottom: none; }.datagrid table tfoot td div { border-top: 1px solid #006699;background: #E1EEF4;} .datagrid table tfoot td { padding: 0; font-size: 12px } .datagrid table tfoot td div{ padding: 2px; }.datagrid table tfoot td ul { margin: 0; padding:0; list-style: none; text-align: right; }.datagrid table tfoot li { display: inline; }.datagrid table tfoot li a { text-decoration: none; display: inline-block; padding: 2px 8px; margin: 1px;color: #FFFFFF;border: 1px solid #006699;-webkit-border-radius: 3px; -moz-border-radius: 3px; border-radius: 3px; background:-webkit-gradient( linear, left top, left bottom, color-stop(0.05, #006699), color-stop(1, #00557F) );background:-moz-linear-gradient( center top, #006699 5%, #00557F 100% );filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#006699', endColorstr='#00557F');background-color:#006699; }.datagrid table tfoot ul.active, .datagrid table tfoot ul a:hover { text-decoration: none;border-color: #006699; color: #FFFFFF; background: none; background-color:#00557F;}div.dhtmlx_window_active, div.dhx_modal_cover_dv { position: fixed !important; }
table {
width: 100%;
table-layout: fixed;
}
td {
border: 1px solid #35f;
overflow: hidden;
text-overflow: ellipsis;
}
td.a {
width: 13%;
white-space: nowrap;
}
td.b {
width: 9%;
word-wrap: break-word;
}
</style>
<body>
<h1>Autorize Report<h1>
<div class="datagrid"><table>
<thead><tr><th>URL</th><th>Authorization Enforcement Status</th></tr></thead>
<tbody>"""
for i in range(0,self._log.size()):
color = ""
if self._log.get(i)._enfocementStatus == self._enfocementStatuses[0]:
color = "red"
if self._log.get(i)._enfocementStatus == self._enfocementStatuses[1]:
color = "yellow"
if self._log.get(i)._enfocementStatus == self._enfocementStatuses[2]:
color = "LawnGreen"
if enforcementStatusFilter == "All Statuses":
htmlContent += "<tr bgcolor=\"%s\"><td><a href=\"%s\">%s</a></td><td>%s</td></tr>" % (color,self._log.get(i)._url,self._log.get(i)._url, self._log.get(i)._enfocementStatus)
else:
if enforcementStatusFilter == self._log.get(i)._enfocementStatus:
htmlContent += "<tr bgcolor=\"%s\"><td><a href=\"%s\">%s</a></td><td>%s</td></tr>" % (color,self._log.get(i)._url,self._log.get(i)._url, self._log.get(i)._enfocementStatus)
htmlContent += "</tbody></table></div></body></html>"
f = open(fileToSave.getAbsolutePath(), 'w')
f.writelines(htmlContent)
f.close()
示例8: onOpenFolder
# 需要导入模块: from javax.swing import JFileChooser [as 别名]
# 或者: from javax.swing.JFileChooser import getSelectedFile [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()
示例9: onClick
# 需要导入模块: from javax.swing import JFileChooser [as 别名]
# 或者: from javax.swing.JFileChooser import getSelectedFile [as 别名]
def onClick(self, e):
chooseFile = JFileChooser()
filter = FileNameExtensionFilter("c files", ["c"])
chooseFile.addChoosableFileFilter(filter)
ret = chooseFile.showDialog(self.panel, "Choose file")
if ret == JFileChooser.APPROVE_OPTION:
file = chooseFile.getSelectedFile()
print file
示例10: loadPopNames
# 需要导入模块: from javax.swing import JFileChooser [as 别名]
# 或者: from javax.swing.JFileChooser import getSelectedFile [as 别名]
def loadPopNames():
global frame, empiricalPanel
fc = JFileChooser(dataPath)
retVal = fc.showOpenDialog(frame)
if retVal == JFileChooser.APPROVE_OPTION:
file = fc.getSelectedFile()
loadFilePopNames(file)
updateAll()
enablePanel(empiricalPanel)
示例11: getFile
# 需要导入模块: from javax.swing import JFileChooser [as 别名]
# 或者: from javax.swing.JFileChooser import getSelectedFile [as 别名]
def getFile(self,button):
dlg = JFileChooser()
result = dlg.showOpenDialog(None)
if result == JFileChooser.APPROVE_OPTION:
f = dlg.getSelectedFile()
path = f.getPath()
self.FileText.setText(path)
try:
self.getIPList(path)
except:
exit(0)
示例12: _configFileDialogue
# 需要导入模块: from javax.swing import JFileChooser [as 别名]
# 或者: from javax.swing.JFileChooser import getSelectedFile [as 别名]
def _configFileDialogue(self):
from javax.swing import JFileChooser
from javax.swing.filechooser import FileNameExtensionFilter
fileDialogue = JFileChooser(self.dssFilePath)
filter = FileNameExtensionFilter("Configuration file (*.yml; *.yaml)",
["yaml", "yml"])
fileDialogue.setFileFilter(filter)
ret = fileDialogue.showOpenDialog(self.mainWindow)
if ret == JFileChooser.APPROVE_OPTION:
return fileDialogue.getSelectedFile().getAbsolutePath()
else:
raise CancelledError("Config file selection was cancelled.")
示例13: set_plugin_loc
# 需要导入模块: from javax.swing import JFileChooser [as 别名]
# 或者: from javax.swing.JFileChooser import getSelectedFile [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'])
示例14: GnitPickFileChooser
# 需要导入模块: from javax.swing import JFileChooser [as 别名]
# 或者: from javax.swing.JFileChooser import getSelectedFile [as 别名]
class GnitPickFileChooser(ActionListener):
def __init__(self,frm):
self.frame = frm
def actionPerformed(self,e):
self.chooser = JFileChooser()
self.option = self.chooser.showOpenDialog(self.frame)
if (self.option == JFileChooser.APPROVE_OPTION):
self.frame.statusbar.setText("You chose " + self.chooser.getSelectedFile().getName())
else:
self.frame.statusbar.setText("You cancelled.")
示例15: onClick
# 需要导入模块: from javax.swing import JFileChooser [as 别名]
# 或者: from javax.swing.JFileChooser import getSelectedFile [as 别名]
def onClick(self, e):
chooseFile = JFileChooser()
filter = FileNameExtensionFilter("SQLite", ["sqlite"])
chooseFile.addChoosableFileFilter(filter)
ret = chooseFile.showDialog(self.panel, "Select SQLite")
if ret == JFileChooser.APPROVE_OPTION:
file = chooseFile.getSelectedFile()
text = self.readPath(file)
self.area.setText(text)