[Paraview] Two Python Shell questions

Pat Marion pat.marion at kitware.com
Mon Jun 10 10:40:09 EDT 2013


Hi Bill,

1) I submitted a patch to ParaView that makes copy and paste work.  I think
the patch didn't make it into ParaView 4.0 release candidate, but hopefully
it can be available soon.  The commit is in the PythonQt-pv4.0 branch that
I mentioned to you in another email.  It is:

https://github.com/patmarion/ParaView/commit/4a092e2d9f492ebb77a864d3080823c0b431754f

2) All the Python code in the python shell has to run on the main thread,
so if you have a loop that does not return, it will block the gui.  My
suggestion, if you are using PythonQt, is to use a QTimer to look for
changes to the data file.  Here's a QTimer example using PythonQt which
will not block the gui:


from PythonQt import QtCore, QtGui

def myCallback():
    print 'checking data file...'

timer = QtCore.QTimer()
timer.connect('timeout()', onPlayTimer)
timer.setTimeout(100) # start timer with 100 msec timeout


Pat


On Fri, Jun 7, 2013 at 4:28 PM, Bill Sherman <shermanw at indiana.edu> wrote:

> Hello ParaView people,
>
> I have a couple questions about the Python shell in the ParaView GUI
> client:
>
> 1) Will we be able to paste text from the OS clipboard into the shell
> such that it will be treated as input?  (Currently pasted text gets
> ignored.)
>
> 2) Is there a way to have an ongoing loop that doesn't totally disable
> the client GUI?  My goal is to have a script that watches for a change
> in the data file and then will cause the pipeline to update, but if I
> use the "pyinotify" package, the "loop" method goes into an enduring
> loop, and so the Python shell doesn't relinquish control back to the
> GUI, effectively freezing the ParaView client.  In fact I don't even
> know how to send an interrupt to the Python in the shell.
>
> As a quick test, an infinite while loop has the save effect:
>         -> Tools -> Python Shell
>
>         >>> count = 0
>         >>> while 1:
>         ...   count = count + 1
>         ...   print count
>         ...
>         1
>         2
>         [...]
>
> (frozen GUI).
>
>         Thank you!
>         Bill
>
> --
> Bill Sherman
> Sr. Technology Advisor
> Advanced Visualization Lab
> Pervasive Technology Inst.
> Indiana University
> shermanw at indiana.edu
> ______________________________**_________________
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at http://www.kitware.com/**
> opensource/opensource.html<http://www.kitware.com/opensource/opensource.html>
>
> Please keep messages on-topic and check the ParaView Wiki at:
> http://paraview.org/Wiki/**ParaView <http://paraview.org/Wiki/ParaView>
>
> Follow this link to subscribe/unsubscribe:
> http://www.paraview.org/**mailman/listinfo/paraview<http://www.paraview.org/mailman/listinfo/paraview>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.paraview.org/pipermail/paraview/attachments/20130610/b3f20d4d/attachment.htm>


More information about the ParaView mailing list