import numpy as np
from PyQt4 import QtCore, QtGui
import PyQt4.Qwt5 as Qwt
import sys, os, csv
from PyQt4.QtCore import *
from PyQt4.QtGui import *
import random
try:
_fromUtf8
= QtCore.
QString.
fromUtf8except AttributeError:
def _fromUtf8(s):
return s
try:
def _translate(context, text, disambig):
return QtGui.
QApplication.
translate(context, text, disambig, _encoding
) except AttributeError:
def _translate(context, text, disambig):
return QtGui.
QApplication.
translate(context, text, disambig
)
def setupUi(self, MainWindow):
MainWindow.setObjectName(_fromUtf8("MainWindow"))
MainWindow.resize(800, 663)
self.
centralwidget = QtGui.
QWidget(MainWindow
) self.centralwidget.setObjectName(_fromUtf8("centralwidget"))
self.
pushButton_1 = QtGui.
QPushButton(self.
centralwidget) self.
pushButton_1.
setGeometry(QtCore.
QRect(60,
20,
311,
27)) self.pushButton_1.setObjectName(_fromUtf8("pushButton_1"))
self.
pushButton_2 = QtGui.
QPushButton(self.
centralwidget) self.
pushButton_2.
setGeometry(QtCore.
QRect(60,
70,
311,
27)) self.pushButton_2.setObjectName(_fromUtf8("pushButton_2"))
self.
qwtPlot_2 = Qwt.
QwtPlot(self.
centralwidget) self.
qwtPlot_2.
setGeometry(QtCore.
QRect(60,
170,
400,
200)) self.qwtPlot_2.setObjectName(_fromUtf8("qwtPlot_2"))
self.
qwtPlot_2.
setAxisTitle(Qwt.
QwtPlot.
xBottom,
'x -->') self.
qwtPlot_2.
setAxisTitle(Qwt.
QwtPlot.
yLeft,
'y -->') pen.setColor(Qt.black)
pen.setWidth(0)
grid.setPen(pen)
grid.attach(self.qwtPlot_2)
self.
qwtPlot_3 = Qwt.
QwtPlot(self.
centralwidget) self.
qwtPlot_3.
setGeometry(QtCore.
QRect(60,
390,
400,
200)) self.qwtPlot_3.setObjectName(_fromUtf8("qwtPlot_3"))
self.
qwtPlot_3.
setAxisTitle(Qwt.
QwtPlot.
xBottom,
'x -->') self.
qwtPlot_3.
setAxisTitle(Qwt.
QwtPlot.
yLeft,
'y -->') pen.setColor(Qt.black)
pen.setWidth(0)
grid.setPen(pen)
grid.attach(self.qwtPlot_3)
MainWindow.setCentralWidget(self.centralwidget)
self.
menubar = QtGui.
QMenuBar(MainWindow
) self.
menubar.
setGeometry(QtCore.
QRect(0,
0,
800,
25)) self.menubar.setObjectName(_fromUtf8("menubar"))
MainWindow.setMenuBar(self.menubar)
self.statusbar.setObjectName(_fromUtf8("statusbar"))
MainWindow.setStatusBar(self.statusbar)
self.retranslateUi(MainWindow)
self.centralwidget.connect(self.pushButton_1, QtCore.SIGNAL('clicked()'), self.showDialog)
def retranslateUi(self, MainWindow):
MainWindow.setWindowTitle(_translate("MainWindow", "MainWindow", None))
self.pushButton_1.setText(_translate("MainWindow", "Selec file txt", None))
self.pushButton_2.setText(_translate("MainWindow", "Plot", None))
#------------------------------------------------------------------------
#azione apertura file0
#------------------------------------------------------------------------
def showDialog(self):
fname
= QtGui.
QFileDialog.
getOpenFileName(self,
'Open a data file',
'.',
'txt files (*.txt);;All Files (*.*)') f = open(fname, 'r')
with f:
data = np.genfromtxt(f, skiprows=1)
self.tdata = data[:,0]
self.cdata = data[:,1]
curve.setData(range(len(self.tdata)), self.tdata)
curve.attach(self.qwtPlot_3)
print 'hello'
#
if __name__ == "__main__":
import sys
ui = Ui_MainWindow()
ui.setupUi(MainWindow)
MainWindow.show()
sys.exit(app.exec_())
import numpy as np
from PyQt4 import QtCore, QtGui
import PyQt4.Qwt5 as Qwt
import sys, os, csv
from PyQt4.QtCore import *
from PyQt4.QtGui import *
import random
try:
_fromUtf8 = QtCore.QString.fromUtf8
except AttributeError:
def _fromUtf8(s):
return s
try:
_encoding = QtGui.QApplication.UnicodeUTF8
def _translate(context, text, disambig):
return QtGui.QApplication.translate(context, text, disambig, _encoding)
except AttributeError:
def _translate(context, text, disambig):
return QtGui.QApplication.translate(context, text, disambig)
class Ui_MainWindow(QtGui.QMainWindow):
def setupUi(self, MainWindow):
MainWindow.setObjectName(_fromUtf8("MainWindow"))
MainWindow.resize(800, 663)
self.centralwidget = QtGui.QWidget(MainWindow)
self.centralwidget.setObjectName(_fromUtf8("centralwidget"))
self.pushButton_1 = QtGui.QPushButton(self.centralwidget)
self.pushButton_1.setGeometry(QtCore.QRect(60, 20, 311, 27))
self.pushButton_1.setObjectName(_fromUtf8("pushButton_1"))
self.pushButton_2 = QtGui.QPushButton(self.centralwidget)
self.pushButton_2.setGeometry(QtCore.QRect(60, 70, 311, 27))
self.pushButton_2.setObjectName(_fromUtf8("pushButton_2"))
self.qwtPlot_2 = Qwt.QwtPlot(self.centralwidget)
self.qwtPlot_2.setGeometry(QtCore.QRect(60, 170, 400, 200))
self.qwtPlot_2.setObjectName(_fromUtf8("qwtPlot_2"))
self.qwtPlot_2.setAxisTitle(Qwt.QwtPlot.xBottom, 'x -->')
self.qwtPlot_2.setAxisTitle(Qwt.QwtPlot.yLeft, 'y -->')
grid = Qwt.QwtPlotGrid()
pen = QPen(Qt.DotLine)
pen.setColor(Qt.black)
pen.setWidth(0)
grid.setPen(pen)
grid.attach(self.qwtPlot_2)
self.qwtPlot_3 = Qwt.QwtPlot(self.centralwidget)
self.qwtPlot_3.setGeometry(QtCore.QRect(60, 390, 400, 200))
self.qwtPlot_3.setObjectName(_fromUtf8("qwtPlot_3"))
self.qwtPlot_3.setAxisTitle(Qwt.QwtPlot.xBottom, 'x -->')
self.qwtPlot_3.setAxisTitle(Qwt.QwtPlot.yLeft, 'y -->')
grid = Qwt.QwtPlotGrid()
pen = QPen(Qt.DotLine)
pen.setColor(Qt.black)
pen.setWidth(0)
grid.setPen(pen)
grid.attach(self.qwtPlot_3)
MainWindow.setCentralWidget(self.centralwidget)
self.menubar = QtGui.QMenuBar(MainWindow)
self.menubar.setGeometry(QtCore.QRect(0, 0, 800, 25))
self.menubar.setObjectName(_fromUtf8("menubar"))
MainWindow.setMenuBar(self.menubar)
self.statusbar = QtGui.QStatusBar(MainWindow)
self.statusbar.setObjectName(_fromUtf8("statusbar"))
MainWindow.setStatusBar(self.statusbar)
self.retranslateUi(MainWindow)
QtCore.QMetaObject.connectSlotsByName(MainWindow)
self.centralwidget.connect(self.pushButton_1, QtCore.SIGNAL('clicked()'), self.showDialog)
def retranslateUi(self, MainWindow):
MainWindow.setWindowTitle(_translate("MainWindow", "MainWindow", None))
self.pushButton_1.setText(_translate("MainWindow", "Selec file txt", None))
self.pushButton_2.setText(_translate("MainWindow", "Plot", None))
#------------------------------------------------------------------------
#azione apertura file0
#------------------------------------------------------------------------
def showDialog(self):
fname = QtGui.QFileDialog.getOpenFileName(self, 'Open a data file', '.', 'txt files (*.txt);;All Files (*.*)')
f = open(fname, 'r')
with f:
data = np.genfromtxt(f, skiprows=1)
self.tdata = data[:,0]
self.cdata = data[:,1]
curve=Qwt.QwtPlotCurve('ciao')
curve.setData(range(len(self.tdata)), self.tdata)
curve.attach(self.qwtPlot_3)
print 'hello'
#
if __name__ == "__main__":
import sys
app = QtGui.QApplication(sys.argv)
MainWindow = QtGui.QMainWindow()
ui = Ui_MainWindow()
ui.setupUi(MainWindow)
MainWindow.show()
sys.exit(app.exec_())
To copy to clipboard, switch view to plain text mode
Bookmarks