vtkTkPhotoImage.py 924 B

123456789101112131415161718192021222324252627282930313233
  1. """
  2. A subclass of tkinter.PhotoImage that connects a
  3. vtkImageData to a photo widget.
  4. Created by Daniel Blezek, August 2002
  5. """
  6. from __future__ import absolute_import
  7. import sys
  8. if sys.hexversion < 0x03000000:
  9. # for Python2
  10. import Tkinter as tkinter
  11. else:
  12. # for Python3
  13. import tkinter
  14. from .vtkLoadPythonTkWidgets import vtkLoadPythonTkWidgets
  15. class vtkTkPhotoImage ( tkinter.PhotoImage ):
  16. """
  17. A subclass of PhotoImage with helper functions
  18. for displaying vtkImageData
  19. """
  20. def __init__ ( self, **kw ):
  21. # Caller the superclass
  22. tkinter.PhotoImage.__init__ ( self, kw )
  23. vtkLoadPythonTkWidgets ( self.tk )
  24. def PutImageSlice ( self, image, z, orientation='transverse', window=256, level=128 ):
  25. t = str ( image.__this__ )
  26. s = 'vtkImageDataToTkPhoto %s %s %d %s %d %d' % ( t, self.name, z, orientation, window, level )
  27. self.tk.eval ( s )