本文整理汇总了Python中javax.swing.JFileChooser方法的典型用法代码示例。如果您正苦于以下问题:Python swing.JFileChooser方法的具体用法?Python swing.JFileChooser怎么用?Python swing.JFileChooser使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.swing
的用法示例。
在下文中一共展示了swing.JFileChooser方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: loadFile
# 需要导入模块: from javax import swing [as 别名]
# 或者: from javax.swing import JFileChooser [as 别名]
def loadFile(self, e):
chooseFile = swing.JFileChooser()
fileDialog = chooseFile.showDialog(self.tab, "Choose file")
if fileDialog == swing.JFileChooser.APPROVE_OPTION:
file = chooseFile.getSelectedFile()
filename = file.getCanonicalPath()
fileExtension = os.path.splitext(filename)[1]
try:
loadedFile = open(filename, "r")
except IOError as e:
print "Error reading file.\n" + str(e)
self.logArea.append('\nError reading File: %s' % filename)
if fileExtension == '.gnmap':
self.nmap(loadedFile)
elif fileExtension == '.nessus':
self.nessus(loadedFile)
elif fileExtension == '.txt':
self.plaintext(loadedFile)
else:
print '\nFile %s was read but does not have the correct extension (.gnmap, .nessus, .txt).' % filename
self.logArea.append('\nFile %s was read but does not have the correct extension (.gnmap, .nessus, .txt).' % filename)
示例2: load
# 需要导入模块: from javax import swing [as 别名]
# 或者: from javax.swing import JFileChooser [as 别名]
def load(self, e):
chooseFile = swing.JFileChooser()
ret = chooseFile.showDialog(self.tab, "Choose file")
if ret == swing.JFileChooser.APPROVE_OPTION:
file = chooseFile.getSelectedFile()
filename = file.getCanonicalPath()
try:
f = open(filename, "r")
text = f.readlines()
if text:
text = [line for line in text if not line.isspace()]
text = [line.rstrip('\n') for line in text]
self.boringHeadersList.setListData(text)
except IOError as e:
print "Error reading file.\n" + str(e)
示例3: setAPI
# 需要导入模块: from javax import swing [as 别名]
# 或者: from javax.swing import JFileChooser [as 别名]
def setAPI(self, e):
selectFile = swing.JFileChooser()
filter = swing.filechooser.FileNameExtensionFilter("python files", ["py"])
selectFile.addChoosableFileFilter(filter)
returnedFile = selectFile.showDialog(self._jPanel, "SQLMap API")
if returnedFile == swing.JFileChooser.APPROVE_OPTION:
file = selectFile.getSelectedFile()
self.apifile = file.getPath()
print 'Selected API at ' + file.getPath()
self._jLabelAPI.setText('API set to: ' + file.getPath())
示例4: setPython
# 需要导入模块: from javax import swing [as 别名]
# 或者: from javax.swing import JFileChooser [as 别名]
def setPython(self, e):
selectFile = swing.JFileChooser()
returnedFile = selectFile.showDialog(self._jPanel, "Python EXE")
if returnedFile == swing.JFileChooser.APPROVE_OPTION:
file = selectFile.getSelectedFile()
self.pythonfile = file.getPath()
print 'Selected Python at ' + file.getPath()
self._jLabelPython.setText('Python set to: ' + file.getPath())
示例5: _tomcatLoadUsersFunc
# 需要导入模块: from javax import swing [as 别名]
# 或者: from javax.swing import JFileChooser [as 别名]
def _tomcatLoadUsersFunc(self, event):
chooser = swing.JFileChooser()
chooser.showOpenDialog(self._tomcatMainPanel)
filePathName = ''
try:
if(chooser.getSelectedFile()) is not None:
filePathName += (str(chooser.getSelectedFile()).replace('\\', '/'))
self._tomcatMainUname.setText(filePathName.strip())
except:
print 'Open User File Error'
示例6: _tomcatLoadPwdsDicts
# 需要导入模块: from javax import swing [as 别名]
# 或者: from javax.swing import JFileChooser [as 别名]
def _tomcatLoadPwdsDicts(self, event):
chooser = swing.JFileChooser()
chooser.showOpenDialog(self._tomcatMainPanel)
filePathName = ''
try:
if(chooser.getSelectedFile()) is not None:
filePathName += (str(chooser.getSelectedFile()).replace('\\', '/'))
self._tomcatMainPwd.setText(filePathName.strip())
except:
print 'Open Pwd File Error'
示例7: choose_file
# 需要导入模块: from javax import swing [as 别名]
# 或者: from javax.swing import JFileChooser [as 别名]
def choose_file(self, event):
chooseFile = JFileChooser()
chooseFile.showOpenDialog(None)
chosenFile = chooseFile.getSelectedFile()
return str(chosenFile)
示例8: exportLog
# 需要导入模块: from javax import swing [as 别名]
# 或者: from javax.swing import JFileChooser [as 别名]
def exportLog(self, event):
chooseFile = JFileChooser()
ret = chooseFile.showDialog(self.logPane, "Choose file")
filename = chooseFile.getSelectedFile().getCanonicalPath()
print("\n" + "Export to : " + filename)
open(filename, 'w', 0).write(self.outputTxtArea.text)
示例9: initUI
# 需要导入模块: from javax import swing [as 别名]
# 或者: from javax.swing import JFileChooser [as 别名]
def initUI(self):
self.tab = swing.JPanel()
# UI for Output
self.outputLabel = swing.JLabel("LinkFinder Log:")
self.outputLabel.setFont(Font("Tahoma", Font.BOLD, 14))
self.outputLabel.setForeground(Color(255,102,52))
self.logPane = swing.JScrollPane()
self.outputTxtArea = swing.JTextArea()
self.outputTxtArea.setFont(Font("Consolas", Font.PLAIN, 12))
self.outputTxtArea.setLineWrap(True)
self.logPane.setViewportView(self.outputTxtArea)
self.clearBtn = swing.JButton("Clear Log", actionPerformed=self.clearLog)
self.exportBtn = swing.JButton("Export Log", actionPerformed=self.exportLog)
self.parentFrm = swing.JFileChooser()
# Layout
layout = swing.GroupLayout(self.tab)
layout.setAutoCreateGaps(True)
layout.setAutoCreateContainerGaps(True)
self.tab.setLayout(layout)
layout.setHorizontalGroup(
layout.createParallelGroup()
.addGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup()
.addComponent(self.outputLabel)
.addComponent(self.logPane)
.addComponent(self.clearBtn)
.addComponent(self.exportBtn)
)
)
)
layout.setVerticalGroup(
layout.createParallelGroup()
.addGroup(layout.createParallelGroup()
.addGroup(layout.createSequentialGroup()
.addComponent(self.outputLabel)
.addComponent(self.logPane)
.addComponent(self.clearBtn)
.addComponent(self.exportBtn)
)
)
)