Python, PyMOL - how to automatically update working directory upon loading object by drag and drop - pymol

I am using PyMOL and wish to automatically update working directory upon loading object by drag and drop. For example, my current pymol working directory is C:/pymol. I then load a pdb file from C:/pdb. How can Pymol automatically update the current working directory to C:/pdb? If it is difficult, then is it possible to get the output from the drag and drop commoand? I notice that everytime I drop a file into Pymol, there is an output saying "CmdLoad: "C:/pdb/C1.pdb" loaded as "C1". Anyway I can store this output in a variable? Many thanks

Related

Sublime Text 3: import projects list from folder/files to OpenRecent list

I save several projects in a same folder by manual click Project -> Save Project As...
and I used to use cmd + ctrl + p to open Switch Projectlist to switch between projects
and everything's works fine.
but today, I accidentally remove my Switch Project list in by click Project -> Open Recent -> Clear Items, so my Switch Project list is empty now...
I know I could add them back through reopen ALL my projects. due to the number of projects is pretty a lot, that will be kind of annoying to add them back one by one.
I wanna know if there's a smarter way to do that for me.
maybe import all my *.sublime-project files from folder or something.
thanks
Short of manually opening every project, I don't think there is any way to do something like this directly. There isn't a command or plugin endpoint that I'm aware of that lets you open a project by name or filename, so it's not possible to create a plugin to do the work, and Sublime doesn't have the ability to pre-load the list of packages directly either.
That said, it is possible to manually update the list of recent projects, but whether or not that is more or less work than opening all of the projects is something to consider.
If you use Preferences > Browse Packages from the menu or the command palette, a file browser will open on your Packages folder. From there go up one directory level and go inside of the Local folder, where you will find a Session.sublime_session file.
Sublime saves it's state into this file when you quit it, and uses it to restore state when you start it again. Here you will find all of the saved information, such as the windows and files that were open and so on.
Changing this file will change the data that Sublime loads, so you can modify the session file to set up the data that you want. You need to make sure that you modify the file while Sublime is not running or your changes will be ignored and clobbered away. Also it's a good idea to make a backup of the file before you start in case things go pear shaped.
Down near the bottom of the file you will find a top level key named workspaces, and inside of it a recent_workspaces key:
"workspaces":
{
"recent_workspaces":
[
"/home/tmartin/local/src/OverrideAudit/OverrideAudit.sublime-workspace",
]
}
This is where the list of recent projects is stored for use in the menu and the quick switch project command. Particular things to notice are that the entries are naming sublime-workspace files, and that the paths are absolute.
NOTE: On windows, the filenames stored in the session file are in a format like /C/Users/tmartin and not c:\users\tmartin; on that platform you need to make sure that you adjust the paths accordingly. As long as there is already at least one entry in the list when you look at the session file, you can easily see how to construct the paths that you need.
Despite the name of the commands and menu items, what you're actually switching between is different workspaces. Every sublime-project is associated with a sublime-workspace file, which acts as a dedicated sublime_session file for that particular project. This mapping is one-to-many in that you can have multiple workspaces for the same project file, allowing you to reference the same paths in multiple windows but have different window layouts.
While Sublime is not running you can edit this file to add in the full paths to all of your workspace files; when you start Sublime up the list will be populated (every sublime-workspace file knows what sublime-project it is associated with).
What remains is whether or not it's quick to come up with the list of files in a way that you can easily paste them into the session file.

efficient result display for python 3

i have written a program that searches every file/folder that is contained within its current folder for fikes with a certain name. i create a dictionary with a path and a list of names within that folder.
i am looking for an effective way to display that after the program is run. it cant display through the terminal as i plan to compile it and rin it elsewhere. what would be a good way of showing the result? my original plan was to make, edit, open and delete a tempory txt file, but i cant find a way to open it to make it visible to the user.
thanks!

Matlab: open files 'outside Matlab' by default

