Home Download Buy Blog Forum Support

Close a specific view?

Close a specific view?

Postby pushxtonotdie on Fri Jan 20, 2012 8:35 pm

Hi, I'm returned a list of views from self.window.views_in_group() in WindowCommand. I'd currently like to iterate over the list of these views and based on certain criteria close them. I'm having a hard time determining how to close these views. How would I go about this?

As a bonus question: I can see that there is a 'close' command, but I'm unable to find any docs for this, nor am I able to locate this command so that I can find out what params I could pass it. I have been looking mainly in the Packages/Default folder. Is there a methodology I can use to find this info out?
pushxtonotdie
 
Posts: 15
Joined: Tue Dec 20, 2011 8:44 pm

Re: Close a specific view?

Postby facelessuser on Fri Jan 20, 2012 10:53 pm

I had to do this in the HexViewer plugin. Make sure you are focused in on the view you want to close and then issue the window command below.

Code: Select all
self.window.focus_view(self.view)
self.window.run_command("close_file")


If the view has unsaved changes, you will have a problem. If you want to close a view like this regardless of whether it has unsaved changes, I believe you can set scratch to true and then close it.

Code: Select all
view.set_scratch(True)
facelessuser
 
Posts: 1575
Joined: Tue Apr 05, 2011 7:38 pm

Re: Close a specific view?

Postby pushxtonotdie on Mon Jan 30, 2012 1:30 am

Sorry for the late reply:

Thanks a lot for the tip. Works great!
pushxtonotdie
 
Posts: 15
Joined: Tue Dec 20, 2011 8:44 pm


Return to Plugin Development

Who is online

Users browsing this forum: No registered users and 10 guests