PyQT+pyQTgui communicate with curvewidget



  • dear all,
    I am trying to create my first PyQT with guiqwt. All work expet that I am not able to communicate with my curvewidget. It is a compatibilitu problem or it is my fault?
    Yhanks in advance to everyone

    This is my code:

    @

    -- coding: utf-8 --

    Form implementation generated from reading ui file 'form_2.ui'

    Created: Fri Aug 1 19:49:00 2014

    by: PyQt4 UI code generator 4.10.4

    WARNING! All changes made in this file will be lost!

    import numpy as np
    from PyQt4 import QtCore, QtGui
    from guiqwt.plot import CurveWidget,PlotManager
    from guiqwt.plot import CurveDialog
    from guiqwt.builder import make
    from guiqwt.signals import SIG_CLICK_EVENT
    from guiqwt.events import ClickHandler

    from guidata.configtools import get_icon

    import sys

    from random import random

    from PyQt4 import QtGui, QtCore

    from PyQt4 import Qwt5

    from guiqwt.plot import CurvePlot
    from guiqwt.curve import CurveItem
    from guiqwt.builder import make
    from guiqwt.styles import CurveParam

    from guiqwt.plot import CurveDialog

    from guiqwt.styles import COLORS

    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(object):
    def setupUi(self, MainWindow):
    MainWindow.setObjectName(_fromUtf8("MainWindow"))
    MainWindow.resize(817, 882)
    MainWindow.setMouseTracking(True)
    self.centralwidget = QtGui.QWidget(MainWindow)
    self.centralwidget.setObjectName(_fromUtf8("centralwidget"))
    self.curvewidget = CurveWidget(self.centralwidget)
    self.curvewidget.setGeometry(QtCore.QRect(80, 470, 400, 300))
    self.curvewidget.setMouseTracking(True)
    self.curvewidget.setOrientation(QtCore.Qt.Horizontal)
    self.curvewidget.setObjectName(_fromUtf8("curvewidget"))

        range = make.range(30, 100)
        self.curvewidget.plot.add_item(range)     
        
        
        
        self.curvewidget_2 = CurveWidget(self.centralwidget)
        self.curvewidget_2.setEnabled(True)
        self.curvewidget_2.setGeometry(QtCore.QRect(80, 130, 401, 300))
        self.curvewidget_2.setMouseTracking(True)
        self.curvewidget_2.setAcceptDrops(False)
        self.curvewidget_2.setOrientation(QtCore.Qt.Horizontal)
        self.curvewidget_2.setObjectName(_fromUtf8("curvewidget_2"))
        self.pushButton = QtGui.QPushButton(self.centralwidget)
        self.pushButton.setGeometry(QtCore.QRect(130, 40, 351, 27))
        self.pushButton.setObjectName(_fromUtf8("pushButton"))
        self.frame = QtGui.QFrame(self.centralwidget)
        self.frame.setGeometry(QtCore.QRect(530, 130, 251, 281))
        self.frame.setFrameShape(QtGui.QFrame.StyledPanel)
        self.frame.setFrameShadow(QtGui.QFrame.Raised)
        self.frame.setObjectName(_fromUtf8("frame"))
        
        MainWindow.connect(self.pushButton, QtCore.SIGNAL('clicked()'), self.showDialog)         
        
        
        self.label = QtGui.QLabel(self.frame)
        self.label.setGeometry(QtCore.QRect(20, 30, 71, 17))
        self.label.setObjectName(_fromUtf8("label"))
        MainWindow.setCentralWidget(self.centralwidget)
        self.menubar = QtGui.QMenuBar(MainWindow)
        self.menubar.setGeometry(QtCore.QRect(0, 0, 817, 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)
    
    def retranslateUi(self, MainWindow):
        MainWindow.setWindowTitle(_translate("MainWindow", "MainWindow", None))
        self.pushButton.setText(_translate("MainWindow", "PushButton", None))
        self.label.setText(_translate("MainWindow", "portata Q", None))
        
    #------------------------------------------------------------------------
              #azione apertura file
    #------------------------------------------------------------------------              
    def showDialog(self):
        fname = QtGui.QFileDialog.getOpenFileName(MainWindow, 'Open a data file', '.', 'txt files (*.txt);;All Files (*.*)')
        f = open(fname, 'r')
        with f:
            data = np.genfromtxt(f, skiprows=1)
    

    self.textEdit.setText(data)

            A=-0.198058
            B=-1.992186
            C=231.17628
            D=86.39123
            alfa=0.962144
            n=0.965078
            m=1.116
            self.tdata = data[:,0]
            odata = data[:,1]
            pdata = data[:,2]
            #correzione in temperatura da norma UNI EN 27888
    

    condc = ((1-alfa+alfa*(A+np.exp(B+C/(D+pdata)))**n)modata)

    self.cdata = condc*TDS

            self.curve_item = make.curve([], [], color='b')
            self.curvewidget_2.plot.add_item(self.curve_item)
            self.curve_item.set_data(self.tdata, odata)
            self.curve_item.plot().replot()
            
            win=CurveDialog(edit=False, toolbar=True)
            self.curvewidget.plot=win.get_plot()                        
            self.curve_item.plot().replot()   
    

    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_())

    @


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.