当前位置: 首页>>代码示例>>Python>>正文


Python JFileChooser.setFileFilter方法代码示例

本文整理汇总了Python中javax.swing.JFileChooser.setFileFilter方法的典型用法代码示例。如果您正苦于以下问题:Python JFileChooser.setFileFilter方法的具体用法?Python JFileChooser.setFileFilter怎么用?Python JFileChooser.setFileFilter使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在javax.swing.JFileChooser的用法示例。


在下文中一共展示了JFileChooser.setFileFilter方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: openFile

# 需要导入模块: from javax.swing import JFileChooser [as 别名]
# 或者: from javax.swing.JFileChooser import setFileFilter [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")
开发者ID:jenshnielsen,项目名称:nammu,代码行数:29,代码来源:NammuController.py

示例2: get_image_file

# 需要导入模块: from javax.swing import JFileChooser [as 别名]
# 或者: from javax.swing.JFileChooser import setFileFilter [as 别名]
	def get_image_file(self) :
		file_dialog = JFileChooser()
		#image files
		image_filter = FileNameExtensionFilter("Image Files", 
			["jpg","bmp","png","gif"])
		print image_filter.getExtensions()
		file_dialog.setFileFilter(image_filter)
		x = file_dialog.showOpenDialog(None)
		if x == JFileChooser.APPROVE_OPTION :
			return file_dialog.getSelectedFile()
		else :
			return None
开发者ID:bkap,项目名称:MICT,代码行数:14,代码来源:imagetool.py

示例3: _configFileDialogue

# 需要导入模块: from javax.swing import JFileChooser [as 别名]
# 或者: from javax.swing.JFileChooser import setFileFilter [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.")
开发者ID:EnviroCentre,项目名称:monitoring-module,代码行数:14,代码来源:__init__.py

示例4: openGVL

# 需要导入模块: from javax.swing import JFileChooser [as 别名]
# 或者: from javax.swing.JFileChooser import setFileFilter [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
开发者ID:nachouve,项目名称:uve_gvsig_scripts,代码行数:18,代码来源:batchLegend.py

示例5: __init__

# 需要导入模块: from javax.swing import JFileChooser [as 别名]
# 或者: from javax.swing.JFileChooser import setFileFilter [as 别名]
 def __init__(self, configFileName=None, dssFilePath=None):
     """
     A tool is defined by providing a `yaml` configuration file 
     ``configFileName`` and a HEC-DSS database ``dssFilePath`` to operate on.
     If ``dssFilePath`` is not set, the active DSS-file in the HEC-DSSVue
     window will be used. If ``configFileName`` is not set, a file selection
     dialogue is displayed prompting for a configuration file.
     
     The attribute :attr:`.config` will be set containing the parsed yaml 
     config file.
     """
     
     if dssFilePath:
         self.dssFilePath = dssFilePath
         self.mainWindow = None
     else:
         from hec.dssgui import ListSelection
         self.mainWindow = ListSelection.getMainWindow()
         self.dssFilePath = self.mainWindow.getDSSFilename()
         if not configFileName:
             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:
                 self.configFilePath = (fileDialogue.getSelectedFile().
                                        getAbsolutePath())
             else:
                 raise CancelledError("Config file selection was cancelled.") 
     
     if configFileName:
         self.configFilePath = path.join(path.dirname(self.dssFilePath), 
                                         configFileName)
     elif dssFilePath:
         raise ValueError("`configFileName` argument must be provided if `dssFilePath` is specified.")
     
     #: Message to be displayed in HEC-DSSVue after running the tool. This 
     #: attribute is typically set in the :meth:`main`.
     self.message = ""
     
     if self._toolIsValid():
         with codecs.open(self.configFilePath, encoding='utf-8') as configFile:
             self.config = yaml.load(configFile.read())
         self._configIsValid()
开发者ID:jprine,项目名称:monitoring-module,代码行数:49,代码来源:__init__.py

