[Paraview] location of python plugin macro

pat marion pat.marion at kitware.com
Thu Jun 10 09:31:23 EDT 2010


Hi Matt, this patch should do it-

--- a/Qt/Python/pqPythonDialog.cxx
+++ b/Qt/Python/pqPythonDialog.cxx
@@ -163,8 +163,8 @@ void pqPythonDialog::runScript(const QStringList& files)
     QFile file(files[i]);
     if(file.open(QIODevice::ReadOnly))
       {
-      this->Implementation->Ui.shellWidget->executeScript(
-        file.readAll().data());
+      this->runString(QString("__file__ = \"%1\"").arg(files[i]));
+      this->runString(file.readAll().data());
       }
     else
       {


Due to the extra call to runString(), the paraview python shell will display
a new prompt twice.  I'd like to fix that before committing it to paraview.


Pat

On Wed, Jun 9, 2010 at 10:55 PM, <m.c.wilkins at massey.ac.nz> wrote:

>
> Hi Pat,
>
> Thank you for your quick response.
>
> Yes setting the __file__ variable would be great.
>
> Is there a formal way to do a feature request?  From googling, I see
> people have just posted requests to this list.  Is that good enough?
> If so, could we please have this has a feature request?
>
> If it is worth your time, perhaps you could point me to were I should
> start looking and perhaps I might be able to figure out how to
> implement the feature myself.
>
> Thank you
>
> Matt Wilkins
>
> On Wed, Jun 09, 2010 at 10:46:23PM -0400, pat marion wrote:
> > I'm afraid there isn't a way to get the name of the python file that is
> > currently executing.  Paraview reads the contents for the file into a
> string
> > and passes the string to the interpreter, so python has no association
> between
> > the string and the file.  As a feature request, I think it would be
> reasonable
> > to have paraview set the __file__ variable to be the name of the file
> before
> > executing it.
> >
> > Pat
> >
> > On Wed, Jun 9, 2010 at 5:15 PM, <m.c.wilkins at massey.ac.nz> wrote:
> >
> >
> >     Hi,
> >
> >     I would like to find the location of the currently running python
> >     plugin macro.  This is so I can do an import of a library that lives
> >     in a directory relative to the directory where all my paraview
> plugins
> >     live.  Is this possible?
> >
> >     In a normal python programme sys.argv[0] can help me, but ofcourse
> >     that just points to the paraview binary in this case.  os.getcwd() is
> >     no use.  The info is known to paraview (for instance it is in
> >     ~/.config/ParaView/ParaView3.8.0.ini file under the [PythonMacros]
> >     section - but I really don't want to go trolling through that file).
> >
> >     I have quite a few plugins, and I want to do the correct thing by
> >     breaking some of the shared functionality out into a module.
> >
> >     Thanks for any help
> >
> >     Matt
> >
> >     _______________________________________________
> >     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
> >
> >
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.paraview.org/pipermail/paraview/attachments/20100610/385cfccf/attachment.htm>


More information about the ParaView mailing list