Exemple #1
0
def analog(draw, width, height):
    now = datetime.datetime.now()
    today_date = now.strftime("%d %b %y")

    top = 16
    margin = 3

    cx = width / 2
    cy = top + ((height - top - margin) / 2)

    left = (width - (height - top - margin)) / 2
    right = width - left

    hrs_angle = 270 + (30 * (now.hour + (now.minute / 60.0)))
    hrs = posn(hrs_angle, cx - 16)

    min_angle = 270 + (6 * now.minute)
    mins = posn(min_angle, cx - 10)

    sec_angle = 270 + (6 * now.second)
    secs = posn(sec_angle, cx - 10)

    draw.ellipse((left, top, right, height - margin), outline="white")
    draw.line((cx, cy, cx + hrs[0], cy + hrs[1]), fill="white")
    draw.line((cx, cy, cx + mins[0], cy + mins[1]), fill="white")
    draw.line((cx, cy, cx + secs[0], cy + secs[1]), fill="red")
    draw.ellipse((cx - 1, cy - 1, cx + 1, cy + 1), fill="white", outline="white")
    title_text(draw, margin, width, today_date)
Exemple #2
0
def digital(draw, width, height):
    margin = 3

    now = datetime.datetime.now()
    today_date = now.strftime("%d %b %y")
    current_time = now.strftime("%H:%m:%S")

    title_text(draw, margin, width, today_date)
    draw.text((margin + 10, 20), text=current_time, fill="white", font=tiny_font)
def render(draw, width, height):
    df = psutil.disk_usage("/")

    margin = 3

    title_text(draw, margin, width, text="Disk")
    draw.text((margin, 20), text="Used:", font=tiny_font, fill="white")
    draw.text((margin, 35), text="Free:", font=tiny_font, fill="white")
    draw.text((margin, 45), text="Total:", font=tiny_font, fill="white")

    right_text(draw, 20, width, margin, text="{0:0.1f}%".format(df.percent))
    right_text(draw, 35, width, margin, text=bytes2human(df.free, "{0:0.0f}"))
    right_text(draw, 45, width, margin, text=bytes2human(df.total, "{0:0.0f}"))
def render(draw, width, height):
    mem = psutil.virtual_memory()
    swap = psutil.swap_memory()
    mem_used_pct = (mem.total - mem.available) * 100.0 / mem.total

    margin = 3

    title_text(draw, margin, width, text="Memory")
    draw.text((margin, 20), text="Used:", font=tiny_font, fill="white")
    draw.text((margin, 35), text="Phys:", font=tiny_font, fill="white")
    draw.text((margin, 45), text="Swap:", font=tiny_font, fill="white")

    right_text(draw, 20, width, margin, text="{0:0.1f}%".format(mem_used_pct))
    right_text(draw, 35, width, margin, text=bytes2human(mem.used))
    right_text(draw, 45, width, margin, text=bytes2human(swap.used))
def render(draw, width, height):
    percentages = psutil.cpu_percent(interval=None, percpu=True)

    top_margin = 3
    bottom_margin = 3
    title_text(draw, top_margin, width, "CPU Load")

    bar_height = height - 15 - top_margin - bottom_margin
    width_cpu = width / len(percentages)
    bar_width = 0.5 * width_cpu
    bar_margin = (width_cpu - bar_width) / 2

    x = bar_margin

    for cpu in percentages:
        cpu_height = bar_height * (cpu / 100.0)
        y2 = height - bottom_margin
        vertical_bar(draw, x, y2 - bar_height - 1, x + bar_width, y2,
                     y2 - cpu_height)

        x += width_cpu