コード例 #1
0
ファイル: Main.py プロジェクト: sedjrodonan/lositan
def chooseFile():
    global frame, dataPath
    global systemPanel, chartPanel
    global isTemporal
    fc = JFileChooser(dataPath)
    retVal = fc.showOpenDialog(frame)
    if retVal != JFileChooser.APPROVE_OPTION:
        return
    fname = fc.getSelectedFile().getAbsolutePath()
    dataPath = os.sep.join(fname.split(os.sep)[:-1])
    if isTemporal:
        info(frame, "We need a file with information about the temporal point of each sample")
        tfc = JFileChooser(dataPath)
        tRetVal = tfc.showOpenDialog(frame)
        if retVal != JFileChooser.APPROVE_OPTION:
            return
        tname = tfc.getSelectedFile().getAbsolutePath()
    systemPanel.enableChartFun = False
    chartPanel.resetData()
    loadGenePop(fname)
    if isTemporal:
        if not loadTemporal(tname):
            return
    updateAll()
    enablePanel(empiricalPanel)
コード例 #2
0
    def actionPerformed(self, e):
        file_chooser = JFileChooser()
        is_load_file = str(e.getActionCommand()) == "load"
        is_save_file = str(e.getActionCommand()) == "save"

        if is_load_file:
            file_chooser.setDialogTitle("Load JSON File")
            file_chooser.setDialogType(JFileChooser.OPEN_DIALOG)
            open_dialog = file_chooser.showOpenDialog(self.file_button)
            is_approve = open_dialog == JFileChooser.APPROVE_OPTION

            if is_approve:
                load_file = file_chooser.getSelectedFile()
                file_name = str(load_file)
                self.load_data(file_name)
            else:
                print("JSON file load cancelled")

        if is_save_file:
            file_chooser.setDialogTitle("Save JSON File")
            file_chooser.setDialogType(JFileChooser.SAVE_DIALOG)
            save_dialog = file_chooser.showSaveDialog(self.file_button)
            is_approve = save_dialog == JFileChooser.APPROVE_OPTION

            if is_approve:
                save_file = str(file_chooser.getSelectedFile())
                self.save_data(save_file)
            else:
                print("JSON file save cancelled")
コード例 #3
0
ファイル: SelPanel.py プロジェクト: samitha/lositan
 def actionPerformed(self, event):
     option = event.getActionCommand()
     if option == 'Close':
       self.dispose()
     elif option == 'SCI':
         chooser = JFileChooser()
         returnVal = chooser.showSaveDialog(self)
         if returnVal == JFileChooser.APPROVE_OPTION:
             fileName = chooser.getSelectedFile().getPath()
             f = open(fileName, 'w')
             f.write("\t".join(["Het", "Fst", "0.5(1-pval)quantile", "median", "0.5(1+pval)quantile"]) + "\n")
             for line in self.confLines:
                 f.write('\t'.join(map(lambda x: str(x), line)) + "\n")
             f.close()
     elif option == 'SLL':
         chooser = JFileChooser()
         returnVal = chooser.showSaveDialog(self)
         if returnVal == JFileChooser.APPROVE_OPTION:
             fileName = chooser.getSelectedFile().getPath()
             f = open(fileName, 'w')
             f.write("\t".join(["Locus", "Het", "Fst", "P(Simul Fst<sample Fst)"]) + "\n")
             for i in range(self.data.size()):
                 line = self.data.elementAt(i)
                 lineList = [str(line.elementAt(0))]
                 lineList.append(str(line.elementAt(1)))
                 lineList.append(str(line.elementAt(2)))
                 lineList.append(str(line.elementAt(3)))
                 f.write("\t".join(lineList) + "\n")
             f.close()
コード例 #4
0
ファイル: SelPanel.py プロジェクト: sedjrodonan/lositan
 def actionPerformed(self, event):
     option = event.getActionCommand()
     if option == 'Close':
         self.dispose()
     elif option == 'SCI':
         chooser = JFileChooser()
         returnVal = chooser.showSaveDialog(self)
         if returnVal == JFileChooser.APPROVE_OPTION:
             fileName = chooser.getSelectedFile().getPath()
             f = open(fileName, 'w')
             f.write("\t".join([
                 "Het", "Fst", "0.5(1-pval)quantile", "median",
                 "0.5(1+pval)quantile"
             ]) + "\n")
             for line in self.confLines:
                 f.write('\t'.join(map(lambda x: str(x), line)) + "\n")
             f.close()
     elif option == 'SLL':
         chooser = JFileChooser()
         returnVal = chooser.showSaveDialog(self)
         if returnVal == JFileChooser.APPROVE_OPTION:
             fileName = chooser.getSelectedFile().getPath()
             f = open(fileName, 'w')
             f.write("\t".join(
                 ["Locus", "Het", "Fst", "P(Simul Fst<sample Fst)"]) + "\n")
             for i in range(self.data.size()):
                 line = self.data.elementAt(i)
                 lineList = [str(line.elementAt(0))]
                 lineList.append(str(line.elementAt(1)))
                 lineList.append(str(line.elementAt(2)))
                 lineList.append(str(line.elementAt(3)))
                 f.write("\t".join(lineList) + "\n")
             f.close()
