can you convert it to another gui as pyqt5 or somehing, without your error. what is that?: "if name == “main”:
       ^^^^
NameError: name ‘name’ is not defined" , but not tiker?: import tkinter as tk
from tkinter import ttk, scrolledtext
from threading import Thread, Lock
import re
import socket
import netifaces

lock = Lock()
def extract_ips(bridge_data):
pattern = re.compile(r’(\d{1,3}(?:.\d{1,3}){3}:\d+)‘)
ips_with_ports = pattern.findall(bridge_data)
return ips_with_ports

def update_console(message):
with lock:
console_display.configure(state=‘normal’)
console_display.insert(tk.END, message + “\n”)
console_display.configure(state=‘disabled’)
console_display.yview(tk.END)

def is_port_open(ip, port, timeout):
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
sock.settimeout(timeout)
try:
sock.connect((ip, port))
return True
except socket.error:
return False
finally:
sock.close()

def check_ip_port(ip, port, timeout):
if is_port_open(ip, port, timeout):
update_console(f"Connection successful for {ip}:{port}“)
return True
else:
update_console(f"Connection failed for {ip}:{port}”)
return False

def check_bridges():
raw_data = bridge_input.get(‘1.0’, tk.END)
ip_port_pairs = extract_ips(raw_data)
timeout = float(timeout_entry.get())
def process_ips():
responsive_bridges = []
for ip_port in ip_port_pairs:
ip, port = ip_port.split(’:‘)
if check_ip_port(ip, int(port), timeout):
responsive_bridges.append(ip_port)
with lock:
responsive_data = ‘\n’.join([line for line in raw_data.split(’\n’) if any(ip_port in line for ip_port in responsive_bridges)])
result_display.configure(state=‘normal’)
result_display.delete(‘1.0’, tk.END)
result_display.insert(tk.END, responsive_data)
result_display.configure(state=‘disabled’)
status_label.config(text=“Check completed”)
for _ in range(int(thread_count_entry.get())):
thread = Thread(target=process_ips)
thread.start()

def get_network_interfaces():
interfaces_list = netifaces.interfaces()
return interfaces_list

def clear_console():
console_display.configure(state=‘normal’)
console_display.delete(‘1.0’, tk.END)
console_display.configure(state=‘disabled’)

root = tk.Tk()
root.title(“Tor Bridge Connectivity Checker”)

frame = ttk.Frame(root, padding=“3”)
frame.grid(column=0, row=0, sticky=(tk.W, tk.E, tk.N, tk.S))
frame.columnconfigure(0, weight=1)

interfaces = get_network_interfaces()
net_interface_label = ttk.Label(frame, text=“Network Interface:”)
net_interface_label.grid(column=0, row=0, sticky=tk.W)
net_interface_selector = ttk.Combobox(frame, values=interfaces)
net_interface_selector.grid(column=1, row=0, sticky=(tk.W, tk.E), columnspan=3)

thread_count_label = ttk.Label(frame, text=“Thread Count:”)
thread_count_label.grid(column=4, row=0, sticky=tk.W, padx=(4, 0))
thread_count_entry = ttk.Spinbox(frame, from_=1, to=100, increment=1, width=7)
thread_count_entry.set(10) # default value
thread_count_entry.grid(column=5, row=0)

timeout_label = ttk.Label(frame, text=“Timeout (s):”)
timeout_label.grid(column=6, row=0, sticky=tk.W, padx=(4, 0))
timeout_entry = ttk.Spinbox(frame, from_=1, to=10, increment=0.5, width=7, format=“%.1f”)
timeout_entry.set(3.0) # default value
timeout_entry.grid(column=7, row=0)

bridge_label = ttk.Label(frame, text=“Bridges to Check:”)
bridge_label.grid(column=0, row=1, sticky=tk.W)
bridge_input = scrolledtext.ScrolledText(frame, height=10)
bridge_input.grid(column=0, row=2, columnspan=8, sticky=(tk.W, tk.E), pady=(0, 5))
paste_button = tk.Button(frame, text=“Paste”, command=lambda: bridge_input.event_generate(‘<<Paste>>’))
paste_button.grid(column=0, row=3, sticky=tk.W)

result_label = ttk.Label(frame, text=“Sorted List:”)
result_label.grid(column=0, row=4, sticky=tk.W)
result_display = scrolledtext.ScrolledText(frame, height=10, state=‘disabled’)
result_display.grid(column=0, row=5, columnspan=8, sticky=(tk.W, tk.E), pady=(0, 5))
select_all_button = tk.Button(frame, text=“Select All”, command=lambda: result_display.tag_add(tk.SEL, “1.0”, tk.END))
select_all_button.grid(column=0, row=6, sticky=tk.W)
copy_button = tk.Button(frame, text=“Copy”, command=lambda: root.clipboard_append(result_display.get(tk.SEL_FIRST, tk.SEL_LAST)))
copy_button.grid(column=1, row=6, sticky=tk.W)

check_button = tk.Button(frame, text=“Check Bridges”, command=check_bridges)
check_button.grid(column=2, row=6, sticky=tk.W, pady=(0, 5))

console_label = ttk.Label(frame, text=“Console Log:”)
console_label.grid(column=0, row=7, sticky=tk.W)
clear_console_button = tk.Button(frame, text=“Clear”, command=clear_console)
clear_console_button.grid(column=0, row=8, sticky=tk.W)
console_display = scrolledtext.ScrolledText(frame, height=8, state=‘disabled’, background=‘black’, foreground=‘white’)
console_display.grid(column=0, row=9, columnspan=8, sticky=(tk.W, tk.E))

status_label = tk.Label(frame, bd=1, relief=tk.SUNKEN, anchor=tk.W)
status_label.grid(column=0, row=10, columnspan=8, sticky=(tk.W, tk.E))

root.mainloop()