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
Beispiel #2
0
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
Beispiel #3
0
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
Beispiel #4
0
    def _filepicker(self):
        """
        Run the filepicker and return if approved

        :return: boolean, true if approved
        """
        fileChooser = JFileChooser()
        fileChooser.setCurrentDirectory(File(System.getProperty("user.home")))
        result = fileChooser.showOpenDialog(self.this)
        isApproveOption = result == JFileChooser.APPROVE_OPTION
        if isApproveOption:
            selectedFile = fileChooser.getSelectedFile()
            self._omnibar.setText(selectedFile.getAbsolutePath())
        return isApproveOption
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 )
Beispiel #6
0
 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()
def runScript(event):
    fc = JFileChooser()
    fc.setCurrentDirectory(
        File(boardcad.gui.jdk.BoardCAD.getInstance().defaultDirectory))
    returnVal = fc.showOpenDialog(
        boardcad.gui.jdk.BoardCAD.getInstance().getFrame())
    if (returnVal != JFileChooser.APPROVE_OPTION):
        return
    mfile = fc.getSelectedFile()
    filename = mfile.getPath()
    filename = filename.replace("\\", "/")
    #print (filename + "\n")
    myconsole.insertText("execfile('" + filename + "')")

    myconsole.enter()
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
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 )
Beispiel #10
0
def saveFileDialog(parent, startingDir=None, title=None, extension=None):
    # type: (java.awt.Component, str, str, str) -> (java.io.File, str)
    """Creates a fileChooser.showSaveDialog and returns the selected file.
    
    Args:
    
    * parent (java.awt.Component): Parent component.
    * startingDir (str): Starting directory.
    * title (str): Title of the dialog.
    * fileFilter (str): Extension (without the dot) of the file to look for. E.g., "json"
    
    Returns java.io.File and a string containing the last used directory."""

    fileChooser = JFileChooser()
    if startingDir is not None:
        startingPath = File(startingDir)
        fileChooser.setCurrentDirectory(startingPath)
    if title is not None:
        fileChooser.dialogTitle = title

    # FileNameExtensionFilter
    # https://docs.oracle.com/javase/8/docs/api/javax/swing/filechooser/FileNameExtensionFilter.html
    if extension is not None:
        extensionFilterString = "%s Files (*.%s)" % (extension.upper(),
                                                     extension)
        extensionFilterList = [extension]
        fil = FileNameExtensionFilter(extensionFilterString,
                                      extensionFilterList)
        fileChooser.fileFilter = fil
        fileChooser.addChoosableFileFilter(fil)

    fileChooser.fileSelectionMode = JFileChooser.FILES_ONLY
    returnVal = fileChooser.showSaveDialog(parent)
    if returnVal != JFileChooser.APPROVE_OPTION:
        # export cancelled or there was an error
        return None, ""

    # store the used directory
    lastDir = fileChooser.getCurrentDirectory().toString()
    # get file path
    selectedFile = fileChooser.getSelectedFile()
    return selectedFile, lastDir
Beispiel #11
0
def FolderDialog(title, folder):
  fc = JFileChooser()
  fc.setMultiSelectionEnabled(False)
  fc.setDialogTitle(title)
  fc.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
  fc.setAcceptAllFileFilterUsed(False);
  if folder ==None:
    sdir = OpenDialog.getDefaultDirectory()
  else:
    sdir = folder
  if sdir!=None:
    fdir = File(sdir)
  if fdir!=None:
    fc.setCurrentDirectory(fdir)
  returnVal = fc.showOpenDialog(IJ.getInstance())
  if returnVal!=JFileChooser.APPROVE_OPTION:
    return
  folder = fc.getSelectedFile();
  path = os.path.join(folder.getParent(), folder.getName())
  return path
Beispiel #12
0
 def go(self, fileTypes=None, default=None, directoryAllowed=False):
     fileChooser = JFileChooser()
     if self.title:
         fileChooser.setDialogTitle(self.title)
     if default:
         fileChooser.setSelectedFile(java.io.File(default))
     fileChooser.setCurrentDirectory(java.io.File("."))
     if fileTypes:
         for extension, description in fileTypes:
            fileChooser.addChoosableFileFilter(FileFilterForExtension(extension, description))            
     if self.loadOrSave == "load":
         result = fileChooser.showOpenDialog(self.parent)
     else:
         result = fileChooser.showSaveDialog(self.parent)
     if (result == JFileChooser.APPROVE_OPTION):
         fileResult = None
         fileAndMaybeDir = fileChooser.getSelectedFile().getAbsoluteFile()
         if directoryAllowed or not fileAndMaybeDir.isDirectory():
             fileResult = str(fileAndMaybeDir)
         return fileResult
     else:
         return None
all.add( minField )
all.add( JLabel("Max") )
all.add(maxField )
all.add( JLabel("Score :") )
all.add(scoreField)
frame = JFrame("CCM scoring")
frame.getContentPane().add(JScrollPane(all))
frame.pack()
frame.addWindowListener( Closing() )
scoreField.requestFocusInWindow()

# Get the grid files
chooser = JFileChooser()
chooser.setDialogTitle("Choose plate grids")
chooser.setMultiSelectionEnabled(True)
chooser.setCurrentDirectory( File(os.path.expanduser("~")))
chooser.showOpenDialog(JPanel())

# This is a hack to get a file path from the
# sun.awt.shell.DefaultShellFolder object returned by the chooser
fp = [str(i) for i in chooser.getSelectedFiles()]

if len(fp) != 0:
    gd = GenericDialog("Name your output file")
    gd.addStringField("Score file name", "scores.csv")
    gd.showDialog()
    if not gd.wasCanceled():
        scoreFile = gd.getNextString()
        scoreFile = os.path.join( os.path.split(fp[0])[0], scoreFile)
        cropDir = os.path.splitext( scoreFile)[0] + "_cropped"
        # Initialize the grid readers
Beispiel #14
0
 def find_binary(parent):
     fileChooser = JFileChooser()
     fileChooser.setCurrentDirectory(File(System.getProperty("user.home")))
     result = fileChooser.showOpenDialog(parent)
     if (result == JFileChooser.APPROVE_OPTION):
         return fileChooser.getSelectedFile().getAbsolutePath()
        filename = f.getName()
        print filename
        filenana, file_extension = os.path.splitext(filename)
        return file_extension


argvs = sys.argv
argc = len(argvs)
defaultpath = '/'
frontoutputpath2 = '/'

xmlfil = XMLFilter('kike')
print xmlfil.getDescription()
chooser = JFileChooser()
fakefile = File(defaultpath)
chooser.setCurrentDirectory(fakefile)
chooser.setDialogTitle("Select xml file")
chooser.setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES)
chooser.setAcceptAllFileFilterUsed(False)
InputFolderPath = ''
if (chooser.showOpenDialog(None) == JFileChooser.APPROVE_OPTION):
    IJ.log("getCrrentDirectory(): " + chooser.getCurrentDirectory().toString())
    InputFolderPath = chooser.getSelectedFile().toString()
else:
    IJ.log("No selection")
file = File(InputFolderPath)

# We have to feed a logger to the reader.
logger = Logger.IJ_LOGGER

#-------------------