Nantes Université

Skip to content
Extraits de code Groupes Projets
Valider 5a823147 rédigé par Mikaël BRIDAY's avatar Mikaël BRIDAY
Parcourir les fichiers

debug event list refactoring

parent a03a483d
Branches
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
......@@ -11,7 +11,7 @@
</rect>
</property>
<property name="windowTitle">
<string>mainwindow</string>
<string>INFEM - TP Bac</string>
</property>
<widget class="QWidget" name="centralwidget">
<layout class="QHBoxLayout" name="horizontalLayout_2">
......
......@@ -34,6 +34,7 @@ class MainWindow(QMainWindow, Ui_mainwindow):
#event list view
self.debugEventModel = debugEventModel()
self.eventListView.setModel(self.debugEventModel)
self.debugEventModel.signalScroll.connect(self.eventListView.scrollToBottom)
#threads
appli = mainThread(self.labTerm,self.drawingWidget,self.debugEventModel)
appli.start()
......
......@@ -35,7 +35,8 @@ class ferry(threading.Thread):
])
def check(self,cond,info,msgIfOk=True):
""" basic verification (assert(cond)). If the condition is not ok, report the pb and ends the thread.
""" basic verification (assert(cond)).
If the condition is not ok, report the pb and ends the thread.
info is an extra information (char string)
"""
if not cond:
......@@ -97,7 +98,8 @@ class car(threading.Thread):
])
def check(self,cond,info,msgIfOk=True):
""" basic verification (assert(cond)). If the condition is not ok, report the pb and ends the thread.
""" basic verification (assert(cond)).
If the condition is not ok, report the pb and ends the thread.
info is an extra information (char string)
"""
if not cond:
......
#! /usr/bin/env python3
# -*- coding: UTF-8 -*-
import threading
from PyQt5.QtWidgets import *
from PyQt5.QtCore import *
from PyQt5.QtGui import *
......@@ -8,9 +9,13 @@ from PyQt5.QtGui import *
pb = QImage('bac/cross.png').scaled(16,16,Qt.KeepAspectRatio)
class debugEventModel(QAbstractListModel):
signalAddEv = pyqtSignal(bool,str)
signalScroll = pyqtSignal()
def __init__(self,*args,debugEvent=None,**kwargs):
super(debugEventModel,self).__init__(*args,**kwargs)
self.debugEvent = debugEvent or []
self.signalAddEv.connect(self.addEvGUIThread)
def data(self,index,role): #index: row,column
status, text = self.debugEvent[index.row()]
......@@ -26,8 +31,14 @@ class debugEventModel(QAbstractListModel):
return len(self.debugEvent)
def addEv(self,error,text):
self.signalAddEv.emit(error,text)
@pyqtSlot(bool,str)
def addEvGUIThread(self,error,text):
assert threading.current_thread() is threading.main_thread()
index = QModelIndex()
n = self.rowCount(index)
self.beginInsertRows(index,0,1)
self.debugEvent.insert(0,(error,text))
self.beginInsertRows(index,n,n)
self.debugEvent.append((error,text))
self.endInsertRows()
self.signalScroll.emit()
......@@ -2,9 +2,10 @@
# Form implementation generated from reading ui file 'bac.ui'
#
# Created by: PyQt5 UI code generator 5.14.0
# Created by: PyQt5 UI code generator 5.15.4
#
# WARNING! All changes made in this file will be lost!
# WARNING: Any manual changes made to this file will be lost when pyuic5 is
# run again. Do not edit this file unless you know what you are doing.
from PyQt5 import QtCore, QtGui, QtWidgets
......@@ -85,7 +86,7 @@ class Ui_mainwindow(object):
def retranslateUi(self, mainwindow):
_translate = QtCore.QCoreApplication.translate
mainwindow.setWindowTitle(_translate("mainwindow", "mainwindow"))
mainwindow.setWindowTitle(_translate("mainwindow", "INFEM - TP Bac"))
self.pbTerm.setText(_translate("mainwindow", "demander la terminaison propre"))
self.label.setText(_translate("mainwindow", "État des sémaphores"))
from QDrawing import QDrawing
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Veuillez vous inscrire ou vous pour commenter