コード例 #5
0
def _buildProjectJar(element, document):
    component = element.getRootElement().getComponent()

    larchJarURL = app_in_jar.getLarchJarURL()
    chosenJarURL = None
    if larchJarURL is None:
        openDialog = JFileChooser()
        openDialog.setFileFilter(
            FileNameExtensionFilter('Larch executable JAR (*.jar)', ['jar']))
        response = openDialog.showDialog(component, 'Choose Larch JAR')
        if response == JFileChooser.APPROVE_OPTION:
            sf = openDialog.getSelectedFile()
            if sf is not None:
                chosenJarURL = sf.toURI().toURL()
        else:
            return

    jarFile = None
    bFinished = False
    while not bFinished:
        saveDialog = JFileChooser()
        saveDialog.setFileFilter(
            FileNameExtensionFilter('JAR file (*.jar)', ['jar']))
        response = saveDialog.showSaveDialog(component)
        if response == JFileChooser.APPROVE_OPTION:
            sf = saveDialog.getSelectedFile()
            if sf is not None:
                if sf.exists():
                    response = JOptionPane.showOptionDialog(
                        component, 'File already exists. Overwrite?',
                        'File already exists', JOptionPane.YES_NO_OPTION,
                        JOptionPane.WARNING_MESSAGE, None,
                        ['Overwrite', 'Cancel'], 'Cancel')
                    if response == JFileChooser.APPROVE_OPTION:
                        jarFile = sf
                        bFinished = True
                    else:
                        bFinished = False
                else:
                    jarFile = sf
                    bFinished = True
            else:
                bFinished = True
        else:
            bFinished = True

    if jarFile is not None:
        outStream = FileOutputStream(jarFile)

        documentBytes = document.writeAsBytes()

        nameBytesPairs = [('app.larch', documentBytes)]

        app_in_jar.buildLarchJar(outStream,
                                 nameBytesPairs,
                                 larchJarURL=chosenJarURL)

        outStream.close()
コード例 #6
0
 def actionPerformed(self, actionEvent):
     chooser = JFileChooser()
     #chooser.setCurrentDirectory(".")
     chooser.setDialogTitle("Choose file")
     chooser.setFileSelectionMode(JFileChooser.FILES_ONLY)
     chooser.setAcceptAllFileFilterUsed(False)
     if chooser.showOpenDialog(self) == JFileChooser.APPROVE_OPTION:
         print chooser.getCurrentDirectory()
         print chooser.getSelectedFile()
         self.field.setText(str(chooser.getSelectedFile()))
     else:
         print "No file selected"
コード例 #7
0
 def showFC(self, event):
     Type = 'Open,Save,Custom'.split(',')
     Answer = 'Error,Approve,Cancel'.split(',')
     fc = JFileChooser()
     fc.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY)
     result = fc.showOpenDialog(None)
     if result == JFileChooser.APPROVE_OPTION:
         message = 'result = "%s"' % fc.getSelectedFile()
         self.directory = fc.getSelectedFile()
         print(self.directory)
         print(type(self.directory))
     else:
         message = 'Request canceled by user'
     self.label.setText(message)
コード例 #8
0
def f2_clic_browse1(event):
   print("Click browse 1")
   fc = JFileChooser()
   fc.setCurrentDirectory(gvars['path_JFileChooser'])
   fc.setDialogTitle('Open original image')
   result = fc.showOpenDialog( None )
   if result == JFileChooser.APPROVE_OPTION :
      message = 'Path to original image %s' % fc.getSelectedFile()
      gvars['path_original_image'] = str(fc.getSelectedFile())
      f2_txt1.setText(gvars['path_original_image'])
      gvars['path_JFileChooser'] = fc.getCurrentDirectory()

   else :
      message = 'Request canceled by user'
   print( message )
コード例 #9
0
 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 
コード例 #10
0
def promptSaveDocumentAs(world, component, handleSaveDocumentAsFn, existingFilename=None):
	filename = None
	bFinished = False
	while not bFinished:
		saveDialog = JFileChooser()
		saveDialog.setFileFilter( FileNameExtensionFilter( 'Larch project (*.larch)', [ 'larch' ] ) )
		response = saveDialog.showSaveDialog( component )
		if response == JFileChooser.APPROVE_OPTION:
			sf = saveDialog.getSelectedFile()
			if sf is not None:
				if sf.exists():
					response = JOptionPane.showOptionDialog( component, 'File already exists. Overwrite?', 'File already exists', JOptionPane.YES_NO_OPTION, JOptionPane.WARNING_MESSAGE, None, [ 'Overwrite', 'Cancel' ], 'Cancel' )
					if response == JFileChooser.APPROVE_OPTION:
						filename = sf.getPath()
						bFinished = True
					else:
						bFinished = False
				else:
					filename = sf.getPath()
					bFinished = True
			else:
				bFinished = True
		else:
			bFinished = True

	if filename is not None:
		handleSaveDocumentAsFn( filename )
		return True
	else:
		return False
