Cautions:
- the font needs to be a monospace font in order for things to line up properly.
- the background is transparent, so choose a color that will work well with your control page background (you can use the OS X color picker to find the HTML color value).
- if you change the font size, it won't be centered in the box any longer (and may not fit if you go much larger); if necessary, uncomment the 'ax.axis('off')' to hide the box.
Note: this script requires matplotlib be installed on the Indigo server machine. If your machine does not have matplotlib installed, this is probably not a solution for you (later Macs ship with it preinstalled.)
- Code: Select all
#! /usr/bin/env python2.6
# -*- coding: utf-8 -*-
import calendar
from datetime import datetime, time
import matplotlib.pyplot as plt
font_name = 'Andale Mono'
font_color = '#000000'
year = int(datetime.today().strftime('%Y'))
month = int(datetime.today().strftime('%m'))
cal = calendar.month(year, month)
output_file_path = '/Library/Application Support/Perceptive Automation/Indigo 6/IndigoWebServer/images/controls/static/calendar.png'
fig = plt.figure(figsize=(5, 3))
ax = fig.add_subplot(111)
ax.text(0.07, 0.95, cal, transform=ax.transAxes, color=font_color, fontname=font_name, fontsize=20, verticalalignment='top')
ax.axes.get_xaxis().set_visible(False)
ax.axes.get_yaxis().set_visible(False)
# ax.axis('off') # uncomment this line to hide the box
plt.savefig(output_file_path, transparent=True)
[EDIT] Moved to the Dave's Scripts forum.
[EDIT2] To see a listing of fonts on your system that matplotlib can see, run the following script in an Indigo scripting shell:
- Code: Select all
import matplotlib.font_manager as mfont
from os import path
font_menu = [path.splitext(path.basename(font))[0] for font in mfont.findSystemFonts(fontpaths=None, fontext='ttf')]
for font in sorted(font_menu):
indigo.server.log(font)