QFileDialog choose file or folder - dialog

Is there a way to choose file or a folder in QFileDialog window. As far as I've reviewed the documentation and it turns out that I can either open file or directory but I can't use the dialog to open both types at the same time. Is there a way I can do this?

Related

index.sublime-project and index.sublime-workspace files

I have a directory named project, and I navigated to Project > Add Folder to Project... in order to see the directory tree in my left sidebar. I noticed that doing this creates a file called index.sublime-project with the following content:
{
"folders":
[
{
"path": "."
}
]
}
I also noticed that there is another file in my directory called index.sublime-workspace, although this one does not appear in the tree view on the left sidebar of Sublime. It is only visible through windows explorer when I navigated to the Project directory.
What is the purpose of these files? Can I prevent them from being created every time I add folder to project?
Adding directories to the window using Project > Add Folder to Project is indeed one of the ways to open a folder (the others being to drag and drop a folder onto the window and File > Open Folder).
However, doing so do not create those files. To create them, you would need to use the Project > Save Project menu item. So you may have accidentally done that without realizing it. In theory a plugin could also create those files for you, though that seems unlikely (anything is possible though).
In any case, assuming you don't want them it's entirely safe to remove them.
A sublime-project file is a file that allows you to open folders in the side bar and then do things like apply settings that apply only to files in that window, alter what files and folders appear, and so on.
A sublime-workspace file is a localized session information for a particular window. Usually, they associated with a sublime-project file but they don't have to be. They store the state of the window, open files, etc so that you can close a window and then recall it later with the same state.

Sublime Text Does Not Let Me Save My Files

How do I fix this on Mac?
Unable to save /test.py Error: Read-only file system
Since Mojave, you are no longer allowed to write to /. I suspect this is the cause of your problem: nothing to do with Sublime Text.
Pick another directory to save your files to, preferably in your home folder.
Once you make your document, go to File and click Save (or just press cmd+n).
Write the title of your document.
Right under the name there should be a little box that says Macintosh. You can click on it and change it to whatever file you prefer.
you must have left the save location as "macintosh". Basically this error means, that this "macintosh" folder is read-only. There is no issue like "sublime not having permission to write to the disk".
Just save to a usual folder and you would be gtg.
Make sure you save it to your project's folder and not just to the desktop or whatever is the default.

How can I get a file or directory name from a file open dialog in PyQt4?

I am writing a PyQt4 application and one of the file types I wish to open is an Esri Grid format which, rather unusually, is a directory. I also wish to open other GIS filetypes that are just files (e.g. geotiffs). I can open these filetypes OK with the GDAL library by passing either a file or directory name and GDAL figures it out.
The problem I have is making the GUI. I want to open a file open dialog and get either a file name, or directory name. The problem is that the file dialog won't let me choose a directory - only files. I need the dialog to return a path to either. I've tried it on Mac and Linux.
I know PySide has a method called getExistingDirectory
http://pyside.github.io/docs/pyside/PySide/QtGui/QFileDialog.html
PyQt is basically the same, so it should have a similar method. http://pyqt.sourceforge.net/Docs/PyQt4/qfiledialog.html It is in the static methods section.
I think I've cracked it. This snippet tests the functionality I need:
dlg=QtGui.QFileDialog()
dlg.setFileMode(QtGui.QFileDialog.AnyFile);
e=dlg.exec_()
print dlg.selectedFiles()[0]
The solution was to set the file mode to 'AnyFile'. This allows the file dialog to return both directory and file names.

How to open last opned folder in QFileDialog using PyQt

I want to know is it possible to open last browsed folder using QFileDialog
I used QFileDialog to browse and select a file.
Step 1
I browsed c:\test\files and selected xyz filde from that folder
Step2
Again when i need to browse for files. This time i want QFileDialog to point to my last visited folder (i.e., c:\test\files)
I know its is possible to do by saving the current visited directory and use QFileDialog.setDirectory to set the previous directory.
Is there any other option like savelast path browse, something like that....?
Is it possible...?
If YES how can i do it.
You can try using the saveState() and restoreState() methods in conjunction with QSettings, but this is just a variant of saving the last path even if probably it is a better method

Coredata: opening an xcdatamodeld file

I have a single xcdatamodeld file and would merely like to open this particular file with xcode. However, when I double click the file, it doesn't really show me anything or allow editing. The only way to do this is to run MyApp.xcodeproj and only then can I modify this file. Isn't there any way to edit the coredata file using only the xcdatamodel file? Thanks!
The xcdatamodeld file is not actually a file - it's a directory containing other model files.
Right click the file, choose Show Package Contents and you will get access to the files inside the directory. You can then double-click those files. When I do so I get just the Xcode model editor without the full Xcode project window.

Resources