當前位置: 首頁>>代碼示例>>Python>>正文


Python swing.JFileChooser方法代碼示例

本文整理匯總了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) 
開發者ID:SmeegeSec,項目名稱:Burp-Importer,代碼行數:26,代碼來源:BurpImporter.py

示例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) 
開發者ID:Dionach,項目名稱:HeadersAnalyzer,代碼行數:19,代碼來源:HeadersAnalyzer.py

示例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()) 
開發者ID:codewatchorg,項目名稱:sqlipy,代碼行數:14,代碼來源:SQLiPy.py

示例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()) 
開發者ID:codewatchorg,項目名稱:sqlipy,代碼行數:12,代碼來源:SQLiPy.py

示例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' 
開發者ID:WallbreakerTeam,項目名稱:TomcatBrute,代碼行數:12,代碼來源:TomcatBrute.py

示例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' 
開發者ID:WallbreakerTeam,項目名稱:TomcatBrute,代碼行數:12,代碼來源:TomcatBrute.py

示例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) 
開發者ID:EnableSecurity,項目名稱:Identity-Crisis,代碼行數:7,代碼來源:identitycrisis.py

示例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) 
開發者ID:InitRoot,項目名稱:BurpJSLinkFinder,代碼行數:8,代碼來源:FransLinkfinder.py

示例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)
                )
            )
        ) 
開發者ID:InitRoot,項目名稱:BurpJSLinkFinder,代碼行數:49,代碼來源:FransLinkfinder.py


注:本文中的javax.swing.JFileChooser方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。