コード例 #11
0
def gcodeBottom(event):

    fc = JFileChooser()
    fc.setCurrentDirectory(
        File(boardcad.gui.jdk.BoardCAD.getInstance().defaultDirectory))
    returnVal = fc.showSaveDialog(
        boardcad.gui.jdk.BoardCAD.getInstance().getFrame())
    if (returnVal != JFileChooser.APPROVE_OPTION):
        return
    mfile = fc.getSelectedFile()
    filename = mfile.getPath()
    if (filename == None):
        return
    boardcad.gui.jdk.BoardCAD.getInstance().defaultDirectory = mfile.getPath()

    boardcam.BoardMachine.bottomFileName = filename

    boardcam.BoardMachine.read_machine_data()

    filename = boardcam.BoardMachine.bottomScript

    myconsole.insertText("execfile('" + filename + "')")

    myconsole.enter()

    board_draw = boardcad.gui.jdk.BoardCAD.getInstance().getBoardHandler(
    ).board_draw

    board_draw.bottom_cut = boardcam.BoardMachine.bottom_cut
    board_draw.nr_of_cuts_bottom = boardcam.BoardMachine.nr_of_cuts_bottom
    board_draw.bottom_collision = boardcam.BoardMachine.bottom_collision
コード例 #12
0
def get_file_name():
    fc = JFileChooser()
    result = fc.showOpenDialog(None)
    if not result == JFileChooser.APPROVE_OPTION:
        return None
    file_name = fc.getSelectedFile()
    return file_name
コード例 #13
0
ファイル: NammuController.py プロジェクト: stinney/nammu
    def openFile(self, event=None):
        '''
        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
        4. Display file name in title bar
        '''
        if self.handleUnsaved():
            fileChooser = JFileChooser(self.get_working_dir())
            file_filter = FileNameExtensionFilter("ATF files", ["atf"])
            fileChooser.setFileFilter(file_filter)
            status = fileChooser.showDialog(self.view, "Choose file")

            if status == JFileChooser.APPROVE_OPTION:
                atfFile = fileChooser.getSelectedFile()
                filename = atfFile.getCanonicalPath()
                basename = atfFile.getName()
                atfText = self.readTextFile(filename)
                self.currentFilename = atfFile.getCanonicalPath()
                # Clear ATF area before adding next text to clean up tooltips
                # and such
                self.atfAreaController.clearAtfArea()
                self.atfAreaController.setAtfAreaText(atfText)
                self.logger.debug("File %s successfully opened.", filename)
                self.view.setTitle(basename)

            # TODO: Else, prompt user to choose again before closing

            # Update settings with current file's path
            self.update_config_element(self.get_working_dir(),
                                       'default', 'working_dir')
コード例 #14
0
ファイル: mpconfig.py プロジェクト: DMDhariya/core
 def writeConfigDialog(self, e):
     """Open a file dialog to save configuration"""
     fileChooser = JFileChooser(os.getcwd())
     retval = fileChooser.showSaveDialog(None)
     if retval == JFileChooser.APPROVE_OPTION:
         f = fileChooser.getSelectedFile()
         self.writeConfig(f.getPath())
コード例 #15
0
 def _onExport(control, event):
     component = control.getElement().getRootElement().getComponent()
     openDialog = JFileChooser()
     openDialog.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY)
     response = openDialog.showDialog(component, 'Export')
     if response == JFileChooser.APPROVE_OPTION:
         sf = openDialog.getSelectedFile()
         if sf is not None:
             filename = sf.getPath()
             if filename is not None and os.path.isdir(filename):
                 response = JOptionPane.showOptionDialog(
                     component,
                     'Existing content will be overwritten. Proceed?',
                     'Overwrite existing content',
                     JOptionPane.YES_NO_OPTION,
                     JOptionPane.WARNING_MESSAGE, None,
                     ['Overwrite', 'Cancel'], 'Cancel')
                 if response == JFileChooser.APPROVE_OPTION:
                     exc = None
                     try:
                         project.export(filename)
                     except:
                         exc = JythonException.getCurrentException()
                     if exc is not None:
                         BubblePopup.popupInBubbleAdjacentTo(
                             DefaultPerspective.instance(exc),
                             control.getElement(), Anchor.BOTTOM, True,
                             True)
コード例 #16
0
def searchFile2(event):
    label3.text = "Isi pesan terenkripsi"
    label4.text = "Isi pesan asli"
    myFileChooser = JFileChooser()
    rVal = int(myFileChooser.showOpenDialog(None))
    print rVal
    if (rVal == JFileChooser.APPROVE_OPTION):
        encryptedTextFile.text = myFileChooser.getSelectedFile().getName()
        encryptedTextPath.text = myFileChooser.getCurrentDirectory().toString()
        try:
            myPath = encryptedTextPath.text + "/" + encryptedTextFile.text
            fileReaderX = FileReader(myPath)
            bufferedReaderX = BufferedReader(fileReaderX)
            inputFile = ""
            textFieldReadable = bufferedReaderX.readLine()
            while (textFieldReadable != None):
                inputFile += textFieldReadable
                inputFile += "\n"
                textFieldReadable = bufferedReaderX.readLine()
            pesanAsli.text = inputFile

            import myGUI.saveToFile as convertThis

            return convertThis.convertBackToInt(inputFile)

        except (RuntimeError, TypeError, NameError):
            print "eror gan"
