Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions traitsui/qt4/editor.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
16 changes: 9 additions & 7 deletions traitsui/qt4/ui_panel.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
----------
Expand All @@ -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)
Expand All @@ -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

Expand Down
8 changes: 5 additions & 3 deletions traitsui/wx/editor.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
7 changes: 5 additions & 2 deletions traitsui/wx/ui_panel.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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

Expand Down