Example #1
0
    def _show_templates(self):
        """
        Update templates on shoeEvent.
        """

        cols = 3
        templates = template_module.Template.get_all()

        for j, item in enumerate(self.visible_items):
            if not templates[item.id]:
                l = QLabel("Нет шаблонов для данного объекта\nУправлять шаблонами можно на вкладке настроек")
                l.setAlignment(Qt.AlignCenter)
                self.templates_layout.addWidget(l)
                continue
            layouts = [QVBoxLayout() for _ in range(cols)]
            for i, each in enumerate(templates[item.id]):
                b = QRadioButton(each.name)
                b.setChecked(item.template == each)
                b.clicked.connect(functools.partial(self._template_clicked, j, each))
                b.mouseDoubleClickEvent = functools.partial(self.open_template_edit_widget, j, each)
                layouts[i % cols].addWidget(b)

            wrapper = QHBoxLayout()
            for each in layouts:
                each.addStretch()
                wrapper.addLayout(each, stretch=int(100 / cols))
            self.templates_layout.addWidget(utils.get_scrollable(wrapper))
    def _show_templates(self):
        """
        Update templates on shoeEvent.
        """

        cols = 3
        templates = template_module.Template.get_all()
        check_templates = []

        for j, item in enumerate(self.visible_items):
            if not templates[item.id]:
                # l = QLabel('Нет шаблонов для данного объекта\nУправлять шаблонами можно на вкладке настроек')
                l = QLabel(
                    'Não há modelos para este objeto\nOs modelos de gerenciamento podem estar na guia de configurações'
                )
                l.setAlignment(Qt.AlignCenter)
                self.templates_layout.addWidget(l)
                continue
            layouts = [QVBoxLayout() for _ in range(cols)]
            for i, each in enumerate(templates[item.id]):
                b = QRadioButton(each.name)
                b.setChecked(item.template == each)
                b.clicked.connect(
                    functools.partial(self._template_clicked, j, each))
                if len(templates[item.id]) == 1:
                    check_templates.append((b, j, each))
                b.mouseDoubleClickEvent = functools.partial(
                    self.open_template_edit_widget, j, each)
                layouts[i % cols].addWidget(b)

            wrapper = QHBoxLayout()
            for each in layouts:
                each.addStretch()
                wrapper.addLayout(each, stretch=int(100 / cols))
            self.templates_layout.addWidget(utils.get_scrollable(wrapper))
        for i, each in enumerate(check_templates):
            b, j, template = each
            self._template_clicked(j, template, i == 0)
            b.setChecked(True)
Example #3
0
 def _get_radio_btn(self, item):
     fullname = "{} {} {}".format(item.surname, item.name, item.patronymic)
     b = QRadioButton(fullname)
     b.mouseDoubleClickEvent = functools.partial(self._button_clicked, item)
     return b
 def _get_radio_btn(self, item):
     fullname = '{} {} {}'.format(item.surname, item.name, item.patronymic)
     b = QRadioButton(fullname)
     b.mouseDoubleClickEvent = (functools.partial(self._button_clicked, item))
     return b