@staticmethod
    def _Truncate(dc, text, maxWidth, ellipse, ellipseChars):
        line = text.split("\n")[0] # only consider the first line
        if not line:
            return ""

        pte = dc.GetPartialTextExtents(line)

        # Does the whole thing fit within our given width?
        stringWidth = pte[-1]
        if stringWidth <= maxWidth:
            return line

        # We (probably) have to ellipse the text so allow for ellipse
        maxWidthMinusEllipse = maxWidth - dc.GetTextExtent(ellipseChars)[0]

        if ellipse == wx.LEFT:
            i = bisect.bisect(pte, stringWidth - maxWidthMinusEllipse)
            return ellipseChars + line[i+1:]

        if ellipse == wx.CENTER:
            i = bisect.bisect(pte, maxWidthMinusEllipse / 2)
            j = bisect.bisect(pte, stringWidth - maxWidthMinusEllipse / 2)
            return line[:i] + ellipseChars + line[j+1:]

        if ellipse == wx.RIGHT:
            i = bisect.bisect(pte, maxWidthMinusEllipse)
            return line[:i] + ellipseChars

        # No ellipsing, just truncating is the default
        i = bisect.bisect(pte, maxWidth)
        return line[:i]

#======================================================================
# TESTING ONLY
#======================================================================
setting up object so we can run 2 different ways (live & debug)
dataset/ETHPy150Open ODM2/ODMToolsPython/odmtools/lib/ObjectListView/WordWrapRenderer.py/WordWrapRenderer._Truncate--crossover with--dataset/ETHPy150Open abunsen/Paython/paython/gateways/stripe_com.py/Stripe.__init__