I have a .py script with Nmap module in it. It works fine when launched from Visual Studio. But it keeps popping up Nmap console-windows when converted to a stand-alone executable.
So the thing is a tkinter GUI for Windows, that periodically pings and port-scans multiple hosts at a time. It uses Nmap for part of its features. Here is an over-minimized version of the thing:
import nmap as nm
import tkinter as tk
radar = nm.PortScanner()
class App(tk.Tk):
def __init__(mr):
tk.Tk.__init__(mr)
mr.entry = tk.Entry(mr)
mr.entry.pack()
mr.entry.bind('<Return>', lambda event: mr.scaner())
def scaner(mr):
adr = mr.entry.get()
report = radar.scan(adr, arguments ='-F --host-timeout 3000ms --max-rtt-timeout 1000ms --max-retries 0 -Pn')
try:
if 'tcp' in radar[adr]:
mr.entry['background'] = 'green'
else:
mr.entry['background'] = 'red'
except KeyError:
mr.entry['background'] = 'red'
def Main():
app = App()
app.mainloop()
if __name__ == "__main__":
Main()
You input an IP address into the Entry-box, and press Enter key. If there's a live host, that has any open or filtered TCP-ports on it, the Entry-background turns green. If not, red. The problem arises after converting the whole thing to an .exe file. BTW, here's how:
pyinstaller --onefile --noconsole myscript.py
After that, the .exe works similarly, except for one annoying dumb thing. It launches a console window for about a sec, every time the scan is performed.
Any ideas on how to do the thing without launching those console windows will be much appreciated.