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

Code before:
                        locked=True,
                    )
                self.obj.HoleWire = val

    def getIcon(self, obj):

        if hasattr(obj.ViewObject, "Proxy"):
            if hasattr(obj.ViewObject.Proxy, "getIcon"):
                return QtGui.QIcon(obj.ViewObject.Proxy.getIcon())
        elif obj.isDerivedFrom("Sketcher::SketchObject"):
            return QtGui.QIcon(":/icons/Sketcher_Sketch.svg")
        elif hasattr(obj.ViewObject, "Icon"):
            return QtGui.QIcon(obj.ViewObject.Icon)
        return QtGui.QIcon(":/icons/Part_3D_object.svg")

    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))

Review comment (suggestion):
```suggestion
            self.widthWidget.setProperty("value", self.obj.Width)
```

Code after:
                        locked=True,
                    )
                self.obj.HoleWire = val

    def getIcon(self, obj):

        if hasattr(obj.ViewObject, "Proxy"):
            if hasattr(obj.ViewObject.Proxy, "getIcon"):
                return QtGui.QIcon(obj.ViewObject.Proxy.getIcon())
        elif obj.isDerivedFrom("Sketcher::SketchObject"):
            return QtGui.QIcon(":/icons/Sketcher_Sketch.svg")
        elif hasattr(obj.ViewObject, "Icon"):
            return QtGui.QIcon(obj.ViewObject.Icon)
        return QtGui.QIcon(":/icons/Part_3D_object.svg")

    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