コード例 #17
0
ファイル: NammuController.py プロジェクト: jenshnielsen/nammu
    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")
コード例 #18
0
    def saveFile(self, event=None):
        '''
        If file being edited has a path, then overwrite with latest changes.
        If file was created from scratch and has no path, prompt JFileChooser
        to save in desired location.
        Also checks for project name, and if found, makes it default.
        '''
        atfText = self.atfAreaController.getAtfAreaText()
        if not self.currentFilename:
            fileChooser = JFileChooser(os.getcwd())
            status = fileChooser.showSaveDialog(self.view)
            if status == JFileChooser.APPROVE_OPTION:
                atfFile = fileChooser.getSelectedFile()
                filename = atfFile.getCanonicalPath()
                basename = atfFile.getName()
                self.currentFilename = filename
                self.view.setTitle(basename)
            else:
                return
        try:
            self.writeTextFile(self.currentFilename, atfText)
        except:
            self.logger.error("There was an error trying to save %s.",
                              self.currentFilename)
        else:
            self.logger.info("File %s successfully saved.",
                             self.currentFilename)

        # Find project and add to setting.yaml as default
        project = self.get_project()
        if project:
            if self.config['projects']['default'] != project:
                self.config['projects']['default'] = [project]
                save_yaml_config(self.config)
コード例 #19
0
ファイル: export.py プロジェクト: zorroroot/Autorize
    def exportToCSV(self):
        parentFrame = JFrame()
        fileChooser = JFileChooser()
        fileChooser.setSelectedFile(File("AutorizeReport.csv"))
        fileChooser.setDialogTitle("Save Autorize Report")
        userSelection = fileChooser.showSaveDialog(parentFrame)
        if userSelection == JFileChooser.APPROVE_OPTION:
            fileToSave = fileChooser.getSelectedFile()

        enforcementStatusFilter = self.exportES.getSelectedItem()
        csvContent = "id\tMethod\tURL\tOriginal length\tModified length\tUnauthorized length\tAuthorization Enforcement Status\tAuthorization Unauthenticated Status\n"

        for i in range(0,self._log.size()):

            if enforcementStatusFilter == "All Statuses":
                csvContent += "%d\t%s\t%s\t%d\t%d\t%d\t%s\t%s\n" % (self._log.get(i)._id, self._log.get(i)._method, self._log.get(i)._url, len(self._log.get(i)._originalrequestResponse.getResponse()) if self._log.get(i)._originalrequestResponse is not None else 0, len(self._log.get(i)._requestResponse.getResponse()) if self._log.get(i)._requestResponse is not None else 0, len(self._log.get(i)._unauthorizedRequestResponse.getResponse()) if self._log.get(i)._unauthorizedRequestResponse is not None else 0, self._log.get(i)._enfocementStatus, self._log.get(i)._enfocementStatusUnauthorized)
            elif enforcementStatusFilter == "As table filter":                
                if ((self._extender.showAuthBypassModified.isSelected() and self.BYPASSSED_STR == self._log.get(i)._enfocementStatus) or
                    (self._extender.showAuthPotentiallyEnforcedModified.isSelected() and "Is enforced???" == self._log.get(i)._enfocementStatus) or
                    (self._extender.showAuthEnforcedModified.isSelected() and self.ENFORCED_STR == self._log.get(i)._enfocementStatus) or
                    (self._extender.showAuthBypassUnauthenticated.isSelected() and self.BYPASSSED_STR == self._log.get(i)._enfocementStatusUnauthorized) or
                    (self._extender.showAuthPotentiallyEnforcedUnauthenticated.isSelected() and "Is enforced???" == self._log.get(i)._enfocementStatusUnauthorized) or
                    (self._extender.showAuthEnforcedUnauthenticated.isSelected() and self.ENFORCED_STR == self._log.get(i)._enfocementStatusUnauthorized) or
                    (self._extender.showDisabledUnauthenticated.isSelected() and "Disabled" == self._log.get(i)._enfocementStatusUnauthorized)):
                    csvContent += "%d\t%s\t%s\t%d\t%d\t%d\t%s\t%s\n" % (self._log.get(i)._id, self._log.get(i)._method, self._log.get(i)._url, len(self._log.get(i)._originalrequestResponse.getResponse()) if self._log.get(i)._originalrequestResponse is not None else 0, len(self._log.get(i)._requestResponse.getResponse()) if self._log.get(i)._requestResponse is not None else 0, len(self._log.get(i)._unauthorizedRequestResponse.getResponse()) if self._log.get(i)._unauthorizedRequestResponse is not None else 0, self._log.get(i)._enfocementStatus, self._log.get(i)._enfocementStatusUnauthorized)
            else:
                if (enforcementStatusFilter == self._log.get(i)._enfocementStatus) or (enforcementStatusFilter == self._log.get(i)._enfocementStatusUnauthorized):
                    csvContent += "%d\t%s\t%s\t%d\t%d\t%d\t%s\t%s\n" % (self._log.get(i)._id, self._log.get(i)._method, self._log.get(i)._url, len(self._log.get(i)._originalrequestResponse.getResponse()) if self._log.get(i)._originalrequestResponse is not None else 0, len(self._log.get(i)._requestResponse.getResponse()) if self._log.get(i)._requestResponse is not None else 0, len(self._log.get(i)._unauthorizedRequestResponse.getResponse()) if self._log.get(i)._unauthorizedRequestResponse is not None else 0, self._log.get(i)._enfocementStatus, self._log.get(i)._enfocementStatusUnauthorized)
        
        f = open(fileToSave.getAbsolutePath(), 'w')
        f.writelines(csvContent)
        f.close()
