In my script it runs fine without adding the GUI but trying to add tkinter I receive
line 44, in <module>
button_1=Button(my_window,text="Check Ports", command=portscan (port))
NameError: name 'port' is not defined
Port is defined within my function and the error only appears when I've added tkinter GUI to the code.
Again the code runs just fine without tkinter but when I add tkinter it gives the error.I'm trying to have a user entry box and use that variable as a target for a port scanner. The button would initiate my function to perform the port scan.
My next phase will be have this output in a secondary window that will popup but at present I'm just trying to get the basics working with tkinter from the input side.
line 44, in <module>
button_1=Button(my_window,text="Check Ports", command=portscan (port))
NameError: name 'port' is not defined
Port is defined within my function and the error only appears when I've added tkinter GUI to the code.
Again the code runs just fine without tkinter but when I add tkinter it gives the error.I'm trying to have a user entry box and use that variable as a target for a port scanner. The button would initiate my function to perform the port scan.
My next phase will be have this output in a secondary window that will popup but at present I'm just trying to get the basics working with tkinter from the input side.
from tkinter import * import socket import threading from queue import Queue print_lock = threading.Lock() def portscan (port): s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) try: con = s.connect((target,port)) with print_lock: output=('port', port, 'is open!') except: pass def threader(): while True: worker = q.get() portscan(worker) q.task_done() q = Queue() for x in range(30): t = threading.Thread(target=threader) t.daemon = True t.start() for worker in range(80,444): q.put(worker) my_window = Tk() label_1 = Label(my_window, text="Server IP or Host Name") entry_1 = Entry(my_window) button_1=Button(my_window,text="Check Ports", command=portscan (port)) label_1.grid(row=0, column=0) entry_1.grid(row=0, column=1) button_1.grid(row=1, column=0) target = entry_1.get() q.join() root.mainloop()