I'm looking for a way to have Excel files in my Matlab folder open 'outside Matlab' (i.e., by MS Excel in most cases) directly by double-clicking the file, rather than right-clicking and selecting 'Open Outside Matlab'.
The .xls files reader built in Matlab can be terribly slow for large files, and an unwanted double-click on a file can cost quite some time in which Matlab is unresponsive.
Thanks.
When you click something in the Current Folder tab, it's actually running the open command, which itself calls finfo to determine what it means by "open" for a given extension. You can see this by creating a breakpoint in open.m directly after the line [~, openAction] = finfo(fullpath); and double clicking - when it hits the breakpoint you'll see it returns openAction as uiimport.
In theory, you can create custom methods for extensions by creating on the path a function openabc where abc is the extension, which should be returned as the openAction.
However, if I look at my finfo.m it first searches for said functions and then regardless of whether or not it finds them if there is an inbuilt method it overwrites them with the standard behaviour. There's even a comment:
% this setup will not allow users to override the default EXTread behavior
If you are willing to muck about in the inbuilts, you may be able to do it like this (backup first! - this could affect other things). I did it temporarily by shadowing the existing finfo like this:
edit finfo.m (Now save a copy to the current folder)
Add these lines after the loop that defines the openAction (in my version, around line 85):
if any(strcmp(['.' ext], matlab.io.internal.xlsreadSupportedExtensions))
openAction = 'winopen';
end
From the folder containing your edited finfo.m, type which finfo -all. You should see two copies, the MATLAB one labelled as shadowed. Opening something from the current folder window should now open Excel externally.
I don't believe there's any straightforward way to do that. It's built in to MATLAB that Excel files will open in the import tool when you double click on them, and there's no way to change that.
You might be able to get around it by changing the file extension on your Excel files to something other than .xls or .xlsx. That would stop MATLAB from opening it in the import tool. Then in Windows, you could associate the new file extension with Excel.

Corflags.exe cf001 Could not open file for wiriting

I am trying to edit the corflags file so that I can run 32bit applications on a 64 bit pc but everytime I try to edit the file using something like corflags.exe assembly /32bit+ it comes up with the error message cf001 could not open file for writing.
Now I have tried a lot of different options such as:
Running in administrator mode;
Finding the file using a search and checking read only is not ticked
Checking that user full control is ticked
Tried to set the whole folder to non read only
When trying the whole folder, it goes through looking like it has set read-only, but then I click OK and re-right click on the whole folder, the box is filled in (not ticked) does this mean that part of the folder is read only and why does it reset to read only?
I just faced the same problem and have tried the same things.
Run cornflags from an elevated ("Run as administrator") Visual Studio Command Prompt. I did the same for a copy of the original .exe just to make sure no other process was using the program.
Create a copy of the file you intend to target with CorFlags.
(e.g. "WcfServiceHost.exe" --creates--> "WcfServiceHost - Copy.exe")
Rename the original file to something else:
(e.g. "WcfServiceHost.exe" --> "WcfServiceHose_Original.exe")
Rename to copy to the original file name
(e.g. "WcfServiceHose - Copy.exe" --> "WcfServiceHost.exe"
For my purposes, I created copies and named them describing their configuration:
Example:
WCFServiceHost_With32BitOn.exe
WCFServiceHost_With32BitOff.exe
Now I can destroy the WCFServiceHost.exe files and create them from these pre-modified copies. No more CorFlags operations necessary.
Note: this is basically a more verbose version of #RMalke answer and that answer should be marked as the answer.
I realise this is years later, but for anyone else looking, I found that the quickest way was to copy cmd and corflags.exe into the same folder as the one you want to edit. Then run cmd as admin from there.

How to set a project working directory in a UI with wxWidgets?

I'm a newbie at wxWidgets. I'm working with Microsoft Visual Studio 2010.
I have a UI, which needs to take some files as input and outputs other files as results. I want the user to specify a "working directory" so that the program will put the output files into this directory. So I want to take the path from the user using a browse screen, and save that path and use it while defining my output file locations in the code.
How can I do that?
To add to the comment of Radu: you can use the DirDialog (http://docs.wxwidgets.org/trunk/classwx_dir_dialog.html) to get the directory from the user, than save that in a variable and prepend to the file names. You can then also store this directory in a configuration, using wxConfig (http://docs.wxwidgets.org/trunk/classwx_config_base.html) and load that value at program startup so the program remembers the working directory from session to session.

Resources