#!/usr/bin/python
#
# A simple PLplot/PyQt example
#
# Copyright (C) 2009 Hazen Babcock
#
# This file is part of PLplot.
#
# PLplot is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Library Public License as published
# by the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# PLplot is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU Library General Public License for more details.
#
# You should have received a copy of the GNU Library General Public License
# along with PLplot; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
#


import sys
from PyQt4 import QtCore, QtGui
import plplot
import plplot_pyqt

class QPlot(QtGui.QMainWindow):
    def __init__(self):
        print "init"
        QtGui.QMainWindow.__init__(self, None)

        self.plot = plplot_pyqt.QtExtWidget(800, 800, self)
        self.setCentralWidget(self.plot)

        plplot_pyqt.plsetqtdev(self.plot)
        plplot.plsdev("extqt")
        plplot.plinit()

        self.resize(400,400)

    def cleanup(self):
        plplot.plend()
        plplot_pyqt.plfreeqtdev()

    def paintEvent(self, event):
        plplot.pladv(0)
        plplot.plenv(0, 10, 0, 10, 0, 0)
        plplot.pllab("X", "Y", "X vs Y")
        self.plot.show()


app = QtGui.QApplication(sys.argv)
plot = QPlot()
plot.show()
app.exec_()
plot.cleanup()


@@ -4,16 +4,20 @@
 usr/bin/
+env 
 python%0A#
@@ -876,16 +876,50 @@
 , QtGui%0A
+from plplot_python_start import *%0A
 import p
@@ -942,16 +942,17 @@
 lot_pyqt
+4
 %0A%0Aclass 
@@ -1101,16 +1101,17 @@
 lot_pyqt
+4
 .QtExtWi
@@ -1192,16 +1192,17 @@
 lot_pyqt
+4
 .plsetqt
@@ -1270,16 +1270,184 @@
 plinit()
+%0A        plplot.pladv(0)%0A        plplot.plvsta()%0A        plplot.plwind(0.0, 1.0, 0., 1.0)%0A        plplot.plcol0(1)%0A        plplot.plbox(%22bcnst%22, 0., 0, %22bcnstv%22, 0., 0)
 %0A%0A      
@@ -1535,16 +1535,17 @@
 lot_pyqt
+4
 .plfreeq

pyqt ==> pyqt4