-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.pyw
90 lines (63 loc) · 2.74 KB
/
main.pyw
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
88
89
import tkinter
import customtkinter
import os
import tkinter.font
from tkinter import messagebox
started = False
# Modes: system (default), light, dark
customtkinter.set_appearance_mode("System")
# Themes: blue (default), dark-blue, green
customtkinter.set_default_color_theme("blue")
app = customtkinter.CTk() # create CTk window like you do with the Tk window
app.resizable(False, False)
photo = tkinter.PhotoImage(file="icon.png")
app.iconphoto(False, photo)
app.iconbitmap("favicon.ico")
width = 600 # Width
height = 600 # Height
screen_width = app.winfo_screenwidth() # Width of the screen
screen_height = app.winfo_screenheight() # Height of the screen
# Calculate Starting X and Y coordinates for Window
x = (screen_width/2) - (width/2)
y = (screen_height/2) - (height/2)
app.geometry('%dx%d+%d+%d' % (width, height, x, y))
app.title('Be Productive')
def button_function():
global started
started = True
print("Started")
messagebox.showinfo(message="Be Productive has Started", title="Be Productive")
app.wm_state('iconic')
os.system("start closer.exe")
def button_function2():
global started
if (started):
os.system("taskkill /F /IM closer.exe")
started = False
print("Down")
else:
messagebox.showinfo(message="You need to start to stop it.", title="Be Productive")
text_var2 = tkinter.StringVar(value="It's time to be free.")
label = customtkinter.CTkLabel(master=app,
textvariable=text_var2,
width=120,
height=25,
corner_radius=8, text_font=("Latin Modern Mono Light", 30))
label.place(relx=0.5, rely=0.3, anchor=tkinter.CENTER)
text_var3 = tkinter.StringVar(value="We know it's hard to say no")
label = customtkinter.CTkLabel(master=app,
textvariable=text_var3,
width=120,
height=25,
corner_radius=8, text_font=("Latin Modern Mono Light", 20))
label.place(relx=0.5, rely=0.35, anchor=tkinter.CENTER)
# Use CTkButton instead of tkinter Button
button = customtkinter.CTkButton(
master=app, text="Start", command=button_function, text_font=("Latin Modern Mono Light", 35), fg_color="green", hover_color=("gray"))
button.place(relx=0.5, rely=0.5, anchor=tkinter.CENTER, width=170,
height=80)
button2 = customtkinter.CTkButton(
master=app, text="Stop", command=button_function2, text_font=("Latin Modern Mono Light", 35), fg_color="red", hover_color=("gray"))
button2.place(relx=0.5, rely=0.65, anchor=tkinter.CENTER, width=160,
height=70)
app.mainloop()