From 6ba8244a7fa424a26b95f7fcd38732bc16860a9e Mon Sep 17 00:00:00 2001 From: Asapanna Rakesh <45640029+INF800@users.noreply.github.com> Date: Sun, 5 Dec 2021 12:18:45 +0000 Subject: [PATCH 1/4] print py3 --- make_timeline.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/make_timeline.py b/make_timeline.py index 7f8beb5..b66612d 100755 --- a/make_timeline.py +++ b/make_timeline.py @@ -239,17 +239,17 @@ def get_text_metrics(self, family, size, text): 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')) From be7df36cd53adef42c9eea66177fc6f288379e0f Mon Sep 17 00:00:00 2001 From: Asapanna Rakesh <45640029+INF800@users.noreply.github.com> Date: Sun, 5 Dec 2021 12:26:50 +0000 Subject: [PATCH 2/4] requrements --- make_timeline.py | 6 +++--- requirements.txt | 4 ++++ 2 files changed, 7 insertions(+), 3 deletions(-) create mode 100644 requirements.txt diff --git a/make_timeline.py b/make_timeline.py index b66612d..b50c317 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) 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 From cbdf01a77c822ab7aaee1916029c7f424e61ec1d Mon Sep 17 00:00:00 2001 From: Asapanna Rakesh <45640029+INF800@users.noreply.github.com> Date: Sun, 5 Dec 2021 18:04:53 +0530 Subject: [PATCH 3/4] typo --- make_timeline.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/make_timeline.py b/make_timeline.py index b50c317..7881c6f 100755 --- a/make_timeline.py +++ b/make_timeline.py @@ -232,7 +232,7 @@ 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")) From 91d57ad926fce8363cfa1ef9796431d093d33a2a Mon Sep 17 00:00:00 2001 From: Asapanna Rakesh <45640029+INF800@users.noreply.github.com> Date: Sun, 5 Dec 2021 18:07:30 +0530 Subject: [PATCH 4/4] docs --- README.md | 9 +++++++++ 1 file changed, 9 insertions(+) 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: