-1

I'm writing a simple 'Ping' app, which adds 'color' identification to ping response. Like, if response failed - red screen, else green screen.

To avoid questions, i already searched my follow-up question on stackoverflow and didn't find any workable solution for my case. Some links, as example:

Program structure looks like this:

There is two files. main_window.py with main window code and ping_window.py with ping window code. The main window contain tk.Entrys for url and some 'ping request' modifications (like -t or -i), and tk.Button which starts pinging (lets call it start button).

After pressing start button, I call a function, which creates and starts new NewProcessPingWindow class object, inherited from the multiprocessing.process(class is located in ping_window.py). In it's run() method i create new, separate window (let's call it ping window) and start ping() function with delivered from main window's tk.Entrys values.

In ping window i show ping results every second (ping() function is moved into another thread, to avoid ping window ui freezing).

All works perfectly well in PyCharm. But when I build an executable file with pyinstaller --onefile main_window.py, it's becoming impossible to start ping window after pressing start button. Instead of that .exe creates new duplicate of the main window, without creating ping window. And i can continue doing this endlessly. Just every elder window will freeze after creating the new one.

Of cource I added if __name__ == '__main__':, but it didn't help. All works in IDE, but not with .exe.

At the end of the question I also add code source, as long as my code is a bit long for stackoverflow posts. I didn't cut anything from example to avoid misunderstandings.

P.S. I'm pretty sure that i don't see an elementary mistake, but i'm searching for 2 days and have no progress...

MIku
  • 89
  • 6

1 Answers1

0

As i thought, the real reason of the wrong window-creating was my fault and inattention. I accidently deleted multiprocessing.freezing_support() call in if '__name__' == '__main__: construction. So, the main_window call should look like

if __name__ == '__main__':
    multiprocessing.freeze_support()
    main_window()

P.S. Thanks to Alexander who helped me with this problem

MIku
  • 89
  • 6