I have written a simple software for creating passwords. But when converted to exe and run file, the terminal screen closes after about 1 second.I have also installed all the modules. The software is available at the link below.Please help me.
https://gofile.io/d/0G6N1o
The reason it is closing is because your application completed. You either need to have a dialog box which allows the user to click close, or at a minimum a sleep before you call exit(). This is the same for a .bat script in which the behavior you describe is a terminal window flickering for a second and going away.
Related
Hello so I'm kind of new with programming and I buildt a program with python and kivy. The issue is that I am using auto-py-to-exe to convert the py files to exe but when I do it, it doesn't work well. The primary issue is that a windows command prompt opens when I run the app and if I close it, the app closes too. The other problem is that I can't share the file to someone else so that they can run it in another computer, and what happens is that the same command prompt kind of appears but then closes and the app doesn't open at all. I would appreciate it if someone could help me to understand how I can debug it as I don't even understand the problem in the first place.
I have been looking online for other people with the same issues but I haven't find any answer that applied to my case.
Try to choose Window Based(hide the console) and it wil works
If you choose “Console Based,” the console will open after running the executable file, which is recommended if your script generates console-based outputs. However, if you don’t want to show the console outputs when running the executable file, choose “Window Based”
I am finishing a python program which I will distribute as exe.
I use Python 3.7 on Windows 10 64b.
The user will double click on exe to run my program. Then a windows console open and display logs in this console.
My program doesn’t need any gui but I would like to give to the users the possibility to hide the console with the logs and to show it back whenever he/she wants from an icon in the systray.
I found various answers here but none was responding to my needs.
I think I am not the one who would like to have this option on our python script. It could be very useful.
I found a tutorial for building a systray icon in python:
https://youtu.be/WM27fMo5Gg8
But it is about opening windows program, not about showing/hiding its own console.
After further investigation, I found the solution. It works when I run my script in the terminal. I still didn't test with the exe of my program. I may come back here to edit my answer if some extra information is necessary for .exe files.
I found this famous script SystrayIcon.py for python 2 which help me to create my icon with a menu very quickly.
I found the Python 3 version of this script here.
Then I use GetConsoleWindow from types and ShowWindow from win32gui to hide and show the console.
def show(sysTrayIcon):
the_program_to_hide = ctypes.windll.kernel32.GetConsoleWindow()
win32gui.ShowWindow(the_program_to_hide, win32con.SW_SHOW)
def hide(sysTrayIcon):
the_program_to_hide = ctypes.windll.kernel32.GetConsoleWindow()
win32gui.ShowWindow(the_program_to_hide, win32con.SW_HIDE)
These 2 functions are connected to the menu of my systray icon.
I hope it will help someone one day.
PS: The StackOverflow editor bug and I couldn't manage to show the code of the 2 functions properly.
I have no idea if this problem has the solution I want but here goes.
I'm making a PyQt4 program that apparently needs the console window to run properly. However, whenever I activate another window, sending the program I'm working on to the back, the only way I can get back to it is by closing all the windows in front of said window. I can't just click on the taskbar because the only thing that comes back is the console window.
I'm curious. Is there a way to have the GUI window activate along with, or independent of, the console window without having to go through the annoying process of closing (minimizing) potentially all the rest of your windows?
Edit: I just realized my question is pretty vague. Let me elaborate.
I'm compiling said program using pyinstaller.
The reason it needs the console window to work properly (I have tried using the .pyw file as well, to no avail) is because there's another program that's the core of this one that prints out to it in a way I can only describe as violently.
Apparently it won't be happy unless it has the console to record it's outbursts.
That being said, I need the console window. However, as I mentioned before, that is the only thing that comes up when the pyinstaller icon is clicked.
There is a gui attached to the console, but there's no way to get it back even after the user would minimize it because the pyinstaller icon insists it doesn't exist.
Maybe it has something to do with how I defined the window while programming it, but I don't see why that would be the case. Is there something in particular pyinstaller doesn't like that would make it act like this?
How are you launching the PyQt application?
If you're launching it with the python executable, it will create a console.
python my_application.py
Instead, launch it with the GUI version of python -- pythonw:
pythonw my_application.py
If the python path isn't in the system path, you may need to specify the whole path to the executable:
C:\python27\pythonw.exe C:\path\to\my_application.py
I have a python script that runs the GUI which is coded using Tkinter.
Problem is when i run the script, there are 2 windows opened. One is the GUI and other is the black console window.
I need to integrate both the windows so that when I start the script only one window appears.
Any ideas are much appreciated.
Thanks in advance.
Rename your Python script as .pyw (not .pyc). This will tell the invoker to to instantiate a console window. Source
Note however, this will work for non-GUI based scripts too which can cause undesireqable behaviour - such as not being able to see your script.
(I am pretty sure there is a better way, but) one way is to change the .pyc object file extension to .pyw and the console will not appear when you launch your GUI using the .pyw file.
I have a weird issue on a friends machine where when they run my script, it only flashes the command window when it hits a line that does something with os.system. It seems to not show the command window at all otherwise. Not showing is fine, but my script does a large process and it causes the window to flash a lot.
Normally on my machine, when I open the script (that launches a gui with tkinter) the command window will open as well in the back. This is what I am trying to get my friends to do, but I do not know what would cause the command window to not show. Is there a setting within python somewhere that doesn't show the command window (unless of course it needs to run a process in it)?
Edit: Ok I did a really lame hack to fix this. Apparently all he .py files got associated with pythonw. I was unable to get this association changed (even going through the command prompt ASSOC) So I just did a silly renamed of the pythonw to old_pythonw, and renamed the python.exe to pythonw.exe. Yes, really silly but no time to argue with windows about file associations.