Bonjour a tous,
J'espère que vous allez bien. J'ai coder un graphique en python avec PyQtGraph. Ce graphique marche très bien il a même un curseur qui affiche sa position en x et y. J'ai ensuite codé une interface graphique sous Qt designer. Le programme fonctionne ma fenêtre s'ouvre le graphique s'affiche mais le curseur ne s'affiche pus. Je suis assez débutant dans ce langage merci pour votre aide.
Cordialement.
Je vous transmets ci-dessous mon code

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
from PyQt5 import QtWidgets, uic
from pyqtgraph import PlotWidget, plot
import pyqtgraph as pg
import sys  # We need sys so that we can pass argv to QApplication
import os
import pyqtgraph as pg
from collections import deque
from pyqtgraph.Qt import QtGui
import numpy as np
from PyQt5.QtWidgets import  QListWidget, QLabel,  QPushButton
from PyQt5.QtWidgets import QListWidgetItem
 
class MainWindow(QtWidgets.QMainWindow):
 
    def __init__(self, *args, **kwargs):
        super(MainWindow, self).__init__(*args, **kwargs)
 
        #Load the UI Page
 
        uic.loadUi('graph6.ui', self)
 
        self.dat = deque()
        self.maxLen = 50#max number of data points to show on graph
        self.app = QtGui.QApplication([])
        self.win = pg.GraphicsWindow()
        self.win.setWindowTitle('graph1')
 
        self.label = pg.LabelItem(justify='right')
        self.win.addItem(self.label)
 
        self.p1 = self.win.addPlot(row=1, col=0)
        self.win.nextRow()
 
        self.region = pg.LinearRegionItem()
        self.region.setZValue(10)
        self.p1.setAutoVisible(y=True)
        #plt.axis([-1,1,-3,3])
        self.x=np.linspace(0,23,15000)
        self.data1 = np.sqrt(self.x)
        self.fen.showGrid(x=True, y=True)
        self.fen.plot(self.data1, pen="y")
        self.p1.plot(self.data1, pen="y")
        self.fen.resize(900,500)
        self.fen.move(200,60)
 
        self.MyUI()
        self.listefichier()
 
 
 
 
        def updateRegion(window, viewRange):
            rgn = viewRange[0]
            self.region.setRegion(rgn)
 
        self.p1.sigRangeChanged.connect(updateRegion)
        self.region.setRegion([1000, 2000])
 
 
        vLine = pg.InfiniteLine(angle=90, movable=False)
        hLine = pg.InfiniteLine(angle=0, movable=False)
        self.p1.addItem(vLine, ignoreBounds=True)
        self.p1.addItem(hLine, ignoreBounds=True)
 
        vb = self.p1.vb
 
 
 
        def mouseMoved(evt):
            pos = evt[0]  ## using signal proxy turns original arguments into a tuple
            if self.p1.sceneBoundingRect().contains(pos):
               mousePoint = vb.mapSceneToView(pos)
               index = int(mousePoint.x())
               if index > 0 and index < len(self.data1):
                  self.label.setText("<span style='font-size: 12pt'><span style='color: yellow'>x=%0.1f,   <span style='color: yellow'>y1=%0.1f</span>" % (mousePoint.x(), self.data1[index]))
               vLine.setPos(mousePoint.x())
               hLine.setPos(mousePoint.y())
 
 
 
        proxy = pg.SignalProxy(self.p1.scene().sigMouseMoved, rateLimit=60, slot=mouseMoved)
 
        #QtGui.QApplication.instance().exec_() 
 
 
 
    """    
      gestion de la liste 
      
    """   
 
    def listefichier(self):
 
        nb_fichier=10
        #self.list_w.setGeometry(500, 740, 200, 60)
 
        for a in range(nb_fichier):
            itema = QListWidgetItem("fichier"+str(a+1))
            self.list_w.addItem(itema)
 
 
 
 
 
 
 
    """
     gestion des boutons
    """
 
    def MyUI(self):
 
        self.pushButton.clicked.connect(self.appui_bouton1)
 
 
        #self.pushButton_2 = QPushButton("supprimer", self)
        self.pushButton_2.clicked.connect(self.appui_bouton2)
        #
 
        # button3 = QPushButton("suivant", self)
        self.pushButton_3.clicked.connect(self.appui_bouton3)
 
 
 
    def appui_bouton1(self):
        print("le fichier a été sauvergarder")
 
 
    def appui_bouton2(self):
        print("le fichier a été supprimer")
       #os.remove("graph2.png")
 
 
    def appui_bouton3(self):
        print("suivant")
 
 
 
 
 
 
 
""" 
appel dans le main         
"""          
 
def main():
    app = QtWidgets.QApplication(sys.argv)
    main = MainWindow()
    main.show()
    sys.exit(app.exec_())
 
if __name__ == '__main__':      
    main()