Добавил:
eipimru
У меня есть канал с приколами: t.me/urmipies_garbage Подпишитесь пж-пж!!!!
Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз:
Предмет:
Файл:
#!/usr/bin/env python3
import tkinter as tk
from tkinter import ttk
from tkinter.scrolledtext import ScrolledText
import security_checks
class OptionRow:
def __init__(self, parent, name, action):
self.name = name
self.frame = tk.Frame(parent)
self.frame.pack(fill=tk.X, pady=2)
self.action = action
self.text_var = tk.StringVar()
button = ttk.Button(
self.frame,
text=name,
command=lambda: self.text_var.set(action())
)
button.pack(side=tk.LEFT, padx=(0, 10))
entry = ttk.Entry(self.frame, textvariable= self.text_var, width=30)
entry.pack(side=tk.LEFT, fill=tk.X, expand=True)
def __str__(self):
text_value = self.text_var.get()
return f"{self.name.replace('\n', ' ')}: {text_value if text_value else 'Не проводилось'}"
class App:
def __init__(self, root):
self.options = []
self.root = root
self.root.title("Программа проверки информационной безопасности")
self.main_frame = ttk.Frame(root)
self.main_frame.pack(expand=True, padx=10, pady=10)
self.create_blocks()
frame = ttk.LabelFrame(self.main_frame, text="Результаты проверок и рекомендации", padding=10)
button = ttk.Button(
frame,
text="Сохранить в файл и сбросить",
command=self.save_to_file)
button.pack(fill=tk.X, padx=10, pady=10)
self.output_text = ScrolledText(frame, height=10)
self.output_text.pack(fill=tk.X, padx=10, pady=10)
frame.pack(fill=tk.X, padx=10, pady=10)
self.update_output_text()
def create_blocks(self):
self.create_block(
"Проверка межсетевого экрана",
[
("Проверка подключения к интернету", security_checks.connection_check),
("Проверка установленного\nмежсетевого экрана", security_checks.firewall_installed_check),
("Проверка работоспособности\nмежсетевого экрана", security_checks.firewall_working_check)
]
)
self.create_block(
"Проверка антивирусного ПО",
[
("Проверка наличия антивирусного ПО", security_checks.antivirus_installed_check),
("Тестирование антивирусного ПО", security_checks.antivirus_working_check),
]
)
def create_block(self, title, buttons):
block_frame = ttk.LabelFrame(self.main_frame, text=title, padding=10)
block_frame.pack(fill=tk.X, pady=5, padx=5)
for button in buttons:
row = OptionRow(block_frame, *button)
row.text_var.trace_add("write", lambda *args: self.update_output_text())
self.options.append(row)
def update_output_text(self):
self.output_text.delete(1.0, tk.END)
self.output_text.insert(tk.INSERT, "\n".join([str(option) for option in self.options]))
def save_to_file(self):
with open("security_check_results.txt", "w") as file:
file.write(str(self.output_text.get(1.0, tk.END)))
for option in self.options:
option.text_var.set("")
self.update_output_text()
def main():
root = tk.Tk()
app = App(root)
root.mainloop()
if __name__ == "__main__":
main() 