test_closewindow.py 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. """Closing the Rendering Window
  2. Press q:
  3. Control returns to terminal,
  4. window will not close but become unresponsive"""
  5. from vedo import *
  6. mesh = Paraboloid()
  7. plt1 = show(mesh, __doc__, title='First Plotter instance')
  8. # Now press 'q' to exit the window interaction,
  9. # windows stays open but not reactive anymore.
  10. # You can go back to interaction mode by simply calling:
  11. #plt1.interactive()
  12. printc('\nControl returned to terminal shell:', c='tomato', invert=1)
  13. # ask('window is now unresponsive (press Enter here)', c='tomato', invert=1)
  14. plt1.close()
  15. # window should now close, the Plotter instance becomes unusable
  16. # but mesh objects still exist in it:
  17. printc("Objects in first Plotter:", len(plt1.objects), '\nPress q again')
  18. # plt1.show() # error here: window does not exist anymore. Cannot reopen.
  19. # ##################################################################
  20. # Can now create a brand new Plotter and show the old object in it
  21. plt2 = Plotter(title='Second Plotter instance', pos=(500,0))
  22. plt2.show(plt1.objects[0].color('red'))
  23. ##################################################################
  24. # Create a third new Plotter and then close the second
  25. plt3 = Plotter(title='Third Plotter instance')
  26. plt2.close()
  27. printc('plt2.close() called')
  28. plt3.show(Hyperboloid()).close()
  29. printc('done.')