diff --git a/README.md b/README.md index bfe70ef..23ac908 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,15 @@ # Timeline A tool for creating SVG timelines from JSON. +### Prerequisites + +Install tkinter and required packages using: + +```shell +$ sudo apt install python3-tk +$ sudo apt install -r requirements.txt +``` + ### Example You will be able to create timelines that look like this: diff --git a/make_timeline.py b/make_timeline.py index 7f8beb5..7881c6f 100755 --- a/make_timeline.py +++ b/make_timeline.py @@ -7,8 +7,8 @@ import json import os.path import sys -import tkFont -import Tkinter +import tkinter +import tkinter.font as TkFont class Colors: black = '#000000' @@ -44,7 +44,7 @@ def __init__(self, filename): self.tick_format = self.data.get('tick_format', None) self.markers = {} # initialize Tk so that font metrics will work - self.tk_root = Tkinter.Tk() + self.tk_root = tkinter.Tk() self.fonts = {} # max_label_height stores the max height of all axis labels # and is used in the final height computation in build(self) @@ -232,24 +232,24 @@ def get_text_metrics(self, family, size, text): if key in self.fonts: font = self.fonts[key] else: - font = tkFont.Font(family=family, size=size) + font = TkFont.Font(family=family, size=size) self.fonts[key] = font assert font is not None w, h = (font.measure(text), font.metrics("linespace")) return w, h def usage(): - print 'Usage: ./make_timeline.py in.json > out.svg' + print('Usage: ./make_timeline.py in.json > out.svg') sys.exit(-1) if __name__ == '__main__': if len(sys.argv) < 2: - print 'missing input filename' + print('missing input filename') usage() filename = sys.argv[1] if not os.path.isfile(filename): - print 'file %s not found' % filename + print('file %s not found' % filename) sys.exit(-1) timeline = Timeline(filename) timeline.build() - print timeline.to_string().encode('utf-8') + print(timeline.to_string().encode('utf-8')) diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..71e376f --- /dev/null +++ b/requirements.txt @@ -0,0 +1,4 @@ +# run `sudo apt install python3-tk` if required +parsedatetime +svgwrite +tk-tools \ No newline at end of file