Для использования двоичной системы необходимо установить для свойства displayIntegerBase
значение 2:
import sys
from PyQt5 import QtWidgets
if __name__ == "__main__":
app = QtWidgets.QApplication(sys.argv)
w = QtWidgets.QSpinBox()
w.setValue(0b10010)
w.setDisplayIntegerBase(2)
w.show()
sys.exit(app.exec_())
Обновление:
Если Вы хотите установить минимальную ширину (в данном случае 5), тогда метод textFromValue()
должен быть переопределен:
import sys
from PyQt5 import QtWidgets
class SpinBox(QtWidgets.QSpinBox):
def textFromValue(self, value):
return "{:05b}".format(value)
if __name__ == "__main__":
app = QtWidgets.QApplication(sys.argv)
w = SpinBox()
w.setMaximum(0b11111)
w.setValue(0b00000)
w.setDisplayIntegerBase(2)
w.show()
sys.exit(app.exec_())
