Are you working from a paraview installer, or compiling paraview 
yourself?  I was able to reproduce the linux bug (by putting a 'print 
"hello"' at the end) and then solve it by commenting out two lines in 
ParaView/Qt/Python/pqPythonShell.cxx.  Just search for the lines with 
&quot;processEvents&quot; and comment them out and then recompile.<br><br>
<br>I&#39;ll try to explain it why this fixes the problem-<br>
<br>
Before paraview executes the python script it acquires a lock.  The lock
 is part of the python C api to help make things thread safe ( 
<a href="http://docs.python.org/c-api/init.html#thread-state-and-the-global-interpreter-lock">http://docs.python.org/c-api/init.html#thread-state-and-the-global-interpreter-lock</a>
 ).  Paraview doesn&#39;t use threads, but it uses multiple python 
interpreters, and each interpreter has its own &quot;thread state&quot;.  So 
before any code is executed by the paraview python shell, the shell 
acquires the lock to activate its interpreter.<br>
<br>
Next, the python script hits a print statement which sends an output 
string to the paraview python shell.  The shell calls processEvents so 
that the widget has an opportunity to repaint itself (make the text 
appear on your screen) without having to wait for the entire python 
script to complete execution.  The problem is that during processEvents,
 the events generated by calling show on a PyQt widget are also 
processed.  While processing these events, PyQt tries to acquire the 
lock itself, fails, and then waits- paraview hangs because this all 
happens in the same thread.  The fix is either to comment out the 
processEvents call in pqPythonShell.cxx, or release the lock before calling 
processEvents and then reacquire it afterward.<br>
<br>
I have never tested PyQt+Paraview on Windows, there may be further 
bugs.  Also, there could be other scenarios where the paraview
 python shell and PyQt fight over the lock.<br>
<br>
Hope this helps a bit!<br>
<br>
Pat<br><br><div class="gmail_quote">On Wed, Oct 13, 2010 at 5:29 PM,  <span dir="ltr">&lt;<a href="mailto:m.c.wilkins@massey.ac.nz">m.c.wilkins@massey.ac.nz</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
<br>
Hi<br>
<br>
I posted about this ages ago, and with your help got it working on<br>
linux, but now I am having problems getting it going under Windows.<br>
<br>
Let me summarize what I am doing.<br>
<div class="im"><br>
I am writing a Python plugin, and I want to popup a custom dialog.<br>
For simple dialogs I have found:<br>
<br>
   import PyQt4.QtGui<br>
   l = PyQt4.QtGui.QInputDialog.getText(wid, &#39;Slice&#39;, &#39;Length&#39;)<br>
<br>
</div>to work fine.  But I need more complicate dialogs.  Yes I have read<br>
<div class="im"><br>
   <a href="http://paraview.markmail.org/message/6h767kpak5dcoqwt" target="_blank">http://paraview.markmail.org/message/6h767kpak5dcoqwt</a><br>
<br>
(thanks Pat), otherwise surely I would not have made it this far!<br>
<br>
</div>My code is below.  It runs fine under paraview linux, and it runs fine<br>
in a nonparaview simple test app under Windows, but when running under<br>
paraview on Windows, it hangs when I push the OK button.<br>
<br>
In the URL above, it says one shouldn&#39;t use exec_() and I am<br>
(incidentally it works under linux ok).  I tried to use setModal(True)<br>
then show(), but control returns immediately to me, then paraview<br>
hangs anyway.<br>
<br>
Also in the URL above, the example works just fine for me, unless I<br>
put a simple &#39;print &quot;hello&quot;&#39; at the end, then paraview hangs.<br>
Something way beyond my meagre skills is happening here.  Please any<br>
help is much appreciated!<br>
<br>
<br>
import os,sys<br>
from PyQt4.QtGui import *<br>
from PyQt4.QtCore import *<br>
import paraview<br>
<div class="im"><br>
def callback_wrapper(func):<br>
   v = paraview.vtk.vtkObject()<br>
   def wrap(*args, **kwargs):<br>
      v._args = args<br>
      v._kwargs = kwargs<br>
      v.Modified()<br>
   def callback(o, e): func(*v._args, **v._kwargs)<br>
   v.AddObserver(&quot;ModifiedEvent&quot;, callback)<br>
   return wrap<br>
<br>
class MyDialog(QDialog):<br>
<br>
   def __init__(self, *args):<br>
      QDialog.__init__(self, *args)<br>
</div>      self.start = 0<br>
<div class="im"><br>
      buttonBox = QDialogButtonBox()<br>
      okButton = buttonBox.addButton(buttonBox.Ok)<br>
<br>
</div>      QObject.connect(okButton, SIGNAL(&quot;clicked()&quot;), self.accepted)<br>
      layout = QVBoxLayout()<br>
      layout.addWidget(buttonBox)<br>
<div class="im">      self.setLayout(layout)<br>
<br>
   @callback_wrapper<br>
</div>   def accepted(self):<br>
      self.start = 1<br>
      self.accept()<br>
<br>
#app = QApplication(sys.argv)<br>
<br>
foo = MyDialog()<br>
<br>
# this hangs paraview under windows<br>
#foo.setModal(True)<br>
#foo.show()<br>
<br>
# this works on linux, but hangs (just prints OK:) under windows if<br>
# user pushes OK<br>
if foo.exec_():<br>
   print &quot;OK:&quot;, foo.start<br>
else:<br>
   print &quot;They cancelled&quot;, foo.start<br>
<br>
<br>
<br>
<br>
Matt Wilkins<br>
<div><div></div><div class="h5"><br>
On Thu, Jun 17, 2010 at 10:33:08AM +1200, <a href="mailto:m.c.wilkins@massey.ac.nz">m.c.wilkins@massey.ac.nz</a> wrote:<br>
&gt;<br>
&gt; Hi,<br>
&gt;<br>
&gt; I hang my head in shame, I really should have thrown my code into a<br>
&gt; nonparaview test app.  I will do that in future.<br>
&gt;<br>
&gt; Pat you simply are the best!  Thank you so much.<br>
&gt;<br>
&gt; The business about self.acceptfoo vs self, acceptfoo arises from my<br>
&gt; lack of understanding about the slots/signals in Qt.  I&#39;ve seen stuff<br>
&gt; like:<br>
&gt;<br>
&gt;    QObject.connect(a, SIGNAL(&quot;clicked()&quot;), a, SLOT(&quot;quit()&quot;))<br>
&gt;<br>
&gt; which indicate you put target object, then the slot, but also stuff<br>
&gt; like:<br>
&gt;<br>
&gt;    QObject.connect(a, SIGNAL(&quot;clicked()&quot;), self.rejectfoo)<br>
&gt;<br>
&gt; which I guess you use when the target of the signal is not a Qt SLOT<br>
&gt; as such.<br>
&gt;<br>
&gt; Anyway, I am very thankful to you Pat, and this list in general.<br>
&gt;<br>
&gt; Matt<br>
&gt;<br>
&gt; On Wed, Jun 16, 2010 at 06:11:01PM -0400, pat marion wrote:<br>
&gt; &gt; Hi,<br>
&gt; &gt;<br>
&gt; &gt; So at the very end of that email that you linked, I mentioned the problem that<br>
&gt; &gt; paraview hangs when it encounters a runtime error, instead of reporting the<br>
&gt; &gt; error.  I haven&#39;t had the chance to investigate the problem, but it&#39;s really<br>
&gt; &gt; annoying!<br>
&gt; &gt;<br>
&gt; &gt; Anyway, I think your problem is just a few typos... try adding:<br>
&gt; &gt;<br>
&gt; &gt;<br>
&gt; &gt; from PyQt4.QtCore import *<br>
&gt; &gt;<br>
&gt; &gt;<br>
&gt; &gt; at the top.  Also, you had commas instead of periods in two places:<br>
&gt; &gt;<br>
&gt; &gt; foo,input1  --&gt; foo.input1<br>
&gt; &gt; self, acceptfoo  --&gt; self.acceptfoo<br>
&gt; &gt;<br>
&gt; &gt;<br>
&gt; &gt; I debugged the problems by running your script in regular python.  I commented<br>
&gt; &gt; out the callback_wrapper and then just added:<br>
&gt; &gt;<br>
&gt; &gt; import sys<br>
&gt; &gt; app = QApplication(sys.argv)<br>
&gt; &gt;<br>
&gt; &gt; before the main script begins.  Doing it this way made it easy to spot the<br>
&gt; &gt; typos.<br>
&gt; &gt;<br>
&gt; &gt;<br>
&gt; &gt; Pat<br>
&gt; &gt;<br>
&gt; &gt;<br>
&gt; &gt; On Wed, Jun 16, 2010 at 5:14 PM, &lt;<a href="mailto:m.c.wilkins@massey.ac.nz">m.c.wilkins@massey.ac.nz</a>&gt; wrote:<br>
&gt; &gt;<br>
&gt; &gt;<br>
&gt; &gt;     Hi,<br>
&gt; &gt;<br>
&gt; &gt;     I am writing a Python plugin, and I want to popup a custom dialog.<br>
&gt; &gt;     For simple dialogs I have found:<br>
&gt; &gt;<br>
&gt; &gt;       import PyQt4.QtGui<br>
&gt; &gt;       l = PyQt4.QtGui.QInputDialog.getText(wid, &#39;Slice&#39;, &#39;Length&#39;)<br>
&gt; &gt;<br>
&gt; &gt;     to work fine.  But I need more complicate dialogs.  I just can&#39;t get<br>
&gt; &gt;     the signals/slots to work.  Yes I have read<br>
&gt; &gt;<br>
&gt; &gt;       <a href="http://paraview.markmail.org/message/6h767kpak5dcoqwt" target="_blank">http://paraview.markmail.org/message/6h767kpak5dcoqwt</a><br>
&gt; &gt;<br>
&gt; &gt;     (thanks Pat), otherwise surely I would not have made it this far!<br>
&gt; &gt;<br>
&gt; &gt;     Here is my plugin, and any time I uncomment either of the connect<br>
&gt; &gt;     lines, paraview (built from git about a week ago) just hangs.  Without<br>
&gt; &gt;     those lines, the dialog doesn&#39;t work of course; I can cancel it with<br>
&gt; &gt;     the window decorator, but that is it.<br>
&gt; &gt;<br>
&gt; &gt;     Thank you for any help, this is beyond me, just reading the definition<br>
&gt; &gt;     of callback_wrapper makes my head hurt, I hope it doesn&#39;t hurt yours<br>
&gt; &gt;     ;-)<br>
&gt; &gt;<br>
&gt; &gt;     Matt<br>
&gt; &gt;<br>
&gt; &gt;<br>
&gt; &gt;     from PyQt4.QtGui import *<br>
&gt; &gt;<br>
&gt; &gt;     def callback_wrapper(func):<br>
&gt; &gt;       v = paraview.vtk.vtkObject()<br>
&gt; &gt;       def wrap(*args, **kwargs):<br>
&gt; &gt;          v._args = args<br>
&gt; &gt;          v._kwargs = kwargs<br>
&gt; &gt;          v.Modified()<br>
&gt; &gt;       def callback(o, e): func(*v._args, **v._kwargs)<br>
&gt; &gt;       v.AddObserver(&quot;ModifiedEvent&quot;, callback)<br>
&gt; &gt;       return wrap<br>
&gt; &gt;<br>
&gt; &gt;     class MyDialog(QDialog):<br>
&gt; &gt;<br>
&gt; &gt;       def __init__(self, *args):<br>
&gt; &gt;          QDialog.__init__(self, *args)<br>
&gt; &gt;<br>
&gt; &gt;          buttonBox = QDialogButtonBox()<br>
&gt; &gt;          okButton = buttonBox.addButton(buttonBox.Ok)<br>
&gt; &gt;          cancelButton = buttonBox.addButton(buttonBox.Cancel)<br>
&gt; &gt;<br>
&gt; &gt;          label0 = QLabel(&quot;Foo&quot;, self)<br>
&gt; &gt;          self.le0 = le0 = QLineEdit(self)<br>
&gt; &gt;<br>
&gt; &gt;          label1 = QLabel(&quot;Bar&quot;, self)<br>
&gt; &gt;          self.le1 = le1 = QLineEdit(self)<br>
&gt; &gt;<br>
&gt; &gt;          # either of these lines cause paraview to lock up<br>
&gt; &gt;          #QObject.connect(okButton, SIGNAL(&quot;clicked()&quot;), self, acceptfoo)<br>
&gt; &gt;          #QObject.connect(cancelButton, SIGNAL(&quot;clicked()&quot;), self.rejectfoo)<br>
&gt; &gt;<br>
&gt; &gt;          layout = QGridLayout()<br>
&gt; &gt;          layout.addWidget(label0, 0, 0)<br>
&gt; &gt;          layout.addWidget(le0, 0, 1)<br>
&gt; &gt;          layout.addWidget(label1, 1, 0)<br>
&gt; &gt;          layout.addWidget(le1, 1, 1)<br>
&gt; &gt;          layout.addWidget(buttonBox, 2, 0, 1, 2)<br>
&gt; &gt;          self.setLayout(layout)<br>
&gt; &gt;<br>
&gt; &gt;       @callback_wrapper<br>
&gt; &gt;       def acceptfoo(self):<br>
&gt; &gt;          self.input0 = self.le0.text()<br>
&gt; &gt;          self.input1 = self.le1.text()<br>
&gt; &gt;          self.accept()<br>
&gt; &gt;<br>
&gt; &gt;       @callback_wrapper<br>
&gt; &gt;       def rejectfoo(self):<br>
&gt; &gt;          print &quot;Doing reject&quot;<br>
&gt; &gt;          self.reject()<br>
&gt; &gt;<br>
&gt; &gt;<br>
&gt; &gt;     foo = MyDialog()<br>
&gt; &gt;     if foo.exec_():<br>
&gt; &gt;       print &quot;OK:&quot;, foo.input0, foo,input1<br>
&gt; &gt;     else:<br>
&gt; &gt;       print &quot;They cancelled&quot;<br>
&gt; &gt;<br>
&gt; &gt;<br>
&gt; &gt;<br>
&gt; &gt;     _______________________________________________<br>
&gt; &gt;     Powered by <a href="http://www.kitware.com" target="_blank">www.kitware.com</a><br>
&gt; &gt;<br>
&gt; &gt;     Visit other Kitware open-source projects at <a href="http://www.kitware.com/" target="_blank">http://www.kitware.com/</a><br>
&gt; &gt;     opensource/opensource.html<br>
&gt; &gt;<br>
&gt; &gt;     Please keep messages on-topic and check the ParaView Wiki at: http://<br>
&gt; &gt;     <a href="http://paraview.org/Wiki/ParaView" target="_blank">paraview.org/Wiki/ParaView</a><br>
&gt; &gt;<br>
&gt; &gt;     Follow this link to subscribe/unsubscribe:<br>
&gt; &gt;     <a href="http://www.paraview.org/mailman/listinfo/paraview" target="_blank">http://www.paraview.org/mailman/listinfo/paraview</a><br>
&gt; &gt;<br>
&gt; &gt;<br>
&gt; _______________________________________________<br>
&gt; Powered by <a href="http://www.kitware.com" target="_blank">www.kitware.com</a><br>
&gt;<br>
&gt; Visit other Kitware open-source projects at <a href="http://www.kitware.com/opensource/opensource.html" target="_blank">http://www.kitware.com/opensource/opensource.html</a><br>
&gt;<br>
&gt; Please keep messages on-topic and check the ParaView Wiki at: <a href="http://paraview.org/Wiki/ParaView" target="_blank">http://paraview.org/Wiki/ParaView</a><br>
&gt;<br>
&gt; Follow this link to subscribe/unsubscribe:<br>
&gt; <a href="http://www.paraview.org/mailman/listinfo/paraview" target="_blank">http://www.paraview.org/mailman/listinfo/paraview</a><br>
</div></div></blockquote></div><br>