Hi Matt, this patch should do it-<br><br>--- a/Qt/Python/pqPythonDialog.cxx<br>+++ b/Qt/Python/pqPythonDialog.cxx<br>@@ -163,8 +163,8 @@ void pqPythonDialog::runScript(const QStringList& files)<br> QFile file(files[i]);<br>
if(file.open(QIODevice::ReadOnly))<br> {<br>- this->Implementation->Ui.shellWidget->executeScript(<br>- file.readAll().data());<br>+ this->runString(QString("__file__ = \"%1\"").arg(files[i]));<br>
+ this->runString(file.readAll().data());<br> }<br> else<br> {<br><br><br>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.<br>
<br><br>Pat<br><br><div class="gmail_quote">On Wed, Jun 9, 2010 at 10:55 PM, <span dir="ltr"><<a href="mailto:m.c.wilkins@massey.ac.nz" target="_blank">m.c.wilkins@massey.ac.nz</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><br>
Hi Pat,<br>
<br>
Thank you for your quick response.<br>
<br>
Yes setting the __file__ variable would be great.<br>
<br>
Is there a formal way to do a feature request? From googling, I see<br>
people have just posted requests to this list. Is that good enough?<br>
If so, could we please have this has a feature request?<br>
<br>
If it is worth your time, perhaps you could point me to were I should<br>
start looking and perhaps I might be able to figure out how to<br>
implement the feature myself.<br>
<br>
Thank you<br>
<br>
Matt Wilkins<br>
<div><div></div><div><br>
On Wed, Jun 09, 2010 at 10:46:23PM -0400, pat marion wrote:<br>
> I'm afraid there isn't a way to get the name of the python file that is<br>
> currently executing. Paraview reads the contents for the file into a string<br>
> and passes the string to the interpreter, so python has no association between<br>
> the string and the file. As a feature request, I think it would be reasonable<br>
> to have paraview set the __file__ variable to be the name of the file before<br>
> executing it.<br>
><br>
> Pat<br>
><br>
> On Wed, Jun 9, 2010 at 5:15 PM, <<a href="mailto:m.c.wilkins@massey.ac.nz" target="_blank">m.c.wilkins@massey.ac.nz</a>> wrote:<br>
><br>
><br>
> Hi,<br>
><br>
> I would like to find the location of the currently running python<br>
> plugin macro. This is so I can do an import of a library that lives<br>
> in a directory relative to the directory where all my paraview plugins<br>
> live. Is this possible?<br>
><br>
> In a normal python programme sys.argv[0] can help me, but ofcourse<br>
> that just points to the paraview binary in this case. os.getcwd() is<br>
> no use. The info is known to paraview (for instance it is in<br>
> ~/.config/ParaView/ParaView3.8.0.ini file under the [PythonMacros]<br>
> section - but I really don't want to go trolling through that file).<br>
><br>
> I have quite a few plugins, and I want to do the correct thing by<br>
> breaking some of the shared functionality out into a module.<br>
><br>
> Thanks for any help<br>
><br>
> Matt<br>
><br>
> _______________________________________________<br>
> Powered by <a href="http://www.kitware.com" target="_blank">www.kitware.com</a><br>
><br>
> Visit other Kitware open-source projects at <a href="http://www.kitware.com/" target="_blank">http://www.kitware.com/</a><br>
> opensource/opensource.html<br>
><br>
> Please keep messages on-topic and check the ParaView Wiki at: http://<br>
> <a href="http://paraview.org/Wiki/ParaView" target="_blank">paraview.org/Wiki/ParaView</a><br>
><br>
> Follow this link to subscribe/unsubscribe:<br>
> <a href="http://www.paraview.org/mailman/listinfo/paraview" target="_blank">http://www.paraview.org/mailman/listinfo/paraview</a><br>
><br>
><br>
</div></div></blockquote></div><br>