-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathultrapowermanagementpromax.py
More file actions
81 lines (59 loc) · 2.93 KB
/
Copy pathultrapowermanagementpromax.py
File metadata and controls
81 lines (59 loc) · 2.93 KB
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
import tkinter as tk
import os
from tkinter import messagebox
# Глобальна змінна для керування таймером
timer_running = None
def run_command(cmd_type):
global timer_running
try:
seconds = int(entry_time.get())
except ValueError:
messagebox. showerror("Помилка", "Введіть число секунд!")
return
if cmd_type == "shutdown":
if messagebox.askyesno("Підтвердження", f"Вимкнути ПК через {seconds} сек?"):
os.system(f"shutdown /s /t {seconds}")
start_ui_countdown (seconds)
elif cmd_type == "restart":
os.system(f"shutdown /r /t {seconds}")
start_ui_countdown (seconds)
elif cmd_type == "cancel":
os. system("shutdown /a")
if timer_running:
root.after_cancel(timer_running) # Зупиняємо графічний таймер
label_countdown.config(text="Таймер зупинено", fg="white")
messagebox.showinfo("Скасовано","Bci команди скасовані")
def start_ui_countdown(time_left):
global timer_running
if time_left > 0:
label_countdown.config(text=f"До дії залишилось: {time_left} сек", fg="#e74c3с")
timer_running = root.after(1000, start_ui_countdown, time_left - 1)
else:
label_countdown.config(text="Час вийшов!", fg="white")
def open_folder():
os.startfile(os.getcwd())
root = tk.Tk()
root.title("Ultra Power Manager Pro")
root.geometry("450x600")
root.config(bg="#1a1a1a")
tk. Label(root, text="SYSTEM CONTROL", font=("Courier New", 20, "bold"),
bg="#1a1a1a", fg="#00ff00").pack(pady=20)
tk.Label(root, text="Введіть час y секундах:", bg="#1a1a1a", fg="white").pack()
entry_time = tk.Entry(root, font=("Arial", 14), justify="center", width=10)
entry_time.insert(0, "60")
entry_time.pack(pady=10)
label_countdown = tk.Label(root, text="Таймер не запущено", font=("Arial", 12),
bg="#1a1a1a", fg="gray")
label_countdown.pack (pady=10)
btn_style = {"width": 25, "height": 2, "font": ("Arial", 10, "bold")}
tk.Button(root, text="Вимкнути ПК", bg="#c0392b", fg="white",
command=lambda: run_command("shutdown"), ** btn_style).pack(pady=5)
tk.Button(root, text="Перезавантажити", bg="#d35400", fg="white",
command=lambda: run_command("restart"), ** btn_style).pack(pady=5)
tk.Button(root, text="Відкрити папку проекту", bg="#2980b9", fg="white",
command=open_folder, ** btn_style).pack(pady=5)
tk.Button(root, text="CKACYBATN", bg="#27ae60", fg="white",
command=lambda: run_command("cancel"), ** btn_style).pack(pady=20)
info_text = f"KopncTyBay: {os.getlogin()} \nod: {os.name}"
tk.Label(root, text=info_text, bg="#1a1a1a", fg="#555", font=("Arial", 8)).pack(side="bottom")
root.mainloop()