Exemple #1
0
    def setSectionCount(self, count):
        """
        Sets the number of editors that the serial widget should have.
        
        :param      count | <int>
        """
        # cap the sections at 10
        count = max(1, min(count, 10))

        # create additional editors
        while self.layout().count() < count:
            editor = XLineEdit(self)
            editor.setFont(self.font())
            editor.setReadOnly(self.isReadOnly())
            editor.setHint(self.hint())
            editor.setAlignment(QtCore.Qt.AlignCenter)
            editor.installEventFilter(self)
            editor.setSizePolicy(QtGui.QSizePolicy.Expanding,
                                 QtGui.QSizePolicy.Expanding)
            editor.setMaxLength(self.sectionLength())
            editor.returnPressed.connect(self.returnPressed)
            self.layout().addWidget(editor)

        # remove unnecessary editors
        while count < self.layout().count():
            widget = self.layout().itemAt(0).widget()
            widget.close()
            widget.setParent(None)
            widget.deleteLater()
Exemple #2
0
 def setSectionCount(self, count):
     """
     Sets the number of editors that the serial widget should have.
     
     :param      count | <int>
     """
     # cap the sections at 10
     count = max(1, min(count, 10))
     
     # create additional editors
     while self.layout().count() < count:
         editor = XLineEdit(self)
         editor.setFont(self.font())
         editor.setReadOnly(self.isReadOnly())
         editor.setHint(self.hint())
         editor.setAlignment(QtCore.Qt.AlignCenter)
         editor.installEventFilter(self)
         editor.setSizePolicy(QtGui.QSizePolicy.Expanding,
                              QtGui.QSizePolicy.Expanding)
         editor.setMaxLength(self.sectionLength())
         editor.returnPressed.connect(self.returnPressed)
         self.layout().addWidget(editor)
     
     # remove unnecessary editors
     while count < self.layout().count():
         widget = self.layout().itemAt(0).widget()
         widget.close()
         widget.setParent(None)
         widget.deleteLater()