Hi,<br><br>So at the very end of that email that you linked, I mentioned the problem that paraview hangs when it encounters a runtime error, instead of reporting the error. I haven't had the chance to investigate the problem, but it's really annoying!<br>
<br>Anyway, I think your problem is just a few typos... try adding:<br><br><meta name="qrichtext" content="1"><meta http-equiv="Content-Type" content="text/html; charset=utf-8"><style type="text/css">
p, li { white-space: pre-wrap; }
</style>
<p style="margin: 0px; text-indent: 0px;">from PyQt4.QtCore import *</p>
<p style="margin: 0px; text-indent: 0px;"></p><br>at the top. Also, you had commas instead of periods in two places:<br><br>foo,input1 --> foo.input1<br>self, acceptfoo --> self.acceptfoo<br><br><br>I debugged the problems by running your script in regular python. I commented out the callback_wrapper and then just added:<br>
<br>import sys<br>app = QApplication(sys.argv)<br><br>before the main script begins. Doing it this way made it easy to spot the typos.<br><br><br>Pat<br><br><br><div class="gmail_quote">On Wed, Jun 16, 2010 at 5:14 PM, <span dir="ltr"><<a href="mailto:m.c.wilkins@massey.ac.nz">m.c.wilkins@massey.ac.nz</a>></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 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, 'Slice', 'Length')<br>
<br>
to work fine. But I need more complicate dialogs. I just can't get<br>
the signals/slots to work. Yes I have read<br>
<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>
Here is my plugin, and any time I uncomment either of the connect<br>
lines, paraview (built from git about a week ago) just hangs. Without<br>
those lines, the dialog doesn't work of course; I can cancel it with<br>
the window decorator, but that is it.<br>
<br>
Thank you for any help, this is beyond me, just reading the definition<br>
of callback_wrapper makes my head hurt, I hope it doesn't hurt yours<br>
;-)<br>
<br>
Matt<br>
<br>
<br>
from PyQt4.QtGui import *<br>
<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("ModifiedEvent", callback)<br>
return wrap<br>
<br>
class MyDialog(QDialog):<br>
<br>
def __init__(self, *args):<br>
QDialog.__init__(self, *args)<br>
<br>
buttonBox = QDialogButtonBox()<br>
okButton = buttonBox.addButton(buttonBox.Ok)<br>
cancelButton = buttonBox.addButton(buttonBox.Cancel)<br>
<br>
label0 = QLabel("Foo", self)<br>
self.le0 = le0 = QLineEdit(self)<br>
<br>
label1 = QLabel("Bar", self)<br>
self.le1 = le1 = QLineEdit(self)<br>
<br>
# either of these lines cause paraview to lock up<br>
#QObject.connect(okButton, SIGNAL("clicked()"), self, acceptfoo)<br>
#QObject.connect(cancelButton, SIGNAL("clicked()"), self.rejectfoo)<br>
<br>
layout = QGridLayout()<br>
layout.addWidget(label0, 0, 0)<br>
layout.addWidget(le0, 0, 1)<br>
layout.addWidget(label1, 1, 0)<br>
layout.addWidget(le1, 1, 1)<br>
layout.addWidget(buttonBox, 2, 0, 1, 2)<br>
self.setLayout(layout)<br>
<br>
@callback_wrapper<br>
def acceptfoo(self):<br>
self.input0 = self.le0.text()<br>
self.input1 = self.le1.text()<br>
self.accept()<br>
<br>
@callback_wrapper<br>
def rejectfoo(self):<br>
print "Doing reject"<br>
self.reject()<br>
<br>
<br>
foo = MyDialog()<br>
if foo.exec_():<br>
print "OK:", foo.input0, foo,input1<br>
else:<br>
print "They cancelled"<br>
<br>
<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/opensource/opensource.html" target="_blank">http://www.kitware.com/opensource/opensource.html</a><br>
<br>
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>
<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>
</blockquote></div><br>