File size: 996 Bytes
e6b3e35
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
from PyQt5.QtWidgets import QApplication, QMainWindow, QPushButton, QWidget, QLabel, QHBoxLayout, QVBoxLayout


class Relatorio(QWidget):

    #constantes
    class_name_str = "Class: {}"
    percent_str = "Percentage of class: {}%"

    def __init__(self):
        super().__init__()

        self.class_name_label = QLabel()
        self.percent_label = QLabel()


        central_layout = QVBoxLayout()
        central_layout.addWidget(self.class_name_label)
        central_layout.addWidget(self.percent_label)

        self.setLayout(central_layout)
        self.resize(self.width(), 100)

    def configure(self, name, percent):
        percent = round(float(percent)*100, 2)
        self.class_name_label.setText(self.class_name_str.format(name))
        self.percent_label.setText(self.percent_str.format(percent))
        self.class_name_label.show()
        self.percent_label.show()

    def hide_labels(self):
        self.class_name_label.hide()
        self.percent_label.hide()