Skip to content

SCIRun Python API 0.2

Dan White edited this page Jan 28, 2016 · 29 revisions

TODO TODO TODO

The API contains global functions for network editing, module state modification, and data object extraction and insertion.

Global functions

  • addModule("ModuleName")
    • Adds a new instance of a module to the network. Returns a PyModule object.
  • removeModule(ModuleId)
    • Removes a module by id. Obtain the id from the PyModule object you want to remove.
  • modules()
    • Returns a list of the current modules in the network. (return type PyModule[])
  • executeAll()
    • Executes the entire network.
  • saveNetwork("filename")
    • Coming in milestone G.
  • loadNetwork("filename")
    • Coming in milestone G.
  • quit()
    • Coming in milestone G.

Classes

  • PyModule properties and methods

    • property id
      • Returns string id of the module
    • property stateVars
      • Returns names of settable fields of module's UI
    • property input
      • Returns input PyPorts object
    • property output
      • Returns output PyPorts object
    • method showUI()
      • Shows the UI of the module.
    • method hideUI()
      • Hides the UI of the module.
    • method __getattr__/__setattr__
      • This overridden pair of methods allow the user to set arbitrary state variables of the module, i.e., the values in the UI, via their official state names. (FUTURE FEATURE: a hotkey to view the official state names of every part of the UI).
  • PyPorts

    • Access a port from this list-like object either by index: mod.output[0], or by name: mod.output.Field. Returns a PyPort object.
    • The len() function is also supported to query number of ports: len(mod.output)
  • PyPort

    • properties name, type, isInput
      • Return basic properties of the port
    • operator >>
      • The way to connect modules. Use as an infix operator between output port and input port, for instance:
        • By index: mod1.output[0] >> mod2.input[1]
        • By name: mod1.output.OutputField >> mod2.input.InputField
        • Combo approach: mod1.output[0] >> mod2.input.InputField
    • method connect
      • Alternative to operator>>:
        • mod1.output[0].connect(mod2.input[0])
Clone this wiki locally