<plugin id="TutoPython">

    <requirement id="servicesReg" />

    <extension implements="::fwServices::registry::AppConfig">
        <id>tutoPythonConfig</id>
        <type>parameters</type>
        <config>
            <object type="::fwData::Composite">
                <item key="PythonString">
                    <object type="::fwData::String">

                        <service uid="mainFrame" type="::fwGui::IFrameSrv" impl="::gui::frame::DefaultFrame" autoConnect="no">
                            <gui>
                                <frame>
                                    <name>TutoPython</name>
                                    <icon>Bundles/TutoPython_0-1/tuto.ico</icon>
                                    <minSize width="800" height="600" />
                                </frame>
                                <toolBar>
                                    <toolBitmapSize height="32" width="32" />
                                </toolBar>
                            </gui>
                            <registry>
                                <toolBar sid="toolBar" start="yes" />
                                <view sid="codeEditor" start="yes" />
                            </registry>
                        </service>

                        <service uid="toolBar" type="::fwGui::IToolBarSrv" impl="::gui::aspect::DefaultToolBarSrv" autoConnect="no">
                            <gui>
                                <layout>
                                    <menuItem name="Test" icon="Bundles/TutoPython_0-1/icons/python.png" />
                                    <menuItem name="Open" />
                                    <menuItem name="Quit" icon="Bundles/TutoPython_0-1/icons/cross.png" />
                                </layout>
                            </gui>
                            <registry>
                                <menuItem sid="PyTest" start="yes" />
                                <menuItem sid="action_openFile" start="yes" />
                                <menuItem sid="actionQuit" start="yes" />
                            </registry>
                        </service>


                        <service uid="PyTest" type="::fwGui::IActionSrv" impl="::uiPython::action::StringRun" autoConnect="no">
                            <state active="true" />
                            <!--<pyobjects> -->
                            <!--<item name="" id="" /> -->
                            <!--</pyobjects> -->
                        </service>

                        <service uid="actionQuit" type="::fwGui::IActionSrv" impl="::gui::action::QuitAction" autoConnect="no" />

                        <service uid="codeEditor" type="::gui::editor::IEditor" impl="::guiQt::editor::Code" autoConnect="yes" />

                        <value>
<![CDATA[
import fwData
import numpy

#use 'open' to load an image, then you can use the 'test' button

image = fwData.getObject("anImage")

print "Image informations : "
for attr in ['origin', 'spacing', 'type', 'size' ]:
    print " - ", attr, ':', getattr(image, attr)

#get view on fwData::Image buffer
if image.buffer is not None:
    data = numpy.asarray(image.buffer)

    #work on data ...
    data[ (0 < data) & (data > 10) ] = 5

    #this will retrieve the <anImageWriter> described in the configuration,
    #start, update and stop it. this will show a file dialog box requesting a
    #filename to save the image to.
    writer = fwData.getSrv("anImageWriter")
    writer.start()
    writer.update()
    writer.stop()
]]>
                    </value>

                    </object>
                </item>

                <item key="Image">
                    <object uid="anImage" type="::fwData::Image">
                        <service uid="anImageReader" impl="::uiIO::editor::IOSelectorService" type="::gui::editor::IDialogEditor" autoConnect="no" />
                        <service uid="anImageWriter" impl="::uiIO::editor::IOSelectorService" type="::gui::editor::IDialogEditor" autoConnect="no">
                            <type mode="writer" />
                        </service>

                        <service uid="action_openFile" type="::fwGui::IActionSrv" impl="::gui::action::StarterActionService" autoConnect="no">
                            <start uid="anImageReader" />
                        </service>


                    </object>
                </item>

                <start uid="mainFrame" />
            </object>
        </config>
    </extension>

</plugin>
