Added tooltip description for stage 2 items
This commit is contained in:
@@ -13,9 +13,12 @@ import gui.utils.colorUtils as colorUtils
|
||||
import gui.utils.drawUtils as drawUtils
|
||||
import gui.utils.animUtils as animUtils
|
||||
import gui.utils.animEffects as animEffects
|
||||
import gui.utils.textFormatting as textFormatting
|
||||
|
||||
import gui.sfBrowserItem as SFItem
|
||||
|
||||
import service
|
||||
|
||||
FitRenamed, EVT_FIT_RENAMED = wx.lib.newevent.NewEvent()
|
||||
FitSelected, EVT_FIT_SELECTED = wx.lib.newevent.NewEvent()
|
||||
FitRemoved, EVT_FIT_REMOVED = wx.lib.newevent.NewEvent()
|
||||
@@ -1023,6 +1026,11 @@ class ShipItem(SFItem.SFBrowserItem):
|
||||
|
||||
self.Bind(wx.EVT_CONTEXT_MENU, self.OnShowPopup)
|
||||
|
||||
self.marketInstance = service.Market.getInstance()
|
||||
self.baseItem = self.marketInstance.getItem(self.shipID)
|
||||
self.shipDescription = textFormatting.wrap(self.baseItem.description, 80)
|
||||
self.SetToolTip(wx.ToolTip(self.shipDescription))
|
||||
|
||||
#=======================================================================\
|
||||
# DISABLED - it will be added as an option in PREFERENCES
|
||||
|
||||
|
||||
14
gui/utils/textFormatting.py
Normal file
14
gui/utils/textFormatting.py
Normal file
@@ -0,0 +1,14 @@
|
||||
def wrap(text, width):
|
||||
"""
|
||||
A word-wrap function that preserves existing line breaks
|
||||
and most spaces in the text. Expects that existing line
|
||||
breaks are posix newlines (\n).
|
||||
"""
|
||||
return reduce(lambda line, word, width=width: '%s%s%s' %
|
||||
(line,
|
||||
' \n'[(len(line)-line.rfind('\n')-1
|
||||
+ len(word.split('\n',1)[0]
|
||||
) >= width)],
|
||||
word),
|
||||
text.split(' ')
|
||||
)
|
||||
Reference in New Issue
Block a user