コード例 #20
0
    def initUI(self):

        self.panel = JPanel()
        self.panel.setLayout(BorderLayout())

        chooseFile = JFileChooser()

        chooseFile.setDialogTitle("Select Export Location")
        chooseFile.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY)

        ret = chooseFile.showSaveDialog(self.panel)

        if ret == JFileChooser.APPROVE_OPTION:
            self.file_name = str(chooseFile.getSelectedFile())
            if not chooseFile.getSelectedFile().isDirectory():
                mkdirp(self.file_name)
コード例 #21
0
    def openFile(self, event=None):
        '''
        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
        4. Display file name in title bar
        '''
        if self.handleUnsaved():
            if self.currentFilename:
                default_path = os.path.dirname(self.currentFilename)
            else:
                default_path = os.getcwd()
            fileChooser = JFileChooser(default_path)
            file_filter = FileNameExtensionFilter("ATF files", ["atf"])
            fileChooser.setFileFilter(file_filter)
            status = fileChooser.showDialog(self.view, "Choose file")

            if status == JFileChooser.APPROVE_OPTION:
                atfFile = fileChooser.getSelectedFile()
                filename = atfFile.getCanonicalPath()
                basename = atfFile.getName()
                atfText = self.readTextFile(filename)
                self.currentFilename = atfFile.getCanonicalPath()
                # Clear ATF area before adding next text to clean up tooltips
                # and such
                self.atfAreaController.clearAtfArea()
                self.atfAreaController.setAtfAreaText(atfText)
                self.logger.debug("File %s successfully opened.", filename)
                self.view.setTitle(basename)
 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)
コード例 #23
0
def check_directory(path):

    if (os.path.lexists(path)):
        contents = os.listdir(path)

        if (contents.count("install-birch") == 0):
            print_console("The selected directory " + path +
                          " does NOT contain a BIRCH installation!")
            message = "The selected path does NOT contain a BIRCH installation.\nPlease select the base directory of the installation that you wish to update,\nOr click \"no\" to cancel update."
            reload = JOptionPane.showConfirmDialog(None, message, "Input",
                                                   JOptionPane.YES_NO_OPTION)

            if (reload == JOptionPane.NO_OPTION):
                print_console("User aborted install.")
                commonlib.shutdown()

            fc = JFileChooser()
            fc.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY)
            fc.showOpenDialog(None)
            path = fc.getSelectedFile().getPath()

            check_directory(path)

        else:
            ARGS.install_dir = path
            print_console("The selected directory " + path +
                          " contains a BIRCH installation, it will be updated")
コード例 #24
0
def _show_directory_dialog():
    filechooser = JFileChooser("")
    filechooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY)
    selected = filechooser.showSaveDialog(None)
    if selected == JFileChooser.APPROVE_OPTION:
      file = filechooser.getSelectedFile()
      return file.getAbsolutePath()
コード例 #25
0
 def selectFile(self, event):
     print("Choose !!")
     chooseFile = JFileChooser()
     ret = chooseFile.showDialog(frm.panel, "Choose file")
     if ret == JFileChooser.APPROVE_OPTION:
         file = chooseFile.getSelectedFile()
         frm.jTextField4.setText(file.getCanonicalPath())
コード例 #26
0
ファイル: timecontrol.py プロジェクト: Elhamahm/nengo_1.4
    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()
コード例 #27
0
ファイル: code.py プロジェクト: jlbcontrols/Flintium
def openFolderDialog(dialogTitle):
    from javax.swing import JFileChooser
    chooser = JFileChooser()
    chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY)
    chooser.setDialogTitle(dialogTitle)
    if chooser.showOpenDialog(None) == JFileChooser.APPROVE_OPTION:
        return str(chooser.getSelectedFile())
コード例 #28
0
    def actionPerformed(self, event):
        """Delete the last row"""

        # Generate a save dialog
        dialog = JFileChooser(Prefs.get("roiGroup.importDir", ""))
        dialog.setSelectedFile(File("roiGroups.txt"))
        dialog.setFileFilter(FileNameExtensionFilter("Text file", ["txt"]))
        output = dialog.showOpenDialog(
            self.groupTable)  # could be None argument too

        if output in [JFileChooser.CANCEL_OPTION, JFileChooser.ERROR_OPTION]:
            return
        selectedFile = dialog.getSelectedFile()
        directory = selectedFile.getParent()
        Prefs.set("roiGroup.importDir", directory)
        if not selectedFile.isFile(): return
        filePath = selectedFile.getPath()

        # Read comma-separated group from file
        with open(filePath, "r") as textFile:
            stringGroup = textFile.readline().rstrip()

        # Update table with content of file
        tableModel = self.groupTable.tableModel
        tableModel.setGroupColumn(stringGroup)
