#
#   Python GUI - Labels - Macintosh
#

from Carbon.Ctl import CreateStaticTextControl
from Carbon.Controls import kControlStaticTextTextTag
from MacDummy import _mac_dummy_window
from GLabels import Label as GLabel

class Label(GLabel):
    
    def __init__(self, text = "New Label", **kwds):
        mac_control = CreateStaticTextControl(_mac_dummy_window,
            (0, 0, 150, 20), text, (0, 0, 0, 0, 0, 0, (0, 0, 0), (0, 0, 0)))
        GLabel.__init__(self, mac_control, **kwds)

    def get_text(self):
        return self._mac_control.GetControlData(0, kControlStaticTextTextTag)
    
    def set_text(self, text):
        self._with_focus(self._set_text, text)
    
    def _set_text(self, text):
        self._mac_control.SetControlData(0, kControlStaticTextTextTag, text)
        self._mac_invalidate()
