Ejemplo n.º 1
0
 def create_text_edit(self, value, min=0, max=60):
     """
     S'occupe de créer un champs éditable
     """
     # On crée le champs éditable
     text_edit = TextEdit()
     text_edit.setText(str(value))
     text_edit.setAlignment(Qt.AlignCenter | Qt.AlignVCenter)
     text_edit.setStyleSheet(line_edit_stylesheet)
     text_edit.setAttribute(Qt.WA_MacShowFocusRect, 0)
     text_edit.setFixedSize(20, 20)
     text_edit.setValidator(QIntValidator(min, max))
     text_edit.returnPressed.connect(lambda: self.editable_item_change(
         text_edit.text(), text_edit, clear_focus=True))
     text_edit.textChanged.connect(
         lambda: self.editable_item_change(text_edit.text(), text_edit))
     self.array_text_edit.append(text_edit)
     return text_edit
Ejemplo n.º 2
0
class BlocParamProd(MondonWidget):
    def __init__(self, plan_prod, parent=None):
        super(BlocParamProd, self).__init__(parent=parent)
        # self.setFixedHeight(50)
        self.setFocusPolicy(Qt.ClickFocus)
        self.background_color = color_bleu_gris
        self.plan_prod = plan_prod
        self.hbox_master = QHBoxLayout()
        self.text_edit_tours = TextEdit(number_only=True, number_limit=1000)
        self.text_edit_tours.setText(str(self.plan_prod.tours))
        self.text_edit_tours.setStyleSheet(line_edit_green_stylesheet)
        self.text_edit_tours.textChanged.connect(self.handle_tours_changed)
        self.label_end = QLabel("Fin production : {}".format(timestamp_to_hour_little(self.plan_prod.end)))
        import time
        text_time_reglage = time.strftime("%H:%M:%S", time.gmtime(self.plan_prod.data_reglages.time_reglage * 60))
        self.label_time_reglage = QLabel("Réglage : {}".format(text_time_reglage))
        value_time_prod = self.plan_prod.end - self.plan_prod.start - self.plan_prod.data_reglages.time_reglage*3600
        text_prod = time.strftime("%H:%M:%S", time.gmtime(value_time_prod / 60))
        self.label_time_prod = QLabel("Production : {}".format(text_prod))
        self.update_label()
        self.init_ui()

    def init_ui(self):
        label_nb_tours = QLabel("Nombre de tours : ")
        label_nb_tours.setStyleSheet(white_12_label_stylesheet)
        self.hbox_master.addWidget(label_nb_tours)
        self.text_edit_tours.setFixedWidth(40)
        self.text_edit_tours.setAlignment(Qt.AlignCenter)
        self.hbox_master.addWidget(self.text_edit_tours)
        self.hbox_master.addStretch(1)
        label_prod = QLabel("PRODUCTION")
        label_prod.setStyleSheet(white_16_bold_label_stylesheet)
        self.hbox_master.addWidget(label_prod)
        self.hbox_master.addStretch(1)
        vbox = QVBoxLayout()
        label_debut = QLabel("Début production : {}".format(timestamp_to_hour_little(self.plan_prod.start)))
        label_debut.setStyleSheet(white_12_label_stylesheet)
        label_debut.setAlignment(Qt.AlignRight)
        self.label_end.setStyleSheet(white_12_label_stylesheet)
        self.label_end.setAlignment(Qt.AlignRight)
        self.label_time_reglage.setStyleSheet(white_12_label_stylesheet)
        self.label_time_reglage.setAlignment(Qt.AlignRight)
        self.label_time_prod.setStyleSheet(white_12_label_stylesheet)
        self.label_time_prod.setAlignment(Qt.AlignRight)
        vbox.addWidget(label_debut)
        vbox.addWidget(self.label_time_reglage)
        vbox.addWidget(self.label_time_prod)
        vbox.addWidget(self.label_end)
        self.hbox_master.addLayout(vbox)
        self.setLayout(self.hbox_master)

    def update_label(self):
        self.plan_prod.get_end()
        if self.text_edit_tours.text() != self.plan_prod.tours:
            self.text_edit_tours.setText(str(self.plan_prod.tours))
        self.label_end.setText("Fin production : {}".format(timestamp_to_hour_little(self.plan_prod.end)))
        import time
        text_time_reglage = time.strftime("%H:%M:%S", time.gmtime(self.plan_prod.data_reglages.time_reglage*60))
        self.label_time_reglage.setText("Réglage : {}".format(text_time_reglage))
        value_time_prod = self.plan_prod.end - self.plan_prod.start - self.plan_prod.data_reglages.time_reglage*60
        if value_time_prod < 0:
            value_time_prod = 0
        text_prod = time.strftime("%H:%M:%S", time.gmtime(value_time_prod))
        self.label_time_prod.setText("Production : {}".format(text_prod))

    def handle_tours_changed(self, text_edit_value):
        if text_edit_value == "":
            self.plan_prod.set_tours(0)
            self.text_edit_tours.setStyleSheet(line_edit_red_stylesheet)
        else:
            self.text_edit_tours.setStyleSheet(line_edit_green_stylesheet)
            self.plan_prod.set_tours(int(text_edit_value))
