diff --git a/traitsui/qt4/editor.py b/traitsui/qt4/editor.py index 0857c4c21..333fed29c 100644 --- a/traitsui/qt4/editor.py +++ b/traitsui/qt4/editor.py @@ -106,11 +106,13 @@ def set_tooltip(self, control=None): """ desc = self.description if desc == '': - desc = self.object.base_trait(self.name).desc + desc = self.object.base_trait(self.name).tooltip if desc is None: - return False + desc = self.object.base_trait(self.name).desc + if desc is None: + return False - desc = 'Specifies ' + desc + desc = 'Specifies ' + desc if control is None: control = self.control diff --git a/traitsui/qt4/ui_panel.py b/traitsui/qt4/ui_panel.py index 7be91330a..d1babc38d 100644 --- a/traitsui/qt4/ui_panel.py +++ b/traitsui/qt4/ui_panel.py @@ -832,7 +832,9 @@ def _add_items(self, content, outer=None): # Otherwise, it must be a trait Item: object = eval(item.object_, globals(), ui.context) trait = object.base_trait(name) - desc = trait.desc or '' + desc = trait.tooltip + if desc is None: + desc = 'Specifies ' + trait.desc if trait.desc else '' # Get the editor factory associated with the Item: editor_factory = item.editor @@ -1098,9 +1100,10 @@ def _create_label(self, item, ui, desc, suffix=':'): we append a suffix (by default a colon ':') at the end of the label text. - We also set the help on the QLabel control (from item.help) and - the tooltip (it item.desc exists; we add "Specifies " at the start - of the item.desc string). + We also set the help on the QLabel control (from item.help) and the + tooltip (if the ``tooltip`` metadata on the edited trait exists, then + it will be used as-is; otherwise, if the ``desc`` metadata exists, the + string "Specifies " will be prepended to the start of ``desc``). Parameters ---------- @@ -1117,6 +1120,7 @@ def _create_label(self, item, ui, desc, suffix=':'): ------- label_control : QLabel The control for the label + """ label = item.get_label(ui) @@ -1139,10 +1143,8 @@ def _create_label(self, item, ui, desc, suffix=':'): #wx.EVT_LEFT_UP( control, show_help_popup ) label_control.help = item.get_help(ui) - # FIXME: do people rely on traitsui adding 'Specifies ' to the start - # of every tooltip? It's not flexible at all if desc != '': - label_control.setToolTip('Specifies ' + desc) + label_control.setToolTip(desc) return label_control diff --git a/traitsui/wx/editor.py b/traitsui/wx/editor.py index 9d66da97a..641b675bc 100644 --- a/traitsui/wx/editor.py +++ b/traitsui/wx/editor.py @@ -115,11 +115,13 @@ def set_tooltip(self, control=None): """ desc = self.description if desc == '': - desc = self.object.base_trait(self.name).desc + desc = self.object.base_trait(self.name).tooltip if desc is None: - return False + desc = self.object.base_trait(self.name).desc + if desc is None: + return False - desc = 'Specifies ' + desc + desc = 'Specifies ' + desc if control is None: control = self.control diff --git a/traitsui/wx/ui_panel.py b/traitsui/wx/ui_panel.py index fb9f2a6c9..f0387a6b3 100644 --- a/traitsui/wx/ui_panel.py +++ b/traitsui/wx/ui_panel.py @@ -885,7 +885,10 @@ def add_items(self, content, panel, sizer): # Otherwise, it must be a trait Item: object = eval(item.object_, globals(), ui.context) trait = object.base_trait(name) - desc = trait.desc or '' + desc = trait.tooltip + if desc is None: + desc = 'Specifies ' + trait.desc if trait.desc else '' + label = None # If we are displaying labels on the left, add the label to the @@ -1091,7 +1094,7 @@ def create_label(self, item, ui, desc, parent, sizer, suffix=':', pad_side, self.label_pad) if desc != '': - control.SetToolTipString('Specifies ' + desc) + control.SetToolTipString(desc) return control