[PyQt] pyqt-plot

nimi pillai nimi.snowhills at gmail.com
Sun Feb 27 10:43:49 GMT 2011


Hi all,

I am totally new to python programming and especially pyqt..
 I tried to use plot in a small GUI application which should produce a new
figure window when we click the push button.
It works well in Windows. In Ubuntu the plot window appears only once ;ie
first click. But the 'print' statements are appearing.Also the Gui window
becomes active only if we close the figure window.

from pylab import *
import matplotlib.pyplot as plt
import sys
from PyQt4 import QtCore, QtGui
from push import Ui_Form

class Form(QtGui.QMainWindow):

  def __init__(self, parent=None):
    QtGui.QWidget.__init__(self, parent)
    self.ui = Ui_Form()
    self.ui.setupUi(self)
    QtCore.QObject.connect(self.ui.pushButton, QtCore.SIGNAL("clicked()"),
self.toplot)

  def toplot(self):
      x=[1,2,3]
      y=[1,2,3]
      figure(1)
      plot(x,y)
      show()
      print x
      print y


if __name__ == "__main__":
  app = QtGui.QApplication(sys.argv)
  a = Form()
  a.show()
  sys.exit(app.exec_())


Thanks in advance.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.riverbankcomputing.com/pipermail/pyqt/attachments/20110227/61fb9135/attachment.html>


More information about the PyQt mailing list