<commit_before>from Tkinter import *
import Settings, Output, functions, PhotoThread

__root = None
__canvas = __debug = None
__w = __h = __image_size = 0

def quit(some_var):
	"""Beendet die App."""
	global __root
	__root.destroy()

def image_size(): return __image_size

def display_text(string):
	"""Displays a text on the screen."""
	global __text, __canvas, __w, __h
	__canvas.delete(__text)
	__text = __canvas.create_text(__w/2, __h/2, text=string, fill="#45ADA6", anchor="c", font="Lucida 90", justify=CENTER)
	Output.debug("Text: " + string.replace("\n", "\\n"))

def display_debug(string):
	"""Displays debug strings on screen."""
	global __debug
	if __canvas:
		if __debug:
			__canvas.delete(__debug)
		__debug = __canvas.create_text(0, 0, text=string, fill="#aaaaaa", font="Lucida 12", anchor="nw")

def remove_debug_text():
	if __canvas and __debug:
		__canvas.delete(__debug)

def clear():
	global __canvas
	__canvas.delete(ALL)

def show_overview():
	"""Displays the 4 pictures on the screen. Uses PhotoLoadThreads and still is pretty slow..."""
	global __canvas, __image_size
	__canvas.delete(ALL)
	Output.debug("image_size is " + str(__image_size))
	for i in range(4):
		plt = PhotoThread.photo_load_threads()[i]
		if i==0 or i==1:
			y = __h/2 - Settings.PADDING/2
			anchor = "s"
		if i==2 or i==3:<commit_msg>Debug output on screen resulted in a race condition with multiple instances of debug output overlapping on screen. As a fix we update the debug stuff only when we're running in the MainThread.<commit_after>from Tkinter import *
import threading
import Settings, Output, functions, PhotoThread

__root = None
__canvas = __debug = None
__w = __h = __image_size = 0

def quit(some_var):
	"""Beendet die App."""
	global __root
	__root.destroy()

def image_size(): return __image_size

def display_text(string):
	"""Displays a text on the screen."""
	global __text, __canvas, __w, __h
	__canvas.delete(__text)
	__text = __canvas.create_text(__w/2, __h/2, text=string, fill="#45ADA6", anchor="c", font="Lucida 90", justify=CENTER)
	Output.debug("Text: " + string.replace("\n", "\\n"))

def display_debug(string):
	"""Displays debug strings on screen."""
	global __debug
	print threading.current_thread().__class__.__name__
	if not threading.current_thread().__class__.__name__ == "_MainThread":
		return
	if __canvas:
		if __debug:
			__canvas.delete(__debug)
		__debug = __canvas.create_text(0, 0, text=string, fill="#aaaaaa", font="Lucida 12", anchor="nw")

def remove_debug_text():
	if __canvas and __debug:
		__canvas.delete(__debug)

def clear():
	global __canvas
	__canvas.delete(ALL)

def show_overview():
	"""Displays the 4 pictures on the screen. Uses PhotoLoadThreads and still is pretty slow..."""
	global __canvas, __image_size
	__canvas.delete(ALL)
	Output.debug("image_size is " + str(__image_size))
	for i in range(4):
		plt = PhotoThread.photo_load_threads()[i]
		if i==0 or i==1:
			y = __h/2 - Settings.PADDING/2
			anchor = "s"
		if i==2 or i==3:
{'fraction_non_alphanumeric': 0.13119143239625167, 'fraction_numerical': 0.013386880856760375, 'mean_word_length': 4.966067864271457, 'pattern_counts': {'":': 1, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, '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': '1313309', 'n_tokens_mistral': 1068, 'n_tokens_neox': 1010, 'n_words': 302}