ParaView/New Python Features: Difference between revisions

From KitwarePublic
Jump to navigationJump to search
No edit summary
No edit summary
Line 28: Line 28:
=== Trace ===
=== Trace ===


Trace  
Trace is a new module.  It can be imported with 'from paraview import smtrace', but normally the user never needs to directly use the trace module.  The trace tab provides buttons for controlling trace:
 
* Start trace - starts trace.  If an active trace was previously started, it will be stopped, cleared, and restarted.
* Stop trace- stops trace.  The trace output generated so far will not be cleared until trace is started again or the python shell is reset.  Some internal trace data structures hold references to c++ objects, so if you want to make sure everything is cleaned up try resetting the shell.
* Show trace- prints the current trace output in the python shell for display
* Edit trace- opens the built in editor, creates a new document and fills it with the current trace output
* Save trace- opens a prompt for the user to specify a filename and saves trace to disk.  The trace script is now available in the directory view.
 
 
TIP: It's a good idea to stop trace before executing a trace script you just recorded.  What I do is click the Disconnect server button in the paraview toolbar.  This will clear the current pipeline objects, stop trace, and reset the python interpreter.




Line 34: Line 43:


For convenience there is a new built in script editor.  It might be cool in the future to allow the user to specify a command to launch an external editor.  The built in editor can be launched by double
For convenience there is a new built in script editor.  It might be cool in the future to allow the user to specify a command to launch an external editor.  The built in editor can be launched by double
=== UI issues ===
The new tab widget is embeded in the python shell dialog using a QSplitter.  The tabs can be hidden completely by collapsing the splitter.  The splitter state should be remembered between sessions.  So should the size/position of the python dialog, and the size/position of the script editor. 
Please report any ui issues with the new python gui, and include your platform and qt version.


== New C++ API ==
== New C++ API ==

Revision as of 13:55, 6 July 2009

New Python GUI

A new set of tabs has been added to the python shell. The python shell is accessed from the main paraview menu: Tools --> Python Shell. The new tabs are:

  • Directory view
  • Macros
  • Trace

Directory View

This tab has a text entry box to enter a script directory. By default, it is set to a 'demos' subfolder inside the paraview python module directory. Only files in the script directory ending with .py are displayed. The following buttons are available:

  • Refresh - refreshes the directory view, for convenience if you change something on disk that paraview doesn't know about
  • New script - launches the built in editor and displays a new document
  • Run selected - runs the python script currently selected in the directory view
  • Add to macros - adds the currently selected python script to the macro set

Python files in the directory view can be double clicked to open them in the editor.

Macros

Python files in the directory view can be added to the macros set. The current macros set is displayed in the listbox in the macros tab. You can double click a macro to edit its assigned name. The file on disk corresponding to a macro is displayed in the tooltip if you mouseover a macro in the listbox.

Macros are displayed in the macros menu and the macros toolbar. The macro menu is shown/hidden by a checkbox in the macros tab. The macros toolbar can be shown/hidden from the paraview main menu: View --> Toolbars --> Macro Toolbar. Both toolbar and menu are hidden by default, but if you show them it will be remembered between sessions.

Note: python is not initialized until you open the python shell for the first time. If you run a macro from the macro toolbar or menu before the python shell has been opened for the first time, you will notice a slight delay as python initializes itself. You should see a wait cursor while python is initializing.

Trace

Trace is a new module. It can be imported with 'from paraview import smtrace', but normally the user never needs to directly use the trace module. The trace tab provides buttons for controlling trace:

  • Start trace - starts trace. If an active trace was previously started, it will be stopped, cleared, and restarted.
  • Stop trace- stops trace. The trace output generated so far will not be cleared until trace is started again or the python shell is reset. Some internal trace data structures hold references to c++ objects, so if you want to make sure everything is cleaned up try resetting the shell.
  • Show trace- prints the current trace output in the python shell for display
  • Edit trace- opens the built in editor, creates a new document and fills it with the current trace output
  • Save trace- opens a prompt for the user to specify a filename and saves trace to disk. The trace script is now available in the directory view.


TIP: It's a good idea to stop trace before executing a trace script you just recorded. What I do is click the Disconnect server button in the paraview toolbar. This will clear the current pipeline objects, stop trace, and reset the python interpreter.


New built in editor

For convenience there is a new built in script editor. It might be cool in the future to allow the user to specify a command to launch an external editor. The built in editor can be launched by double

UI issues

The new tab widget is embeded in the python shell dialog using a QSplitter. The tabs can be hidden completely by collapsing the splitter. The splitter state should be remembered between sessions. So should the size/position of the python dialog, and the size/position of the script editor. Please report any ui issues with the new python gui, and include your platform and qt version.

New C++ API