[Paraview] Pre-load python macros & toolbar icons?

pat marion pat.marion at kitware.com
Wed Nov 11 10:20:02 EST 2009


You can install individual files or whole directories.  Just run
"cmake --help-command install" for help, or search in paraview's
source code for "INSTALL(DIRECTORY" or "INSTALL(FILES" for examples.

To add macros programatically- at runtime determine the path to the
python macro file you want to add (get the path to the paraview.exe
and then you should know where the .py file is relative to that,
search the source code for "applicationDirPath" for an example) then
just call the static method:

pqPythonMacroSupervisor::addMacro(label, filename);

Probably you only want to do this on the first run, after that the
macro is stored in the paraview ini settings file.  You need to call
addMacro before the macro toolbar is populated because the method to
refresh the macro toolbar is protected
(pqPythonMacroSupervisor::resetActions()).  The toolbar is populated
after the call to addWidgetForMacros() in pqClientMainWindow.

Pat

On Wed, Nov 11, 2009 at 10:04 AM, Eric E. Monson <emonson at cs.duke.edu> wrote:
> Hey guys,
>
> Thanks a lot for the responses. I'll add the icon thing as a feature
> request, but I'm interested in figuring out how to add the macros, either
> embedded in a plugin or in my custom application code.
>
> If I was doing it as a plugin: building an autostart plugin shouldn't be a
> problem, but I don't know how to "programmatically add python macros" -- do
> you just use the pqPythonMacroSupervisor somehow...? I also have never run
> across the CMake ADD_PYTHON_EXTENSION before. I see the section in the
> Plugin_HowTo about Embedding Python Source as Modules, but I'm not sure what
> a "python extension" is or what exactly it does...
>
> If I was adding the macros in my custom application constructor: I have my
> macros as .py files, but I'm not clear on what "custom install rules" are.
> Can I somehow just use the macro supervisor to add macros from the files in
> my constructor? (Oh, I bet you're referring to how to use CMake to package
> the .py files afterwards so they tag along with the libraries, etc, for the
> app to find them! Yup, I have no idea how to do that, eitther. :)
>
> So, Pat, if you're willing to give me some pointers (or pointers to source
> code) to get me going in the right direction, I'd really appreciate it!
>
> Thanks again,
> -Eric
>
>
> On Nov 10, 2009, at 6:03 PM, pat marion wrote:
>
>> Actually, if you're making a custom application then you don't even
>> need to worry about plugins, you can just insert one line in your
>> application constructor to add python macros.  You'll need to write
>> the macros as .py files and write custom install rules for them.
>>
>> Pat
>>
>> On Tue, Nov 10, 2009 at 5:56 PM, pat marion <pat.marion at kitware.com>
>> wrote:
>>>
>>> There is no way to do this right now, but if you want to try what Dave
>>> said, write an autostart plugin, the plugin can programatically add
>>> python macros.  I can give you a hint if you want to try this.
>>>
>>> No way to associate an icon with the macros.  Currently macros are
>>> stored in the paraview settings file as <label, filename> pairs.  This
>>> could be extended to store qrc icon filenames without too much
>>> trouble.
>>>
>>> Pat
>>>
>>> On Tue, Nov 10, 2009 at 5:14 PM, Berk Geveci <berk.geveci at kitware.com>
>>> wrote:
>>>>
>>>> I am guessing that these will have to be feature requests. I am sure
>>>> you know where those go :-)
>>>>
>>>> On Tue, Nov 10, 2009 at 3:51 PM, Eric E. Monson <emonson at cs.duke.edu>
>>>> wrote:
>>>>>
>>>>> Hello,
>>>>>
>>>>> I'm wondering if it is possible for ParaView to automatically load
>>>>> Python
>>>>> macros? (Like plugins, where PV looks in certain places to load
>>>>> automatically, or through some XML?)
>>>>>
>>>>> I understand that once macros are loaded they'll show up again the next
>>>>> time
>>>>> PV is launched, but I was wondering in the context of delivering a
>>>>> custom
>>>>> application where I'd like to fill the toolbar with macros right from
>>>>> the
>>>>> first launch.
>>>>>
>>>>> Also, is there any way to associate an icon with a macro (like you can
>>>>> with
>>>>> a filter)?
>>>>>
>>>>> Thanks,
>>>>> -Eric
>>>>>
>>>>> ------------------------------------------------------
>>>>> Eric E Monson
>>>>> Duke Visualization Technology Group
>>>>>
>>>>>
>>>>>
>>>>> _______________________________________________
>>>>> Powered by www.kitware.com
>>>>>
>>>>> Visit other Kitware open-source projects at
>>>>> http://www.kitware.com/opensource/opensource.html
>>>>>
>>>>> Please keep messages on-topic and check the ParaView Wiki at:
>>>>> http://paraview.org/Wiki/ParaView
>>>>>
>>>>> Follow this link to subscribe/unsubscribe:
>>>>> http://www.paraview.org/mailman/listinfo/paraview
>>>>>
>>>> _______________________________________________
>>>> Powered by www.kitware.com
>>>>
>>>> Visit other Kitware open-source projects at
>>>> http://www.kitware.com/opensource/opensource.html
>>>>
>>>> Please keep messages on-topic and check the ParaView Wiki at:
>>>> http://paraview.org/Wiki/ParaView
>>>>
>>>> Follow this link to subscribe/unsubscribe:
>>>> http://www.paraview.org/mailman/listinfo/paraview
>>>>
>>>
>
>


More information about the ParaView mailing list