コード例 #29
0
 def add_file(self, evt):
     fc = JFileChooser()
     ret = fc.showOpenDialog(self.tab)
     if ret == JFileChooser.APPROVE_OPTION:
         with open(fc.getSelectedFile().getCanonicalPath()) as fd:
             for line in fd:
                 self.listModel.addElement(line)
コード例 #30
0
 def openFile(self, fileext, filedesc, fileparm):
     myFilePath = ''
     chooseFile = JFileChooser()
     myFilter = FileNameExtensionFilter(filedesc, [fileext])
     chooseFile.setFileFilter(myFilter)
     ret = chooseFile.showOpenDialog(self.tab)
     if ret == JFileChooser.APPROVE_OPTION:
         file = chooseFile.getSelectedFile()
         myFilePath = str(file.getCanonicalPath()).lower()
         if not myFilePath.endswith(fileext):
             myFilePath += '.' + fileext
         okWrite = JOptionPane.YES_OPTION
         if os.path.isfile(myFilePath):
             okWrite = JOptionPane.showConfirmDialog(
                 self.tab, 'File already exists. Ok to over-write?', '',
                 JOptionPane.YES_NO_OPTION)
             if okWrite == JOptionPane.NO_OPTION:
                 return
         j = True
         while j:
             try:
                 f = open(myFilePath, mode=fileparm)
                 j = False
             except IOError:
                 okWrite = JOptionPane.showConfirmDialog(
                     self.tab, 'File cannot be opened. Correct and retry?',
                     '', JOptionPane.YES_NO_OPTION)
                 if okWrite == JOptionPane.NO_OPTION:
                     return None, False
         return f, True
コード例 #31
0
ファイル: Autorize.py プロジェクト: MiauWuffMiau/Autorize
    def exportToHTML(self, event):
        parentFrame = JFrame()
        fileChooser = JFileChooser()
        fileChooser.setSelectedFile(File("AutorizeReprort.html"));
        fileChooser.setDialogTitle("Save Autorize Report")
        userSelection = fileChooser.showSaveDialog(parentFrame)
        if userSelection == JFileChooser.APPROVE_OPTION:
            fileToSave = fileChooser.getSelectedFile()

        enforcementStatusFilter = self.exportES.getSelectedItem()
        htmlContent = """<html><title>Autorize Report by Barak Tawily</title>
        <style>
        .datagrid table { border-collapse: collapse; text-align: left; width: 100%; }
         .datagrid {font: normal 12px/150% Arial, Helvetica, sans-serif; background: #fff; overflow: hidden; border: 1px solid #006699; -webkit-border-radius: 3px; -moz-border-radius: 3px; border-radius: 3px; }
         .datagrid table td, .datagrid table th { padding: 3px 10px; }
         .datagrid table thead th {background:-webkit-gradient( linear, left top, left bottom, color-stop(0.05, #006699), color-stop(1, #00557F) );background:-moz-linear-gradient( center top, #006699 5%, #00557F 100% );filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#006699', endColorstr='#00557F');background-color:#006699; color:#FFFFFF; font-size: 15px; font-weight: bold; border-left: 1px solid #0070A8; } .datagrid table thead th:first-child { border: none; }.datagrid table tbody td { color: #00496B; border-left: 1px solid #E1EEF4;font-size: 12px;font-weight: normal; }.datagrid table tbody .alt td { background: #E1EEF4; color: #00496B; }.datagrid table tbody td:first-child { border-left: none; }.datagrid table tbody tr:last-child td { border-bottom: none; }.datagrid table tfoot td div { border-top: 1px solid #006699;background: #E1EEF4;} .datagrid table tfoot td { padding: 0; font-size: 12px } .datagrid table tfoot td div{ padding: 2px; }.datagrid table tfoot td ul { margin: 0; padding:0; list-style: none; text-align: right; }.datagrid table tfoot  li { display: inline; }.datagrid table tfoot li a { text-decoration: none; display: inline-block;  padding: 2px 8px; margin: 1px;color: #FFFFFF;border: 1px solid #006699;-webkit-border-radius: 3px; -moz-border-radius: 3px; border-radius: 3px; background:-webkit-gradient( linear, left top, left bottom, color-stop(0.05, #006699), color-stop(1, #00557F) );background:-moz-linear-gradient( center top, #006699 5%, #00557F 100% );filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#006699', endColorstr='#00557F');background-color:#006699; }.datagrid table tfoot ul.active, .datagrid table tfoot ul a:hover { text-decoration: none;border-color: #006699; color: #FFFFFF; background: none; background-color:#00557F;}div.dhtmlx_window_active, div.dhx_modal_cover_dv { position: fixed !important; }
        table {
        width: 100%;
        table-layout: fixed;
        }
        td {
            border: 1px solid #35f;
            overflow: hidden;
            text-overflow: ellipsis;
        }
        td.a {
            width: 13%;
            white-space: nowrap;
        }
        td.b {
            width: 9%;
            word-wrap: break-word;
        }
        </style>
        <body>
        <h1>Autorize Report<h1>
        <div class="datagrid"><table>
        <thead><tr><th>URL</th><th>Authorization Enforcement Status</th></tr></thead>
        <tbody>"""

        for i in range(0,self._log.size()):
            color = ""
            if self._log.get(i)._enfocementStatus == self._enfocementStatuses[0]:
                color = "red"
            if self._log.get(i)._enfocementStatus == self._enfocementStatuses[1]:
                color = "yellow"
            if self._log.get(i)._enfocementStatus == self._enfocementStatuses[2]:
                color = "LawnGreen"

            if enforcementStatusFilter == "All Statuses":
                htmlContent += "<tr bgcolor=\"%s\"><td><a href=\"%s\">%s</a></td><td>%s</td></tr>" % (color,self._log.get(i)._url,self._log.get(i)._url, self._log.get(i)._enfocementStatus)
            else:
                if enforcementStatusFilter == self._log.get(i)._enfocementStatus:
                    htmlContent += "<tr bgcolor=\"%s\"><td><a href=\"%s\">%s</a></td><td>%s</td></tr>" % (color,self._log.get(i)._url,self._log.get(i)._url, self._log.get(i)._enfocementStatus)

        htmlContent += "</tbody></table></div></body></html>"
        f = open(fileToSave.getAbsolutePath(), 'w')
        f.writelines(htmlContent)
        f.close()
