Untitled

mail@pastecode.io avatar
unknown
python
6 months ago
2.7 kB
8
Indexable
Never
    def open_requirements_windows(self):
        # Create window of requirements


        req_win = tk.Toplevel()
        req_win.title("Requisiti")
        req_win.config(background="white")
        # Setting size and geometry
        width = 400
        height = 400
        screenwidth = root.winfo_screenwidth()
        screenheight = root.winfo_screenheight()
        alignstr = '%dx%d+%d+%d' % (width, height, (screenwidth - width) / 2, (screenheight - height) / 2)
        req_win.geometry(alignstr)

        image = PhotoImage(file=self.resource_path("logo.png"))
        icon_label = Label(req_win, image=image)
        icon_label.pack(pady=30)


        title_label = Label(req_win, text="Requisiti", font=("Times", 18, "bold"), background="white")
        title_label.pack()

        separator = ttk.Separator(req_win, orient="horizontal")
        separator.pack(fill="both")

        # Check admin security permission
        is_admin = ctypes.windll.shell32.IsUserAnAdmin()
        admin_check = ""
        if is_admin:
            admin_check = "OK"
        else:
            admin_check = "NO"

        # Check test connection (LAN cable plugin?)
        command_test_connection = f"Get-NetAdapter | Select-Object -ExpandProperty Status Up"
        proc = subprocess.run(["powershell", command_test_connection], capture_output=True, shell=True).stdout.decode("utf-8")
        if "Up" in proc:
            connection_check = "OK"
        else:
            connection_check = "NO"

        # Label of admin permissions
        admincheck_label = Label(req_win, text="\n * Diritti di amministratore: "+admin_check, background="white", wraplength=280, font=("Times", 14, "bold"))
        admincheck_label.pack()

        # Label of connection check
        connection_check_label = Label(req_win, text="\n * Connessione LAN: " + connection_check, background="white",
                                 wraplength=280, font=("Times", 14, "bold"))
        connection_check_label.pack()

        # Button OK to close requirements window
        button_ok_info = tk.Button(req_win, text="OK", width=30, background="yellow",
                                   command=lambda: req_win.destroy())
        button_ok_info.pack(pady=30)
        req_win.attributes("-topmost", True)
        # Shows new window
        req_win.mainloop()


    def open_req_win_in_sep_thread(self):
        # Creates new thread to execute function 
        thread = threading.Thread(target=self.open_requirements_windows())

        # Starts thread
        thread.start()

        # Wait thread to stop
        thread.join()