PD: Enhance InvoluteGear's Task Panel with Tool Tips
In order to not maintain the same information in two places, the property docs are reused as tool tips for their input fields. And for user convenience, the same tool tip is assigned to the respective label as well.
This commit is contained in:
@@ -166,6 +166,7 @@ class _InvoluteGearTaskPanel:
|
||||
|
||||
self.form=FreeCADGui.PySideUic.loadUi(str(pathlib.Path(__file__).with_suffix(".ui")))
|
||||
self.form.setWindowIcon(QtGui.QIcon(":/icons/PartDesign_InternalExternalGear.svg"))
|
||||
self.assignToolTipsFromPropertyDocs()
|
||||
|
||||
def assignValue(property_name, fitView=False):
|
||||
"""Returns a function that takes a single value and assigns it to the given property"""
|
||||
@@ -198,6 +199,22 @@ class _InvoluteGearTaskPanel:
|
||||
self.obj.Proxy.execute(self.obj) # calculate once
|
||||
FreeCAD.Gui.SendMsgToActiveView("ViewFit")
|
||||
|
||||
def assignToolTipsFromPropertyDocs(self):
|
||||
def assign(property_name, *widgets):
|
||||
doc = self.obj.getDocumentationOfProperty(property_name)
|
||||
for w in widgets:
|
||||
w.setToolTip(doc)
|
||||
|
||||
# we assign the tool tip to both, the label and the input field, for user convenience
|
||||
assign("Modules", self.form.Quantity_Modules, self.form.label_Modules)
|
||||
assign("PressureAngle", self.form.Quantity_PressureAngle, self.form.label_PressureAngle)
|
||||
assign("NumberOfTeeth", self.form.spinBox_NumberOfTeeth, self.form.label_NumberOfTeeth)
|
||||
assign("HighPrecision", self.form.comboBox_HighPrecision, self.form.label_HighPrecision)
|
||||
assign("ExternalGear", self.form.comboBox_ExternalGear, self.form.label_ExternalGear)
|
||||
assign("AddendumCoefficient", self.form.doubleSpinBox_Addendum, self.form.label_Addendum)
|
||||
assign("DedendumCoefficient", self.form.doubleSpinBox_Dedendum, self.form.label_Dedendum)
|
||||
assign("RootFilletCoefficient", self.form.doubleSpinBox_RootFillet, self.form.label_RootFillet)
|
||||
|
||||
def transferTo(self):
|
||||
"Transfer from the dialog to the object"
|
||||
self.obj.NumberOfTeeth = self.form.spinBox_NumberOfTeeth.value()
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
</property>
|
||||
<layout class="QFormLayout" name="formLayout">
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="label_9">
|
||||
<widget class="QLabel" name="label_NumberOfTeeth">
|
||||
<property name="text">
|
||||
<string>Number of teeth:</string>
|
||||
</property>
|
||||
@@ -35,7 +35,7 @@
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="label_8">
|
||||
<widget class="QLabel" name="label_Modules">
|
||||
<property name="text">
|
||||
<string>Module:</string>
|
||||
</property>
|
||||
@@ -79,7 +79,7 @@
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QLabel" name="label_6">
|
||||
<widget class="QLabel" name="label_PressureAngle">
|
||||
<property name="text">
|
||||
<string>Pressure angle:</string>
|
||||
</property>
|
||||
@@ -120,7 +120,7 @@
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="0">
|
||||
<widget class="QLabel" name="label_7">
|
||||
<widget class="QLabel" name="label_HighPrecision">
|
||||
<property name="text">
|
||||
<string>High precision:</string>
|
||||
</property>
|
||||
@@ -147,7 +147,7 @@
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="0">
|
||||
<widget class="QLabel" name="label_10">
|
||||
<widget class="QLabel" name="label_ExternalGear">
|
||||
<property name="text">
|
||||
<string>External gear:</string>
|
||||
</property>
|
||||
@@ -174,7 +174,7 @@
|
||||
</widget>
|
||||
</item>
|
||||
<item row="5" column="0">
|
||||
<widget class="QLabel" name="label">
|
||||
<widget class="QLabel" name="label_Addendum">
|
||||
<property name="text">
|
||||
<string>Addendum Coefficient</string>
|
||||
</property>
|
||||
@@ -194,7 +194,7 @@
|
||||
</widget>
|
||||
</item>
|
||||
<item row="6" column="0">
|
||||
<widget class="QLabel" name="label_2">
|
||||
<widget class="QLabel" name="label_Dedendum">
|
||||
<property name="text">
|
||||
<string>Dedendum Coefficient</string>
|
||||
</property>
|
||||
@@ -214,7 +214,7 @@
|
||||
</widget>
|
||||
</item>
|
||||
<item row="7" column="0">
|
||||
<widget class="QLabel" name="label_3">
|
||||
<widget class="QLabel" name="label_RootFillet">
|
||||
<property name="text">
|
||||
<string>Root Fillet Coefficient</string>
|
||||
</property>
|
||||
|
||||
Reference in New Issue
Block a user