Projekt

Obecné

Profil

« Předchozí | Další » 

Revize e89316f6

Přidáno uživatelem Jan Rach před téměř 4 roky(ů)

Re: #8968 - second function delete feature implemented.

Zobrazit rozdíly:

aswi2021vochomurka/view/main_view.py
170 170
            self.dataDict[message.topic] = [message.value]
171 171

  
172 172
            figure = plt.figure(figsize=[500, 500])
173

  
173 174
            canvas = FigureCanvas(figure)
174 175
            self.layout = QHBoxLayout()
175 176

  
176 177
            plt.plot(self.dataDict[message.topic])
178

  
177 179
            figure.suptitle(message.topic)
178 180

  
179 181
            self.canvasDict[message.topic] = canvas
......
187 189
            button.clicked.connect(lambda: self.getFile(message.topic))
188 190
            button.setFixedSize(QSize(40, 40))
189 191

  
192
            button2 = QPushButton('Del')
193
            button2.clicked.connect(lambda: self.deleteSecond(message.topic))
194
            button2.setFixedSize(QSize(40, 40))
195

  
190 196
            self.layout.addWidget(canvas)
191
            self.layout.addWidget(button)
192
            self.layout.setAlignment(button, QtCore.Qt.AlignTop)
197

  
198
            boxLayout = QVBoxLayout()
199
            boxLayout.addWidget(button)
200
            boxLayout.addWidget(button2)
201
            boxLayout.setAlignment(button, QtCore.Qt.AlignTop)
202
            boxLayout.setAlignment(button2, QtCore.Qt.AlignTop)
203
            self.layout.addLayout(boxLayout)
193 204
            widget.setMinimumSize(QSize(500, 500))
194 205

  
195 206
            self.grid.addWidget(widget, int(self.chartsNum / 2), self.chartsNum % 2)
......
224 235
        except:
225 236
            logging.error("Error while loading and displaying data file")
226 237

  
238
    def deleteSecond(self, topic: str):
239
        if topic in self.dataDict2:
240
            del self.dataDict2[topic]
241

  
242
            figure = self.figureDict[topic]
243
            figure.clear()
244

  
245
            figure = plt.figure(figure.number)
246
            figure.suptitle(topic)
247
            plt.plot(self.dataDict[topic])
248

  
249
            self.canvasDict[topic].draw()
250

  
227 251
    def deletePlot(self, topic: str):
228 252
        """
229 253
        Deletes plot
......
237 261
        del self.canvasDict[topic]
238 262
        del self.figureDict[topic]
239 263
        del self.dataDict[topic]
264
        if topic in self.dataDict2:
265
            del self.dataDict2[topic]
240 266

  
241 267
        self.reorganizePlots()
242 268

  
......
274 300
        """
275 301
        Reconnect
276 302
        """
303
        for widget in self.widgetDict.values():
304
            widget.setParent(None)
305

  
306
        self.widgetDict.clear()
307
        self.widgetList.clear()
308
        self.canvasDict.clear()
309
        self.figureDict.clear()
310
        self.dataDict.clear()
311
        self.dataDict2.clear()
312

  
277 313
        self.disconnect()
278 314
        self.worker.params = self.getConfigParams()
279 315
        self.workerThread.start()

Také k dispozici: Unified diff