-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMain.py
87 lines (60 loc) · 2.16 KB
/
Main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
from tkinter import Tk, Frame, Label, BOTH, YES, Toplevel, Button
from PIL import Image, ImageTk
class varis:
# opens the picture (must be .png) whos name is written in the "Name" txt file
with open("Name", "r") as file:
pics = file.read().strip("\n").split(", ")
pic = pics[0]
w, h = Image.open(f"Pictures/{pic}.png").size
w = int(w / 1.2)
h = int(h / 1.2)
root = Tk()
root.title("Frame")
root.configure(background="black")
root.overrideredirect(False)
dummy = Label(None)
root.focus_set()
ws = root.winfo_screenwidth()
hs = root.winfo_screenheight()
x = int(ws - w)
y = int(hs - h)
root.geometry(f"{w}x{h}+{x}+{y}")
var = varis()
class NotMyCode(Frame):
def __init__(self, master, *pargs):
Frame.__init__(self, master, *pargs)
self.image = Image.open(f"Pictures/{var.pic}.png")
self.img_copy = self.image.copy()
self.background_image = ImageTk.PhotoImage(self.image)
self.background = Label(self, image=self.background_image)
self.background.pack(fill=BOTH, expand=YES)
self.background.bind('<Configure>', self.resize_image)
self.p = 0
def resize_image(self, event):
new_width = event.width
new_height = event.height
self.image = self.img_copy.resize((new_width, new_height))
self.background_image = ImageTk.PhotoImage(self.image)
self.background.configure(image=self.background_image)
var.root.overrideredirect(True)
e = NotMyCode(var.root)
e.pack(fill=BOTH, expand=YES)
var.root.attributes("-topmost", False)
def button():
def loop():
if e.p % 2 == 0:
var.root.withdraw()
B.geometry(f"10x10+{var.ws-10}+{var.hs-10}")
e.p += 1
else:
var.root.deiconify()
B.geometry(f"10x10+{var.x - 10}+{var.hs-10}")
e.p += 1
B = Toplevel()
B.geometry(f"10x10+{var.x - 10}+{var.hs-10}")
b1 = Button(B, text="", command=loop, bg="#0a1517", fg="#0a1517", relief="flat", highlightbackground="#0a1517")
b1.pack()
B.attributes("-topmost", True)
B.overrideredirect(True)
button()
var.root.mainloop()