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


Python swing.JFileChooser类代码示例

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


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

示例1: getFilePath

 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 
开发者ID:0x24bin,项目名称:BurpSuite,代码行数:7,代码来源:SequenceGenerator.py

示例2: save_pdf

    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()
开发者ID:Elhamahm,项目名称:nengo_1.4,代码行数:30,代码来源:timecontrol.py

示例3: openFile

    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,代码行数:27,代码来源:NammuController.py

示例4: FileManager

class FileManager(object):
    
    def __init__(self, pywin):
        self.fc = JFileChooser()
        self.fc.fileFilter = FileNameExtensionFilter("Python Files", ["py"])
        self.pywin = pywin
        self.load_path = None
        self.script_path = None

    @property
    def script_area(self):
        return self.pywin.script_pane.script_area
    
    def show_open_dialog(self, title):
        self.fc.dialogTitle = title
        res = self.fc.showOpenDialog(self.pywin.frame)
        if res == JFileChooser.APPROVE_OPTION:
            return self.fc.selectedFile
    
    def show_save_dialog(self, title):
        self.fc.dialogTitle = title
        res = self.fc.showSaveDialog(self.pywin.frame)
        if res == JFileChooser.APPROVE_OPTION:
            return self.fc.selectedFile
    
    def save_script(self):
        if self.script_path is None:
            return
        with codecs.open(self.script_path, "wb", "utf-8") as stream:
            stream.write(self.script_area.input)
    
    def open_script(self):
        f = self.show_open_dialog("Select script file to open")
        if f is None:
            return
        self.script_path = f.absolutePath
        with codecs.open(self.script_path, "rb", "utf-8") as stream:
            self.script_area.input = stream.read()
    
    def save_script_as(self):
        f = self.show_save_dialog("Select file to write script to")
        if f is None:
            return
        self.script_path = f.absolutePath
        self.save_script()
    
    def load_script(self):
        f = self.show_open_dialog("Select script file to load")
        if f is None:
            return
        self.load_path = f.absolutePath
        self.reload_script()
    
    def reload_script(self):
        print "*** Loading", self.load_path, "***"
        try:
            self.pywin.execfile(self.load_path)
        except Exception, e:
            self.pywin.outputpane.addtext(str(e) + '\n', 'error')
开发者ID:aeriksson,项目名称:geogebra,代码行数:59,代码来源:gui.py

示例5: onOpenFolder

 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()
开发者ID:fran-jo,项目名称:SimuGUI,代码行数:8,代码来源:meegui_jy.py

示例6: init

 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)
开发者ID:Steell,项目名称:Ray-Tracer-Jython,代码行数:58,代码来源:rtlib.py

示例7: loadPopNames

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)
开发者ID:tiagoantao,项目名称:lositan,代码行数:9,代码来源:Main.py

示例8: onClick

 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
开发者ID:fran-jo,项目名称:SimuGUI,代码行数:9,代码来源:demo.py

示例9: actionPerformed

	def actionPerformed(self, e):
	
		fc = JFileChooser()
		
		returnValue = fc.showSaveDialog(self.pi.mainWindow.frame)
		
		if returnValue == JFileChooser.APPROVE_OPTION:
			fileName = fc.selectedFile.absolutePath
			createIdcFile(fileName, self.module)
			MessageBox.showInformation(self.pi.mainWindow.frame, "Module information was successfully written to the selected IDC file. Please run the IDC file in IDA Pro now.")
开发者ID:0x90erator,项目名称:binnavi,代码行数:10,代码来源:ida_backporter.py

示例10: selectFile

	def selectFile(self, event):
		'''
		Action handler to select a file to save to
		'''
		
		chooser = JFileChooser()
		retVal = chooser.showSaveDialog(None)

		#if reVal == JFileChooser.APPROVE_OPTION:
		self.saveFile = chooser.selectedFile.path
开发者ID:Yaeger,项目名称:Burp,代码行数:10,代码来源:logme.py

示例11: MultiFileDialog

def MultiFileDialog(title):
  #hide/show debug prints
  verbose = 0
  # Choose image file(s) to open
  fc = JFileChooser()
  fc.setMultiSelectionEnabled(True)
  fc.setDialogTitle(title)

  sdir = OpenDialog.getDefaultDirectory()
  if sdir!=None:
    fdir = File(sdir)
  if fdir!=None:
    fc.setCurrentDirectory(fdir)
  
  returnVal = fc.showOpenDialog(IJ.getInstance())
  if returnVal!=JFileChooser.APPROVE_OPTION:
    return
  files = fc.getSelectedFiles()

  paths = []
  for i in range(len(files)):
      paths.append(os.path.join(files[i].getParent(), files[i].getName()))
      
  if verbose > 0:
    for i in range(len(files)):
      path = os.path.join(files[i].getParent(), files[i].getName())
      print "Path: " + path
  
  return paths
开发者ID:BWHCNI,项目名称:workflow,代码行数:29,代码来源:OMUtilities.py

示例12: getFile

 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)
开发者ID:0x24bin,项目名称:BurpSuite,代码行数:11,代码来源:Burp_MultiProxy.py

示例13: GnitPickFileChooser

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.")
开发者ID:mcamiano,项目名称:gnitpick,代码行数:12,代码来源:GnitPickFileChooser.py

示例14: get_image_file

	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,代码行数:12,代码来源:imagetool.py

示例15: _configFileDialogue

 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,代码行数:12,代码来源:__init__.py


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