1313from PyQt4 import QtGui , QtCore
1414
1515from matplotlib .numerix import arange , sin , pi
16-
17- # The QApplication has to be created before backend_qt is imported, otherwise
18- # it will create one itself.
19- # Note: color-intensive applications may require a different color allocation
20- # strategy.
21- QtGui .QApplication .setColorSpec (QtGui .QApplication .NormalColor )
22- qApp = QtGui .QApplication (sys .argv )
23-
2416from matplotlib .backends .backend_qt4agg import FigureCanvasQTAgg as FigureCanvas
2517from matplotlib .figure import Figure
2618
27- # This seems to be what PyQt expects, according to the examples shipped in
28- # its distribution.
29- TRUE = 1
30- FALSE = 0
31-
3219progname = os .path .basename (sys .argv [0 ])
3320progversion = "0.1"
3421
@@ -44,7 +31,7 @@ def __init__(self, parent=None, width=5, height=4, dpi=100):
4431 self .compute_initial_figure ()
4532
4633 FigureCanvas .__init__ (self , self .fig )
47- self .setParent (parent )#, QtCore.QPoint(0, 0))
34+ self .setParent (parent )
4835
4936 FigureCanvas .setSizePolicy (self ,
5037 QtGui .QSizePolicy .Expanding ,
@@ -117,7 +104,7 @@ def __init__(self):
117104 self .statusBar ().showMessage ("All hail matplotlib!" , 2000 )
118105
119106 def fileQuit (self ):
120- qApp . exit ( 0 )
107+ self . close ( )
121108
122109 def closeEvent (self , ce ):
123110 self .fileQuit ()
@@ -132,13 +119,17 @@ def about(self):
132119
133120It may be used and modified with no restriction; raw copies as well as
134121modified versions may be distributed without limitation."""
135- % {"prog" : progname , "version" : progversion })
122+ % {"prog" : progname , "version" : progversion })
136123
137124
138125def main ():
126+ # Note: color-intensive applications may require a different color
127+ # allocation strategy.
128+ QtGui .QApplication .setColorSpec (QtGui .QApplication .NormalColor )
129+ qApp = QtGui .QApplication (sys .argv )
130+
139131 aw = ApplicationWindow ()
140132 aw .setWindowTitle ("%s" % progname )
141- ## qApp.setMainWidget(aw)
142133 aw .show ()
143134 sys .exit (qApp .exec_ ())
144135
0 commit comments