Exemple #1
0
def text_size(font, text):
    """Gets the height and width of text using font, in imlib2"""
    font_num = adesklets.load_font(font)
    adesklets.context_set_font(font_num)
    width, height = adesklets.get_text_size(text)
    adesklets.free_font(font_num)
    return width, height
Exemple #2
0
    def _draw_time(self):
        """
        Draw the time onto the canvas
        """
        x_pos = 0
        y_pos = 0

        # run through the tuple and print each part of the time
        for display in self.displays:
            text = get_time(display['format'])
            if self.caps:
                text = text.upper()
            s_x_pos = display['x_pos']
            s_y_pos = display['y_pos']

            x_pos = eval(s_x_pos) if isinstance(s_x_pos, str) else s_x_pos
            y_pos = eval(s_y_pos) if isinstance(s_y_pos, str) else s_y_pos

            print text

            # sure this is gross and dumb, but it's easier.
            cur_font = adesklets.load_font(display['font'])
            adesklets.context_set_font(cur_font)
            adesklets.text_draw(x_pos, y_pos, text)
            adesklets.free_font(cur_font)