示例6: onClick

# 需要导入模块: from javax.swing import JFileChooser [as 别名]
# 或者: from javax.swing.JFileChooser import setFileFilter [as 别名]
   def onClick(self, e):

       print outputTextField.getText()
       chooseFile = JFileChooser()
       filter = ExampleFileFilter()
       filter.addExtension("txt")
       filter.setDescription("txt HL7 input files")
       chooseFile.setFileFilter(filter)
       

       ##ret = chooseFile.showDialog(self.panel, "Choose file")
       ret = chooseFile.showOpenDialog(self.panel)

       if ret == JFileChooser.APPROVE_OPTION:
           file = chooseFile.getSelectedFile()
           text = self.readFile(file)
           self.area.append(text)
           outputFile = outputTextField.getText()
           p1 = HL7RepClass.ParseORUClass(file.getCanonicalPath(), outputFile)
           p1.parseORU()
           print "\noutfile = ", outputFile
开发者ID:chronotrope,项目名称:HL7Reporter,代码行数:23,代码来源:HL7ORUGui.py

示例7: actionPerformed

# 需要导入模块: from javax.swing import JFileChooser [as 别名]
# 或者: from javax.swing.JFileChooser import setFileFilter [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.")
开发者ID:PolitoInc,项目名称:Yara-Scanner,代码行数:40,代码来源:yaraburp.py

示例8: DataPanel

# 需要导入模块: from javax.swing import JFileChooser [as 别名]
# 或者: from javax.swing.JFileChooser import setFileFilter [as 别名]
class DataPanel(JPanel,MouseListener):
    def __init__(self,view):
        JPanel.__init__(self)
        self.view=view
        self.background=Color.white
        self.layout=BorderLayout()

        self.popup=JPopupMenu()
        self.popup_items={}

        self.add(self.make_controls(),BorderLayout.SOUTH)

        data,title=self.extract_data()
        self.table=JTable(DefaultTableModel(data,title))

        scroll=JScrollPane(self.table)
        self.add(scroll)

        scroll.addMouseListener(self)
        self.table.tableHeader.addMouseListener(self)
        self.table.addMouseListener(self)

        self.fileChooser=JFileChooser()
        self.fileChooser.setFileFilter(CSVFilter())
        self.fileChooser.setSelectedFile(File('%s.csv'%self.view.network.name))



    def make_controls(self):
        from timeview.components.timecontrol import Icon, ShadedIcon
        panel=JPanel(background=self.background)
        panel.add(JButton(Icon.refresh,actionPerformed=self.refresh,rolloverIcon=ShadedIcon.refresh,toolTipText='refresh',borderPainted=False,focusPainted=False,contentAreaFilled=False))

        filter=JPanel(layout=BorderLayout(),opaque=False)
        self.filter = JSpinner(SpinnerNumberModel(self.view.tau_filter,0,0.5,0.01),stateChanged=self.refresh)
        filter.add(self.filter)
        filter.add(JLabel('filter'),BorderLayout.NORTH)
        filter.maximumSize=filter.preferredSize
        panel.add(filter)

        decimals=JPanel(layout=BorderLayout(),opaque=False)
        self.decimals = JSpinner(SpinnerNumberModel(3,0,10,1),stateChanged=self.refresh)
        decimals.add(self.decimals)
        decimals.add(JLabel('decimal places'),BorderLayout.NORTH)
        decimals.maximumSize=decimals.preferredSize
        panel.add(decimals)

        panel.add(JButton(Icon.save,actionPerformed=self.save,rolloverIcon=ShadedIcon.save,toolTipText='save',borderPainted=False,focusPainted=False,contentAreaFilled=False))

        return panel

    def extract_data(self):
        pause_state=self.view.paused
        self.view.paused=True

        while self.view.simulating:
            java.lang.Thread.sleep(10)

        tau=float(self.filter.value)
        dt=self.view.dt
        if tau<dt: dt_tau=None
        else: dt_tau=dt/tau

        decimals=int(self.decimals.value)
        format='%%1.%df'%decimals

        start_index=max(0,self.view.timelog.tick_count-self.view.timelog.tick_limit+1)
        count=min(self.view.timelog.tick_limit,self.view.timelog.tick_count)
        start_time=start_index*self.view.dt

        data=None
        title=['t']
        keys = self.view.watcher.active.keys()
        keys.sort()
        for key in keys:
            watch = self.view.watcher.active[key]
            name,func,args=key

            code='%s.%s%s'%(name,func.__name__,args)
            if code not in self.popup_items:
                state=True
                if 'spike' in func.__name__: state=False
                if 'voltage' in func.__name__: state=False
                self.popup_items[code]=JCheckBoxMenuItem(code,state,stateChanged=self.refresh)
                self.popup.add(self.popup_items[code])

            if self.popup_items[code].state is False: continue

            d=watch.get(dt_tau=dt_tau,start=start_index,count=count)
            n=len(watch.get_first())
            if data is None:
                data=[]
                while len(data)<len(d):
                    data.append(['%0.4f'%(start_time+(len(data)+0)*self.view.dt)])


            for i in range(n):
                title.append('%s[%d]'%(code,i))
                for j in range(len(data)):
                    dd=d[j]
