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:
- Tkinter: Launching process via multiprocessing creates not-wanted new window
- Executable using tkinter and multiprocessing creates multiple windows)
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.Entry
s 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.Entry
s 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.
- https://pastebin.com/wTGEZqvL - main window
- https://pastebin.com/Kn0qVBM0 - ping window
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...