Repository: FreeCAD/FreeCAD
File: src/Mod/BIM/ArchWindow.py (Python)

Code before:

    def update(self):
        "fills the tree widgets"

        self.tree.clear()
        self.wiretree.clear()
        self.comptree.clear()
        if self.obj:

            FreeCADGui.ExpressionBinding(self.widthWidget).bind(self.obj, "Width")
            self.widthWidget.setProperty("unit", self.obj.Width.getUserPreferred()[2])
            self.widthWidget.setProperty("rawValue", self.obj.Width.Value)

            FreeCADGui.ExpressionBinding(self.heightWidget).bind(self.obj, "Height")
            self.heightWidget.setProperty("unit", self.obj.Height.getUserPreferred()[2])
            self.heightWidget.setProperty("rawValue", self.obj.Height.Value)

            FreeCADGui.ExpressionBinding(self.openingWidget).bind(self.obj, "Opening")
            # Opening is a scalar property, as opposed to a quantity property. It appears to have
            # no "preferred unit" metadata. We cannot set the suffix manually either, but at least
            # we can set some safe limits. These limits are hardcoded: the Property Editor clamps
            # the property to these, so it must be reading them from metadata, but they might not
            # be queryable via Python.
            self.openingWidget.setProperty("minimum", 0.0)
            self.openingWidget.setProperty("maximum", 100.0)
            self.openingWidget.setProperty("rawValue", self.obj.Opening)

            if self.obj.Base:
                item = QtGui.QTreeWidgetItem(self.tree)
                item.setText(0, self.obj.Base.Name)
                item.setIcon(0, self.getIcon(self.obj.Base))
                if hasattr(self.obj.Base, "Shape"):
                    i = 0
                    for w in self.obj.Base.Shape.Wires:
                        if w.isClosed():
                            item = QtGui.QTreeWidgetItem(self.wiretree)
                            item.setText(0, "Wire" + str(i))
                            item.setIcon(0, QtGui.QIcon(":/icons/Draft_Draft.svg"))
                        i += 1
                if self.obj.WindowParts:
                    for p in range(0, len(self.obj.WindowParts), 5):
                        item = QtGui.QTreeWidgetItem(self.comptree)
                        item.setText(0, self.obj.WindowParts[p])
                        item.setIcon(0, QtGui.QIcon(":/icons/Part_3D_object.svg"))
                if hasattr(self.obj, "HoleWire"):
                    self.holeNumber.setText(str(self.obj.HoleWire))
                else:
                    self.holeNumber.setText("0")

            self.retranslateUi(self.baseform)
            self.basepanel.obj = self.obj

Review comment (suggestion):
```suggestion
            self.openingWidget.setProperty("minimum", 0)
            self.openingWidget.setProperty("maximum", 100)
            # https://forum.freecad.org/viewtopic.php?p=781883 (wmayer):
            quant = FreeCAD.Units.Quantity()
            quant.Value = self.obj.Opening
            quant.Format = {"Precision": 0}
            self.openingWidget.setProperty("value", quant)
```
This is not a perfect solution. If you use the spinbox arrows, decimals will still be appear. But if the spinbox loses focus, and after pressing enter, they disappear again.

Code after:

    def update(self):
        "fills the tree widgets"

        self.tree.clear()
        self.wiretree.clear()
        self.comptree.clear()
        if self.obj:

            FreeCADGui.ExpressionBinding(self.widthWidget).bind(self.obj, "Width")
            self.widthWidget.setProperty("value", self.obj.Width)

            FreeCADGui.ExpressionBinding(self.heightWidget).bind(self.obj, "Height")
            self.heightWidget.setProperty("value", self.obj.Height)

            FreeCADGui.ExpressionBinding(self.openingWidget).bind(self.obj, "Opening")
            # Opening is a scalar property, as opposed to a quantity property. It appears to have
            # no "preferred unit" metadata. We cannot set the suffix manually either, but at least
            # we can set some safe limits. These limits are hardcoded: the Property Editor clamps
            # the property to these, so it must be reading them from metadata, but they might not
            # be queryable via Python.
            self.openingWidget.setProperty("minimum", 0)
            self.openingWidget.setProperty("maximum", 100)
            self.openingWidget.setProperty("value", self.obj.Opening)

            if self.obj.Base:
                item = QtGui.QTreeWidgetItem(self.tree)
                item.setText(0, self.obj.Base.Name)
                item.setIcon(0, self.getIcon(self.obj.Base))
                if hasattr(self.obj.Base, "Shape"):
                    i = 0
                    for w in self.obj.Base.Shape.Wires:
                        if w.isClosed():
                            item = QtGui.QTreeWidgetItem(self.wiretree)
                            item.setText(0, "Wire" + str(i))
                            item.setIcon(0, QtGui.QIcon(":/icons/Draft_Draft.svg"))
                        i += 1
                if self.obj.WindowParts:
                    for p in range(0, len(self.obj.WindowParts), 5):
                        item = QtGui.QTreeWidgetItem(self.comptree)
                        item.setText(0, self.obj.WindowParts[p])
                        item.setIcon(0, QtGui.QIcon(":/icons/Part_3D_object.svg"))
                if hasattr(self.obj, "HoleWire"):
                    self.holeNumber.setText(str(self.obj.HoleWire))
                else:
                    self.holeNumber.setText("0")

            self.retranslateUi(self.baseform)
            self.basepanel.obj = self.obj
            self.basepanel.update()
            for wp in self.obj.WindowParts: