本文整理汇总了Python中javax.swing.JFileChooser.addChoosableFileFilter方法的典型用法代码示例。如果您正苦于以下问题:Python JFileChooser.addChoosableFileFilter方法的具体用法?Python JFileChooser.addChoosableFileFilter怎么用?Python JFileChooser.addChoosableFileFilter使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.swing.JFileChooser
的用法示例。
在下文中一共展示了JFileChooser.addChoosableFileFilter方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: chooseFile
# 需要导入模块: from javax.swing import JFileChooser [as 别名]
# 或者: from javax.swing.JFileChooser import addChoosableFileFilter [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
示例2: createFileChooserDialog
# 需要导入模块: from javax.swing import JFileChooser [as 别名]
# 或者: from javax.swing.JFileChooser import addChoosableFileFilter [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: onClick
# 需要导入模块: from javax.swing import JFileChooser [as 别名]
# 或者: from javax.swing.JFileChooser import addChoosableFileFilter [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
示例4: onClick
# 需要导入模块: from javax.swing import JFileChooser [as 别名]
# 或者: from javax.swing.JFileChooser import addChoosableFileFilter [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)
示例5: onClick
# 需要导入模块: from javax.swing import JFileChooser [as 别名]
# 或者: from javax.swing.JFileChooser import addChoosableFileFilter [as 别名]
def onClick(self, e):
chooseFile = JFileChooser()
filter = FileNameExtensionFilter("SQLite", ["sqlite"])
chooseFile.addChoosableFileFilter(filter)
ret = chooseFile.showDialog(self.panel0, "Select SQLite")
if ret == JFileChooser.APPROVE_OPTION:
file = chooseFile.getSelectedFile()
Canonical_file = file.getCanonicalPath()
#text = self.readPath(file)
self.local_settings.setSetting('ExecFile', Canonical_file)
self.Program_Executable_TF.setText(Canonical_file)
示例6: Find_Plaso_File
# 需要导入模块: from javax.swing import JFileChooser [as 别名]
# 或者: from javax.swing.JFileChooser import addChoosableFileFilter [as 别名]
def Find_Plaso_File(self, e):
chooseFile = JFileChooser()
filter = FileNameExtensionFilter("All", ["*.*"])
chooseFile.addChoosableFileFilter(filter)
ret = chooseFile.showDialog(self.panel0, "Find Plaso Storage File")
if ret == JFileChooser.APPROVE_OPTION:
file = chooseFile.getSelectedFile()
Canonical_file = file.getCanonicalPath()
#text = self.readPath(file)
self.local_settings.setSetting('Plaso_Storage_File', Canonical_file)
self.Plaso_Storage_File_TF.setText(Canonical_file)
示例7: Find_Dir
# 需要导入模块: from javax.swing import JFileChooser [as 别名]
# 或者: from javax.swing.JFileChooser import addChoosableFileFilter [as 别名]
def Find_Dir(self, e):
chooseFile = JFileChooser()
filter = FileNameExtensionFilter("All", ["*.*"])
chooseFile.addChoosableFileFilter(filter)
#chooseFile.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY)
ret = chooseFile.showDialog(self.panel0, "Find Volatility Directory")
if ret == JFileChooser.APPROVE_OPTION:
file = chooseFile.getSelectedFile()
Canonical_file = file.getCanonicalPath()
#text = self.readPath(file)
self.local_settings.setSetting('Volatility_Directory', Canonical_file)
self.Program_Executable_TF.setText(Canonical_file)
示例8: onOpenFile
# 需要导入模块: from javax.swing import JFileChooser [as 别名]
# 或者: from javax.swing.JFileChooser import addChoosableFileFilter [as 别名]
def onOpenFile(self, event):
''' remember to change the path'''
chooseFile = JFileChooser()
chooseFile.setCurrentDirectory(File('C:\Users\fragom\PhD_CIM\Modelica\Models'))
filtro = FileNameExtensionFilter("mo files", ["mo"])
chooseFile.addChoosableFileFilter(filtro)
ret = chooseFile.showDialog(self, "Choose file")
if ret == JFileChooser.APPROVE_OPTION:
self.faile= chooseFile.getSelectedFile()
if event.getActionCommand() == "Load Model":
self.cbMoFile.addItem(self.faile.getPath())
self.cbMoFile.selectedItem= self.faile.getPath()
if event.getActionCommand() == "Load Library":
self.cbMoLib.addItem(self.faile.getPath())
self.cbMoLib.selectedItem= self.faile.getPath()
示例9: init
# 需要导入模块: from javax.swing import JFileChooser [as 别名]
# 或者: from javax.swing.JFileChooser import addChoosableFileFilter [as 别名]
def init():
canvas = RayTracePanel(w, h, aa, threads)
self.add(canvas)
#Save FileChooser
fcS = JFileChooser()
fcS.addChoosableFileFilter(FileNameExtensionFilter('Windows Bitmap (*.bmp)', ['bmp']))
fcS.addChoosableFileFilter(FileNameExtensionFilter('JPEG / JFIF (*.jpg)', ['jpg']))
fcS.addChoosableFileFilter(FileNameExtensionFilter('Portable Network Graphics (*.png)', ['png']))
def saveFile(event):
'''Performed when the save button is pressed'''
result = fcS.showSaveDialog(frame)
if result == JFileChooser.APPROVE_OPTION:
file = fcS.getSelectedFile()
fname = file.getPath()
ext = fcS.getFileFilter().getExtensions()[0]
if not fname.endswith('.' + ext):
file = File(fname + '.' + ext)
canvas.saveToFile(file, ext)
#Open FileChooser
fcO = JFileChooser()
fcO.addChoosableFileFilter(FileNameExtensionFilter('RayTrace Scene File (*.rts)', ['rts']))
def openFile(event):
'''Performed when the open button is pressed'''
result = fcO.showOpenDialog(frame)
if result == JFileChooser.APPROVE_OPTION:
fname = fcO.getSelectedFile().getPath()
if fname.endswith('.rts'):
f = open(fname, 'rb')
newScene = SceneFactory().buildScene(f)
f.close()
Painter(canvas, newScene, openButton, saveButton, stopButton).start()
def stop(event):
'''Peformed when the stop button is pressed'''
canvas.stopRendering()
#Setup Menu
menuBar = JMenuBar()
menu = JMenu("File")
menuBar.add(menu)
openButton = JMenuItem("Open...", actionPerformed=openFile)
openButton.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_O, ActionEvent.CTRL_MASK))
menu.add(openButton)
saveButton = JMenuItem("Save as...", actionPerformed=saveFile)
saveButton.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_S, ActionEvent.CTRL_MASK))
menu.add(saveButton)
menu.addSeparator()
stopButton = JMenuItem('Stop Render', actionPerformed=stop)
stopButton.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0));
stopButton.setEnabled(False)
menu.add(stopButton)
menu.addSeparator()
closeButton = JMenuItem('Close', actionPerformed=exit)
closeButton.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_F4, ActionEvent.ALT_MASK))
menu.add(closeButton)
self.setJMenuBar(menuBar)
示例10: loadSimOut
# 需要导入模块: from javax.swing import JFileChooser [as 别名]
# 或者: from javax.swing.JFileChooser import addChoosableFileFilter [as 别名]
def loadSimOut(self, event):
chooseFile = JFileChooser()
filtro = FileNameExtensionFilter("Output files (.h5)", ['h5'])
chooseFile.addChoosableFileFilter(filtro)
ret = chooseFile.showDialog(self.frame, "Choose simulation result")
if ret == JFileChooser.APPROVE_OPTION:
faile= chooseFile.getSelectedFile()
self.cbfilesimOut.addItem(faile.getPath())
self.cbfilesimOut.selectedItem(faile.getPath())
h5pmu= PhasorMeasH5.PhasorMeasH5(faile)
h5pmu.open_h5()
h5pmu.load_h5('pwLine4', 'V')
# result: 2 vectors per variable, work with pwLine4.n.vr, pwLine4.n.vi
senyal= h5pmu.get_senyal()
print senyal
示例11: go
# 需要导入模块: from javax.swing import JFileChooser [as 别名]
# 或者: from javax.swing.JFileChooser import addChoosableFileFilter [as 别名]
def go(self, fileTypes=None, default=None, directoryAllowed=False):
fileChooser = JFileChooser()
if self.title:
fileChooser.setDialogTitle(self.title)
if default:
fileChooser.setSelectedFile(java.io.File(default))
fileChooser.setCurrentDirectory(java.io.File("."))
if fileTypes:
for extension, description in fileTypes:
fileChooser.addChoosableFileFilter(FileFilterForExtension(extension, description))
if self.loadOrSave == "load":
result = fileChooser.showOpenDialog(self.parent)
else:
result = fileChooser.showSaveDialog(self.parent)
if (result == JFileChooser.APPROVE_OPTION):
fileResult = None
fileAndMaybeDir = fileChooser.getSelectedFile().getAbsoluteFile()
if directoryAllowed or not fileAndMaybeDir.isDirectory():
fileResult = str(fileAndMaybeDir)
return fileResult
else:
return None
示例12: actionPerformed
# 需要导入模块: from javax.swing import JFileChooser [as 别名]
# 或者: from javax.swing.JFileChooser import addChoosableFileFilter [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.")
示例13: BurpExtender
# 需要导入模块: from javax.swing import JFileChooser [as 别名]
# 或者: from javax.swing.JFileChooser import addChoosableFileFilter [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
示例14: run
# 需要导入模块: from javax.swing import JFileChooser [as 别名]
# 或者: from javax.swing.JFileChooser import addChoosableFileFilter [as 别名]
def run(scene, w=512, h=512, aa=1, threads=1):
"""Create GUI and perform ray-tracing."""
# Make Swing not look like garbage (so much)
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName())
# Setup frame
frame = JFrame("RayTracer", defaultCloseOperation=JFrame.EXIT_ON_CLOSE, size=(w, h))
frame.setIconImage(ImageIcon("resources/icon.png").getImage())
canvas = RayTracePanel(w, h, aa, threads)
frame.getContentPane().add(JScrollPane(canvas))
# Save FileChooser
fcS = JFileChooser()
fcS.addChoosableFileFilter(FileNameExtensionFilter("Windows Bitmap (*.bmp)", ["bmp"]))
fcS.addChoosableFileFilter(FileNameExtensionFilter("JPEG / JFIF (*.jpg)", ["jpg"]))
fcS.addChoosableFileFilter(FileNameExtensionFilter("Portable Network Graphics (*.png)", ["png"]))
def saveFile(event):
"""Performed when the save button is pressed"""
result = fcS.showSaveDialog(frame)
if result == JFileChooser.APPROVE_OPTION:
file = fcS.getSelectedFile()
fname = file.getPath()
ext = fcS.getFileFilter().getExtensions()[0]
if not fname.endswith("." + ext):
file = File(fname + "." + ext)
canvas.saveToFile(file, ext)
# Open FileChooser
fcO = JFileChooser()
fcO.addChoosableFileFilter(FileNameExtensionFilter("RayTrace Scene File (*.rts)", ["rts"]))
def openFile(event):
"""Performed when the open button is pressed"""
result = fcO.showOpenDialog(frame)
if result == JFileChooser.APPROVE_OPTION:
fname = fcO.getSelectedFile().getPath()
if fname.endswith(".rts"):
f = open(fname, "rb")
newScene = SceneFactory().buildScene(f)
f.close()
Painter(canvas, newScene, openButton, saveButton, stopButton).start()
def exit(event):
"""Performed when the exit button is pressed"""
import sys
sys.exit(0)
def stop(event):
"""Peformed when the stop button is pressed"""
canvas.stopRendering()
# Setup Menu
menuBar = JMenuBar()
menu = JMenu("File")
menuBar.add(menu)
openButton = JMenuItem("Open...", actionPerformed=openFile)
openButton.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_O, ActionEvent.CTRL_MASK))
menu.add(openButton)
saveButton = JMenuItem("Save as...", actionPerformed=saveFile)
saveButton.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_S, ActionEvent.CTRL_MASK))
menu.add(saveButton)
menu.addSeparator()
stopButton = JMenuItem("Stop Render", actionPerformed=stop)
stopButton.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0))
stopButton.setEnabled(False)
menu.add(stopButton)
menu.addSeparator()
closeButton = JMenuItem("Close", actionPerformed=exit)
closeButton.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_F4, ActionEvent.ALT_MASK))
menu.add(closeButton)
frame.setJMenuBar(menuBar)
# Finish initializing GUI
self.pack()
示例15: run
# 需要导入模块: from javax.swing import JFileChooser [as 别名]
# 或者: from javax.swing.JFileChooser import addChoosableFileFilter [as 别名]
def run(scene, w=512, h=512, aa=1, threads=1):
'''Create GUI and perform ray-tracing.'''
#Make Swing not look like garbage (so much)
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName())
#Setup frame
frame = JFrame(
"RayTracer",
defaultCloseOperation=JFrame.EXIT_ON_CLOSE,
size=(w, h)
)
frame.setIconImage(ImageIcon('resources/icon.png').getImage())
canvas = RayTracePanel(w, h, aa, threads)
frame.getContentPane().add(JScrollPane(canvas))
#Save FileChooser
fcS = JFileChooser()
fcS.addChoosableFileFilter(FileNameExtensionFilter('Windows Bitmap (*.bmp)', ['bmp']))
fcS.addChoosableFileFilter(FileNameExtensionFilter('JPEG / JFIF (*.jpg)', ['jpg']))
fcS.addChoosableFileFilter(FileNameExtensionFilter('Portable Network Graphics (*.png)', ['png']))
def saveFile(event):
'''Performed when the save button is pressed'''
result = fcS.showSaveDialog(frame)
if result == JFileChooser.APPROVE_OPTION:
file = fcS.getSelectedFile()
fname = file.getPath()
ext = fcS.getFileFilter().getExtensions()[0]
if not fname.endswith('.' + ext):
file = File(fname + '.' + ext)
canvas.saveToFile(file, ext)
#Open FileChooser
fcO = JFileChooser()
fcO.addChoosableFileFilter(FileNameExtensionFilter('RayTrace Scene File (*.rts)', ['rts']))
def openFile(event):
'''Performed when the open button is pressed'''
result = fcO.showOpenDialog(frame)
if result == JFileChooser.APPROVE_OPTION:
fname = fcO.getSelectedFile().getPath()
if fname.endswith('.rts'):
f = open(fname, 'rb')
newScene = SceneFactory().buildScene(f)
f.close()
Painter(canvas, newScene, openButton, saveButton).start()
def exit(event):
'''Performed when the exit button is pressed'''
import sys
sys.exit(0)
#Setup Menu
menuBar = JMenuBar()
menu = JMenu("File")
menuBar.add(menu)
openButton = JMenuItem("Open...", actionPerformed=openFile)
openButton.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_O, ActionEvent.CTRL_MASK))
menu.add(openButton)
saveButton = JMenuItem("Save as...", actionPerformed=saveFile)
saveButton.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_S, ActionEvent.CTRL_MASK))
menu.add(saveButton)
menu.addSeparator()
closeButton = JMenuItem('Close', actionPerformed=exit)
closeButton.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_F4, ActionEvent.ALT_MASK))
menu.add(closeButton)
frame.setJMenuBar(menuBar)
#Finish initializing GUI
frame.pack()
#frame.setLocationRelativeTo(None)
frame.setVisible(True)
#Perform ray-tracing
if scene is not None:
Thread(Painter(canvas, scene, openButton, saveButton)).start()