コード例 #32
0
ファイル: mpconfig.py プロジェクト: DMDhariya/core
 def loadConfigDialog(self, e):
     """Open a file dialog to select configuration to load"""
     fileChooser = JFileChooser(os.getcwd())
     retval = fileChooser.showOpenDialog(None)
     if retval == JFileChooser.APPROVE_OPTION:
         f = fileChooser.getSelectedFile()
         log.info("Selected file: " + f.getPath())
         self.loadConfig(f.getPath())
コード例 #33
0
ファイル: meegui_jy.py プロジェクト: fran-jo/SimuGUI
 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()
コード例 #34
0
 def showFC( self, event ) :
     fc = JFileChooser()
     result = fc.showOpenDialog( None )
     if result == JFileChooser.APPROVE_OPTION :
         message = 'result = "%s"' % fc.getSelectedFile()
     else :
         message = 'Request canceled by user'
     self.label.setText( message )
コード例 #35
0
ファイル: demo.py プロジェクト: fran-jo/SimuGUI
 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
コード例 #36
0
 def open(self, e):
     filechooser = JFileChooser()
     filter = FileNameExtensionFilter("c files", ["c"])
     filechooser.addChoosableFileFilter(filter)
     ret = filechooser.showDialog(self.panel, "Elegir fichero")
     if ret == JFileChooser.APPROVE_OPTION:
         file = filechooser.getSelectedFile()
         text = self.readFile(file)
         self.area.setText(text)
コード例 #37
0
def f4_clic_browse1(event):
   print("Click browse 1")
   fc = JFileChooser()
   fc.setCurrentDirectory(gvars['path_JFileChooser'])
   fc.setDialogTitle('Select Directory for multiple images')
   fc.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY)

   result = fc.showOpenDialog( None )
   if result == JFileChooser.APPROVE_OPTION :
      if fc.getSelectedFile().isDirectory():
         message = 'Path to original image %s' % fc.getSelectedFile()
         gvars['path_multiple_image_directory'] = str(fc.getSelectedFile())
         f4_txt1.setText(gvars['path_multiple_image_directory'])
         gvars['path_JFileChooser'] = fc.getSelectedFile()

   else :
      message = 'Request canceled by user'
   print( message )
コード例 #38
0
ファイル: Main.py プロジェクト: sedjrodonan/lositan
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)
コード例 #39
0
ファイル: Burp_MultiProxy.py プロジェクト: 0x24bin/BurpSuite
 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)
コード例 #40
0
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.")
コード例 #41
0
    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)
コード例 #42
0
 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.")
コード例 #43
0
ファイル: SpyDir.py プロジェクト: aur3lius-dev/SpyDir
 def set_plugin_loc(self, event):
     """Attempts to load plugins from a specified location"""
     if self.config['Plugin Folder'] is not None:
         choose_plugin_location = JFileChooser(self.config['Plugin Folder'])
     else:
         choose_plugin_location = JFileChooser()
     choose_plugin_location.setFileSelectionMode(
         JFileChooser.DIRECTORIES_ONLY)
     choose_plugin_location.showDialog(self.tab, "Choose Folder")
     chosen_folder = choose_plugin_location.getSelectedFile()
     self.config['Plugin Folder'] = chosen_folder.getAbsolutePath()
     self._load_plugins(self.config['Plugin Folder'])
コード例 #44
0
ファイル: imagetool.py プロジェクト: bkap/MICT
	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
コード例 #45
0
    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)
コード例 #46
0
    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)
コード例 #47
0
ファイル: SpyDir.py プロジェクト: aur3lius-dev/SpyDir
 def get_source_input(self, event):
     """Sets the source dir/file for parsing"""
     source_chooser = JFileChooser()
     source_chooser.setFileSelectionMode(
         JFileChooser.FILES_AND_DIRECTORIES)
     source_chooser.showDialog(self.tab, "Choose Source Location")
     chosen_source = source_chooser.getSelectedFile()
     try:
         self.source_input = chosen_source.getAbsolutePath()
     except AttributeError:
         pass
     if self.source_input is not None:
         self.update_scroll("[*] Source location: %s" % self.source_input)
         self.curr_conf.setText(self.source_input)
