# Run tkinter code in another thread
import threading
import tkinter as tk


class DiggingOverlay(threading.Thread):

    def __init__(self, config):
        threading.Thread.__init__(self)
        self.root = tk.Tk
        self.EnemyLabel = tk.Label
        self.TkPosition = config.returnDiggingOverlayPos()
        self.start()

    def callback(self):
        self.root.quit()

    def run(self):
        self.root = tk.Tk()
        self.root.geometry(self.TkPosition)
        self.root.overrideredirect(1)  # fenster ohne aussen rum :-)
        self.root.attributes('-alpha', 0.5)  # fenster transparent
        self.root.attributes('-topmost', 1)  # fenster immer im vordergrund
        self.root.resizable(False, False)
        self.root.wm_attributes("-disabled", True)
        self.root.configure(background='black')
        self.root.mainloop()

    def hide_window(self):
        self.root.attributes('-alpha', 0.0)

    def show_window(self):
        self.root.attributes('-alpha', 0.2)
