Skip to content

Commit

Permalink
Added %Imaris_screenshot screenshot magic
Browse files Browse the repository at this point in the history
  • Loading branch information
zindy committed Apr 18, 2018
1 parent 8ceedc0 commit e814763
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions XTIPython.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,12 +63,14 @@
import hotswap
import ImarisLib
import BridgeLib
import tempfile

from notebook.notebookapp import main
from IPython import get_ipython
from IPython.core.magic import (Magics, magics_class, line_magic, cell_magic, line_cell_magic)
from IPython.testing.skipdoctest import skip_doctest
from IPython.utils.py3compat import unicode_to_str
from IPython.display import Image
import numpy as np
import webbrowser

Expand Down Expand Up @@ -96,6 +98,19 @@ def __init__(self, shell):
shell.user_ns["vScene"]=self.vImaris.GetSurpassScene()
shell.user_ns["vFactory"]=self.vImaris.GetFactory()

@skip_doctest
@line_magic
def imaris_screenshot(self, line):
'''Line-level magic that takes a screenshot of Imaris.
'''

f = tempfile.NamedTemporaryFile(delete=False,suffix='.png')
self.vImaris.SaveSnapShot(f.name)
i = Image(filename=f.name)
f.close()
os.unlink(f.name)
return i

@skip_doctest
@line_magic
def imaris_pull(self, line):
Expand Down

0 comments on commit e814763

Please sign in to comment.