<commit_before># ImageWindow.py
from PIL import Image, ImageDraw, ImageTk
try:
    import Tkinter as tkinter
except ImportError:
    import tkinter

# Thanks to the following examples for the Tk code...
# http://code.activestate.com/recipes/521918-pil-and-tkinter-to-display-images/
# https://stackoverflow.com/questions/19895877/tkinter-cant-bind-arrow-key-events

class ImageWindow:
    def __init__(self, width, height, root=None):
        if root==None:
            self.root = tkinter.Tk()
            # self.root = tkinter.Toplevel()
        else:
            self.root = root

        self.width = width
        self.height = height
        self.key = ''
        self.num_annotated = 0

        self.root.geometry('%dx%d' % (width, height))
        self.root.bind("<Key>", lambda e: self.key_handler(e, self))
        # self.root.bind("<Left>", self.arrow_handler)
        # self.root.bind("<Right>", self.arrow_handler)
        # self.root.bind("<Up>", self.arrow_handler)
        # self.root.bind("<Down>", self.arrow_handler)

    @staticmethod
    def key_handler(event, obj):
        obj.set_key(event.keysym)
        event.widget.quit()

    def set_key(self, key):
        self.key = key

    def get_key(self):
        return self.key

    def show_image(self, image):
        self.tki = ImageTk.PhotoImage(image)
        self.label = tkinter.Label(self.root, image=self.tki)
        self.label.place(x=0, y=0, width=self.width, height=self.height)

    def force_focus(self):
        self.root.focus_force()

    def wait(self):
        self.root.mainloop()

    def update(self):
        self.root.update()

    def close(self):
        self.root.destroy()<commit_msg>Moved ImageWindow to shared, made show_image() return self<commit_after># ImageWindow.py
from PIL import Image, ImageDraw, ImageTk
try:
    import Tkinter as tkinter
except ImportError:
    import tkinter

# Thanks to the following examples for the Tk code...
# http://code.activestate.com/recipes/521918-pil-and-tkinter-to-display-images/
# https://stackoverflow.com/questions/19895877/tkinter-cant-bind-arrow-key-events

class ImageWindow:
    def __init__(self, width, height, root=None):
        if root==None:
            self.root = tkinter.Tk()
            # self.root = tkinter.Toplevel()
        else:
            self.root = root

        self.width = width
        self.height = height
        self.key = ''
        self.num_annotated = 0

        self.root.geometry('%dx%d' % (width, height))
        self.root.bind("<Key>", lambda e: self.key_handler(e, self))
        # self.root.bind("<Left>", self.arrow_handler)
        # self.root.bind("<Right>", self.arrow_handler)
        # self.root.bind("<Up>", self.arrow_handler)
        # self.root.bind("<Down>", self.arrow_handler)

    @staticmethod
    def key_handler(event, obj):
        obj.set_key(event.keysym)
        event.widget.quit()

    def set_key(self, key):
        self.key = key

    def get_key(self):
        return self.key

    def show_image(self, image):
        self.tki = ImageTk.PhotoImage(image)
        self.label = tkinter.Label(self.root, image=self.tki)
        self.label.place(x=0, y=0, width=self.width, height=self.height)
        return self

    def force_focus(self):
        self.root.focus_force()

    def wait(self):
        self.root.mainloop()

    def update(self):
        self.root.update()

    def close(self):
        self.root.destroy()
{'fraction_non_alphanumeric': 0.13362445414847163, 'fraction_numerical': 0.009898107714701601, 'mean_word_length': 2.491869918699187, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 13, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5592191', 'n_tokens_mistral': 1154, 'n_tokens_neox': 1109, 'n_words': 220}