コード例 #48
0
ファイル: meegui_jy.py プロジェクト: fran-jo/SimuGUI
 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()
コード例 #49
0
ファイル: EditSettingsView.py プロジェクト: oracc/nammu
 def browse(self, event=None):
     '''
     Open new dialog for the user to select a path as default working dir.
     '''
     default_path = self.wd_field.getText()
     if not os.path.isdir(default_path):
         default_path = os.getcwd()
     fileChooser = JFileChooser(default_path)
     fileChooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY)
     # Fixed showDialog bug using showOpenDialog instead. The former was
     # duplicating the last folder name in the path due to a Java bug in
     # OSX in the implementation of JFileChooser!
     status = fileChooser.showOpenDialog(self)
     if status == JFileChooser.APPROVE_OPTION:
         self.wd_field.setText(fileChooser.getSelectedFile().toString())
コード例 #50
0
    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)
コード例 #51
0
ファイル: maegui_jy.py プロジェクト: fran-jo/SimuGUI
    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
コード例 #52
0
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
コード例 #53
0
ファイル: __init__.py プロジェクト: jprine/monitoring-module
 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()
コード例 #54
0
ファイル: PoCPlugin.py プロジェクト: bluec0re/pyBurp
    def menuItemClicked(self, menuItemCaption, messageInfo):
        if menuItemCaption == 'Save PoC':

            if self.dir:
                fc = JFileChooser(self.dir)
            else:
                fc = JFileChooser()

            returnVal = fc.showSaveDialog(None)

            if returnVal == JFileChooser.APPROVE_OPTION:
                file = fc.getSelectedFile()

                try:
                    mode = 'w'
                    if file.exists():
                        res = JOptionPane.showConfirmDialog(None, 
                                "File exists. Append?")
                        mode = {
                                JOptionPane.YES_OPTION : 'a',
                                JOptionPane.NO_OPTION : 'w',
                                JOptionPane.CANCEL_OPTION : None,
                                }[res]

                    if not mode:
                        return
                    fp = open(str(file.getAbsolutePath()), mode)
                    for req_resp in messageInfo:
                        req = req_resp.getRequest()
                        resp = req_resp.getResponse()
                        fp.write(req.tostring())
                        fp.write('\r\n\r\n')
                        fp.write(resp.tostring())
                        fp.write('\r\n\r\n')
                    fp.close()
                except Exception, e:
                    JOptionPane.showMessageDialog(None, 
                            "Error during save: " + str(e), "Error",  
                            JOptionPane.ERROR_MESSAGE)
                    raise

                JOptionPane.showMessageDialog(None, 
                            "File was successfully saved", "Ok",  
                            JOptionPane.INFORMATION_MESSAGE)
                self.dir = fc.getCurrentDirectory()
コード例 #55
0
ファイル: Gui.py プロジェクト: pythonoob/SimplePyzzle
    def generate_board(self, event):

        chooser = JFileChooser()
        status = chooser.showOpenDialog(self.frame)
        if status != JFileChooser.APPROVE_OPTION:
            return

        imageFile = chooser.getSelectedFile()

        self.puzzle = SimplePyzzle(float(int(self.combo_box.getSelectedItem())))
        self.draw_board()
        self.load_images(imageFile, self.puzzle.level())
        self.canvas.set_puzzle(self.puzzle)
        width = self.images_dict[0].getWidth()
        height = self.images_dict[0].getHeight()
        size = Dimension(width * self.puzzle.level(), height * self.puzzle.level())
        self.frame.setPreferredSize(size)
        self.frame.setSize(size)
コード例 #56
0
ファイル: NammuController.py プロジェクト: jenshnielsen/nammu
    def saveFile(self, event):
        '''
        1. Check if current file has a filename
        2. Save current file in destination given by user
        '''

        self.consoleController.addText("NammuController: Saving file...")

        fileChooser = JFileChooser()
        status = fileChooser.showSaveDialog(self.view)

        if status == JFileChooser.APPROVE_OPTION:
            atfFile = fileChooser.getSelectedFile()
            filename = atfFile.getCanonicalPath()
            atfText = self.atfAreaController.getAtfAreaText()
            self.writeTextFile(filename, atfText)
            #TODO check returned status?

        self.consoleController.addText(" OK\n")
コード例 #57
0
ファイル: window.py プロジェクト: silvioangels/cb2java-1
    def opencopy(self, e):
        c = None
        if "lastcopy" in self.settings.keys():
            c = JFileChooser(self.settings["lastcopy"])
        else:
            c = JFileChooser()

        r = c.showOpenDialog(self.frame)

        if r == JFileChooser.APPROVE_OPTION:
            f = c.getSelectedFile()
            self.f = f
            s = f.getAbsolutePath()

            self.settings["lastcopy"] = f.getParent()
            self.settings.save()

            #            i = FileInputStream(s)
            self.text.setcopy(s)