Ejemplo n.º 1
0
    def __init__(self,  parent=None, z=textStartHeight, text_wordwrap=16, text='',
                 orientation='left', **kw):
        loadModels()

        if parent is None:
            parent = aspect2d

        if orientation == 'left':
            pos = (leftMargin, 0, z)
            text_align = TextNode.ALeft
        else:
            pos = kw['pos']
            text_align = TextNode.ACenter

        optiondefs = (
            ('relief', None, None),
            ('pos', pos, None),
            ('text_align', text_align, None),
            ('text_scale', 0.052, None),
            ('text_wordwrap', text_wordwrap, None),
            ('text', text, None)
        )

        self.defineoptions(kw, optiondefs)
        DirectLabel.__init__(self, parent)
        self.initialiseoptions(OptionLabel)
Ejemplo n.º 2
0
    def __init__(self,
                 parent=aspect2d,
                 text_size=1,
                 pos=(0.0, 0.0, 0.0),
                 text_align=TextNode.ACenter,
                 text_wordwrap=16,
                 text='',
                 **kw):
        scale = self.Scales.get(text_size, self.Scales[self.NormalSize])

        optiondefs = (('relief', None,
                       None), ('pos', pos, None), ('text_scale', scale, None),
                      ('text_wordwrap', text_wordwrap,
                       None), ('text', text, None), ('text_align', text_align,
                                                     TextNode.ACenter))

        self.defineoptions(kw, optiondefs)
        DirectLabel.__init__(self, parent)
        self.initialiseoptions(TTLabel)
    def __init__(self, parent = None, **kw):
        optiondefs = (
            ('text',        'Tooltip',      None),
            ('text_align',  TextNode.ALeft, None),
            #('text_fg',    (1, 1, 1, 1),    None),
            #('text_bg',    (0, 0, 0, 0.75), None),
            #('text_frame', (0, 0, 0, 0.75), None),
            ('borderWidth', (0.05, 0.05),   None),
            #('parent',      base.pixel2d,   None),
            #('sortOrder',   1000,           None),
           )
        # Merge keyword options with default options
        self.defineoptions(kw, optiondefs)
        # Initialize superclasses
        DirectLabel.__init__(self, parent)

        # make sure the text apears slightly right below the cursor
        if parent is base.pixel2d:
            self.textXShift = 10
            self.textYShift = -32
        else:
            self.textXShift = 0.05
            self.textYShift = -0.08

        self.mousePos = None

        # this will determine when the tooltip should be moved in the
        # respective direction, whereby
        # 1  : display edge
        # <1 : margin inside the window
        # >1 : margin outside the window
        self.xEdgeStartShift = 0.99
        self.yEdgeStartShift = 0.99

        # make sure the tooltip is shown on top
        self.setBin('gui-popup', 0)

        # Call option initialization functions
        self.initialiseoptions(DirectTooltip)

        self.hide()