<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def set_onscreen_message(self, text, redraw=True):
 """Called by a subclass to update the onscreen message. Parameters text : str The text to show in the display. """

        width, height = self.get_window_size()

        font = self.t_.get('onscreen_font', 'sans serif')
        font_size = self.t_.get('onscreen_font_size', None)
        if font_size is None:
            font_size = self._calc_font_size(width)

        # TODO: need some way to accurately estimate text extents
        # without actually putting text on the canvas
        ht, wd = font_size, font_size
        if text is not None:
            wd = len(text) * font_size * 1.1

        x = (width // 2) - (wd // 2)
        y = ((height // 3) * 2) - (ht // 2)

        tag = '_$onscreen_msg'

        canvas = self.get_private_canvas()
        try:
            message = canvas.get_object_by_tag(tag)
            if text is None:
                message.text = ''
            else:
                message.x = x
                message.y = y
                message.text = text
                message.fontsize = font_size

        except KeyError:
            if text is None:
                text = ''
            Text = canvas.get_draw_class('text')
            canvas.add(Text(x, y, text=text,
                            font=font, fontsize=font_size,
                            color=self.img_fg, coord='window'),
                       tag=tag, redraw=False)

        if redraw:
            canvas.update_canvas(whence=3)