Hi Luis,

In order to use the python service in a different module/plugin you have to 
load it over the microservices :

mitk::IPythonService* m_PythonService;
us::ServiceReference<mitk::PythonService> m_PythonServiceRef;

us::ModuleContext* context = us::GetModuleContext();
m_PythonServiceRef = context->GetServiceReference<mitk::IPythonService>();
 try {
        m_PythonService = 
context->GetService<mitk::IPythonService>(m_PythonServiceRef);
catch(...){}

Best,
Eric

-----Ursprüngliche Nachricht-----
Von: Goch, Caspar Jonas [mailto:[email protected]] 
Gesendet: Montag, 31. August 2015 11:47
An: 'Luis J. Salvatierra'; 'mitk-users'
Betreff: Re: [mitk-users] MITK Python Plugin

Hi Luis,

Regarding the compile time:
You might want to build your own project based on the MITK-ProjectTemplate [1], 
that way you only need to build MITK once, after that you only build your own 
project (plus you are not modifying MITK's source code, but only your own).

Regarding the compile error:
I assume you build python during the MITK superbuild? If you want help 
regarding the error, please answer the following questions [2].

Regarding python itself:
Eric is going to answer that, as I do not use python myself. Does the python 
console work for you org.mitk.gui.qt.python?

Best,
Caspar

[1] https://github.com/MITK/MITK-ProjectTemplate
[2] http://mitk.org/wiki/BuildErrorHelpQuestions
-----Ursprüngliche Nachricht-----
Von: Luis J. Salvatierra [mailto:[email protected]] 
Gesendet: Freitag, 28. August 2015 11:40
An: mitk-users
Betreff: [mitk-users] MITK Python Plugin

Hi,

first of all, thank all the MITK developers. I started to work with MITK this 
August, and I have to say I feel a bit overwhelmed with the size of the project.

I'm trying to create a Python plugin for MITK, that is, create a plugin with 
`MitkPluginGenerator` with a simple view, process an image with Python and show 
it in the MitkWorkbench.

For now I've been able to compile MITK with a simple C++ plugin, the default 
example with the button `Do something`. And now I'm trying to embed a call to a 
Python script, no luck for now.

I've looked in the documentation and found `mitkPythonService.h`, that contains 
a few functions, and It's a lot easier and simple than full python embedding. 
But now I'm having a lot of problems compiling MITK with this basic example:

'''
...

itk::SmartPointer<mitk::PythonService> _PythonService(new 
mitk::PythonService());

std::string result = _PythonService->Execute( "print ('Hello World!')", 
mitk::IPythonService::SINGLE_LINE_COMMAND );

MITK_INFO << result;
'''

I'll try to figure it out the compiling problem. But I would like to know if 
someone tried this before, if so, do you know if there is any example with 
`mitkPythonService.h`?.

Also, I would like to ask, how to test my Plugin (mitkPythonService) without 
compiling all the MITK project, because it takes me several hours to compile, 
between 6 and 7 hours, with an SSD, Intel i7-4790k and 8GB RAM.

I compile without the `-jX` flag, because it causes compiling erros, I think, 
only when the `MITK_USE_PYTHON` option is enabled, again, I'm not sure. But I 
do now, that everytime I compile with `-jX` I get compile errors, not always 
the same error.

Kind regards and thank you for your time,
--
Luis J. Salvatierra
http://www.ljsalvatierra.com
@Luisja_350
Python San Sebastián - ACPySS

------------------------------------------------------------------------------
_______________________________________________
mitk-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mitk-users
------------------------------------------------------------------------------
_______________________________________________
mitk-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mitk-users
------------------------------------------------------------------------------
_______________________________________________
mitk-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mitk-users

Reply via email to