#.........这里部分代码省略.........
开发者ID:Elhamahm,项目名称:nengo_1.4,代码行数:103,代码来源:data.py

示例9: JFileChooser

# 需要导入模块: from javax.swing import JFileChooser [as 别名]
# 或者: from javax.swing.JFileChooser import setFileFilter [as 别名]
import glob

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')
开发者ID:AndTH,项目名称:JMRI,代码行数:32,代码来源:ClassKeysReport.py

示例10: BurpExtender

# 需要导入模块: from javax.swing import JFileChooser [as 别名]
# 或者: from javax.swing.JFileChooser import setFileFilter [as 别名]

#.........这里部分代码省略.........
        f = open('config.ini', 'w')
        self.config.write(f)
        f.close()

    def getXMLDoc(self, xmlPath):
        try:
            document = DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(xmlPath)
            return document
        except:
            self._extender.popup("XML file not found")
            return

    def saveXMLDoc(self, doc, xmlPath):
        transformerFactory = TransformerFactory.newInstance()
        transformer = transformerFactory.newTransformer()
        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() 
开发者ID:anhnt4288,项目名称:PT-Manager,代码行数:70,代码来源:PTManager.py

示例11: default

# 需要导入模块: from javax.swing import JFileChooser [as 别名]
# 或者: from javax.swing.JFileChooser import setFileFilter [as 别名]
from time import time

import jmri
import java
from javax.swing import JFileChooser, JOptionPane
from javax.swing.filechooser import FileNameExtensionFilter

dialogTitle = "Bundle Keys Report"

##
# Select a properties file to be anaylzed.  This will normally be the
# default (English) file.
##
fc = JFileChooser(FileUtil.getProgramPath())
fc.setDialogTitle(dialogTitle)
fc.setFileFilter(FileNameExtensionFilter("Bundle Properties", ["properties"]));
ret = fc.showOpenDialog(None)
if ret == JFileChooser.APPROVE_OPTION:
    selectedBundle = fc.getSelectedFile().toString()
    startTime = time()
else:
    print "No file selected, bye"
    quit()

# set up path info
bundleFile = os.path.basename(selectedBundle)
fullPath = os.path.dirname(selectedBundle)
splitPath = fullPath.split(os.sep + "src" + os.sep)
jmriPath = splitPath[0]
bundlePath = splitPath[1]
dotPath = ".".join(bundlePath.split(os.sep))
开发者ID:AndTH,项目名称:JMRI,代码行数:33,代码来源:BundleKeysReport.py


注:本文中的javax.swing.JFileChooser.setFileFilter方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。