RE: PyQt and PyROOT

From: Fine, Valeri <fine_at_bnl.gov>
Date: Thu, 11 Jan 2007 11:31:08 -0500


Hello Luca,

> Hi Valeri,
> I apologize for not writing on the root talk forum, but I just
> registered and it seems like

I am forwarding your message to the ROOTTalk and RootDev lists

I am not fluent with Python, sorry. Probably you (or some one from the roottalk) will need to explain me some basic things about Python and Python ROOT.

>From the first glance your trouble is not caused by QtRoot class like
TQtWidget rather by the "pure" Qt class which is QWidget.

By this reason my first question is, "Does your code work if you remove the line

> self.Canvas = TQtWidget(self.CentralWidget)
and replace it with the "pure" Qt class like

         self.Canvas = QWidget(self.CentralWidget); ?

My guess it does work. I did pay an attention to the line

> self.CentralWidget = QWidget()

that your python did not complain about.

 I did see the Python is aware about TQtWidget as well. However it is confused with the ctor parameter QWidget. I do not know how one can "explain" python that this parameter is very pointer to the QWidget class the python is aware about via

> from qt import *

I.e. I did see some confusion with the different dictionaries however my knowledge is not enough to pinpoint the reason.

May be the only thing you need to do is to build the "qtcint" RootCint dictionary for the Qt classes
http://root.bnl.gov/QtRoot/htmldoc/src/qtclasses.h.html. However, I am not sure whether it makes sense for you. It may add the insult to injury ;)

I hope some Python people on list can clarify the issue.

Best Regards

                         Valeri Fine


Brookhaven National Laboratory
Upton, NY 11973, USA
Phone: +1 631 344 7806
Fax: +1 631 344 4206
E-mail: fine_at_bnl.gov

> -----Original Message-----
> From: Luca Baldini [mailto:luca.baldini_at_pi.infn.it]
> Sent: Thursday, January 11, 2007 10:32 AM
> To: Fine, Valeri
> Cc: johan.bregeon_at_pi.infn.it
> Subject: PyQt and PyROOT
>
> Hi Valeri,
> I apologize for not writing on the root talk forum, but I just
> registered and it seems like
> it takes some time for my account to be activated.
> We are trying to put a ROOT canvas on a qt gui and we would like to be
> able to do that from
> python with pyROOT and pyQt (ROOT 5.14.00, qt 3.3.3, pyQt 3.17, python
> 2.5).
> Based on the c++ examples, we tried the following
>
> import sys
> from qt import *
> from ROOT import *
>
> class window(QMainWindow):
> def __init__(self):
> QMainWindow.__init__(self)
> self.CentralWidget = QWidget()
> self.setCentralWidget(self.CentralWidget)
> self.Layout = QGridLayout(self.CentralWidget)
> self.Canvas = TQtWidget(self.CentralWidget)
> self.Layout.addWidget(self.Canvas, 0, 0)
>
>
> if __name__ == '__main__':
> application = QApplication(sys.argv)
> w = window()
> w.show()
> application.exec_loop()
>
>
> but it doesn't work:
>
> Warning in <TClass::TClass>: no dictionary for class QWidget is
available
> Traceback (most recent call last):
> File "window.py", line 18, in <module>
> w = window()
> File "window.py", line 12, in __init__
> self.Canvas = TQtWidget(self.CentralWidget)
> TypeError: TQtWidget::TQtWidget(QWidget* parent = 0) =>
> could not convert argument 1
>
>
> Any suggestion you can give me?
>
> Thanks a lot,
> Luca Baldini, INFN Pisa
Received on Thu Jan 11 2007 - 17:31:32 CET

This archive was generated by hypermail 2.2.0 : Fri Jan 12 2007 - 05:50:00 CET