Ejemplo n.º 3
0
class SelectorFilter(MondonWidget):
    def __init__(self, parent):
        super(SelectorFilter, self).__init__(parent=parent)
        self.setObjectName("SelectorFilter")
        if filter_store.data_type == "perfo":
            self.setFixedHeight(0)
            self.setMinimumWidth(1150)
        self.set_background_color(color_bleu_gris)
        self.search_code = TextEdit(upper_mode=True)
        self.init_widget()

    def init_widget(self):
        hbox = QHBoxLayout()
        hbox.setContentsMargins(10, 10, 30, 10)
        hbox.setSpacing(10)
        if filter_store.data_type == "bobine":
            hbox.addLayout(self.get_search_bar())
        if filter_store.data_type == "bobine":
            for index in range(len(filter_store.list_filter_bobine_fille)):
                hbox.addWidget(
                    SelectorCollumFilter(
                        parent=self,
                        title=filter_store.title_filter_bobine_fille[index],
                        name_filter=filter_store.
                        list_filter_bobine_fille[index],
                        sort_mode=filter_store.sort_mode_bobine_fille[index],
                        filter_mode=filter_store.
                        filter_mode_bobine_fille[index]))
        if filter_store.data_type == "poly":
            for index in range(len(filter_store.list_filter_poly)):
                hbox.addWidget(
                    SelectorCollumFilter(
                        parent=self,
                        title=filter_store.title_filter_poly[index],
                        name_filter=filter_store.list_filter_poly[index],
                        sort_mode=filter_store.sort_mode_poly[index],
                        filter_mode=filter_store.filter_mode_poly[index]))
        if filter_store.data_type == "refente":
            for index in range(len(filter_store.list_filter_refente)):
                hbox.addWidget(
                    SelectorCollumFilter(
                        parent=self,
                        title=filter_store.title_filter_refente[index],
                        name_filter=filter_store.list_filter_refente[index],
                        sort_mode=filter_store.sort_mode_refente[index],
                        filter_mode=filter_store.filter_mode_refente[index]))
        if filter_store.data_type == "papier":
            for index in range(len(filter_store.list_filter_papier)):
                hbox.addWidget(
                    SelectorCollumFilter(
                        parent=self,
                        title=filter_store.title_filter_papier[index],
                        name_filter=filter_store.list_filter_papier[index],
                        sort_mode=filter_store.sort_mode_papier[index],
                        filter_mode=filter_store.filter_mode_papier[index]))
        self.setLayout(hbox)

    @staticmethod
    def get_label(text):
        label = QLabel(text)
        label.setStyleSheet(black_14_label_stylesheet)
        return label

    def get_search_bar(self):
        self.search_code.setStyleSheet(line_edit_stylesheet)
        self.search_code.textChanged.connect(self.handle_search_code_changed)
        self.search_code.setFixedWidth(250 - 21)
        icone_search = Image(parent=self,
                             img="commun/assets/images/icon_search.png",
                             size=21,
                             background_color=color_blanc)
        layout_search_bar = QHBoxLayout()
        layout_search_bar.setSpacing(0)
        layout_search_bar.setContentsMargins(0, 0, 0, 0)
        layout_search_bar.addWidget(self.search_code)
        layout_search_bar.addWidget(icone_search)
        return layout_search_bar

    def handle_search_code_changed(self):
        filter_store.set_search_code(search_code=self.search_code.text())