On Saturday 19 August 2006 12:47, Charlie Moad wrote:
> On 8/19/06, Darren Dale <[EMAIL PROTECTED]> wrote:
> > On Friday 18 August 2006 08:27, Darren Dale wrote:
> > > On Wednesday 16 August 2006 04:54, Samuel GARCIA wrote:
> > > > Thank you,
> > > > Sorry I did known the existence of
> > > > matplotlib.backends.backend_qt4agg. It is more easy than I thought.
> > > >
> > > > but I still have a problem. This is my code :
> > > >
> > > > import sys
> > > >
> > > > from PyQt4.QtCore import *
> > > > from PyQt4.QtGui import *
> > > >
> > > > from matplotlib.backends.backend_qt4agg import FigureCanvasQTAgg as
> > > > FigureCanvas
> > > > from matplotlib.figure import Figure
> > > >
> > > > #--------------------------------------------------------------------
> > > >---- -- ---- class MyWidget(QWidget):
> > > >     def __init__(self, parent=None):
> > > >         QWidget.__init__(self, parent)
> > > >         self.menuBar = QMenuBar()
> > > >         self.fileMenu = QMenu(self.tr("&File"), self)
> > > >         self.menuBar.addMenu(self.fileMenu)
> > > >
> > > >         mainLayout = QVBoxLayout()
> > > >         mainLayout.setMenuBar(self.menuBar)
> > > >
> > > >         self.setLayout(mainLayout)
> > > >
> > > > #--------------------------------------------------------------------
> > > >---- -- ---- if __name__ == "__main__":
> > > >     app = QApplication(sys.argv)
> > > >     dialog = MyWidget()
> > > >     dialog.show()
> > > >     sys.exit(app.exec_())
> > > >
> > > > and it does not works because the main window is blocking.
> >
> > There is a comment in the embedding_in_qt.py example:
> >
> > # The QApplication has to be created before backend_qt is imported,
> > otherwise # it will create one itself.
> >
> > This goes for qt4 as well, and is the source of the problem. You can have
> > only one QApplication at a time. (Ted, John, do you think the
> > QApplication really needs to be created during the module import? show()
> > is the only function that looks for the QApplication, maybe the qApp
> > should be created there instead. Any reason against?)
> >
> > I added an example, embedding_in_qt4.py, to the svn repository. It is
> > closely based on embedding_in_qt.py.
>
> From what I saw, creating QApp in show makes more sense.

I changed the qt backends to create a QApplication in show() rather than at 
the time of module import. I also updated the embedding_in_qt* examples. 
Samuel, as of svn 2711, you are free to create your QApplication *after* you 
import backend_qt(4).

Darren

P.S.- For anyone who is interested, I'd recommend "C++ GUI Programming with Qt 
4" (available at Amazon). I'm not an experienced C++ programmer, but the book 
has an excellent (and brief) introduction to C++ in the appendix, and is easy 
enough to understand for anyone who wants to work with PyQt4.

-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users

Reply via email to