How to hide console window in python in Ubuntu? - python

I have a python file that displays a console window by running it. I want this window to be hidden. I did it in Windows but I couldn't in Ubuntu.
The code used in Windows:
import ctypes
ctypes.windll.user32.ShowWindow( ctypes.windll.kernel32.GetConsoleWindow(), 0 )

Related

tk,Tk().widthdraw() all tk windows instead of just root in IDLE

When running
tk.Tk().withdraw()
filePath = filedialog.askopenfile(filetypes=[("Comma seperated values",".csv")])
through command line a file select window shows up (what I want to happen), however when running through IDLE nothing shows up how can I fix this?
I am using Python 3.9.7 on Windows 10

How to start python program with a terminal window on ubuntu startup

I want to start a python program on ubuntu startup and im using session and startup option for it. But each time the system boots python program starts but without a terminal window that I need. Is there any option to force program to start with terminal window?
To open a python application with a terminal window on startup just add it to the Settings >> Session and Startup with a following command gnome-terminal -- python3 path/to/app

Focus on pygame window

I am using
import ctypes
ctypes.windll.user32.ShowWindow( ctypes.windll.kernel32.GetConsoleWindow(), 6 )
to close the console and leave the pygame window open however I have to click on the window to interact with it. Can I make it so it goes back to the pygame window automatically?
A python script may be run in windowed mode by launching with pythonw, this may be automatically handled by changing the file extension to .pyw.
See this answer for more detailed information.

Using wxPython within Sublime Text 3

I am using Windows 10
I wish to use wxPython as a GUI for my Python3 programs. I am using SublimeText 3 to write and launch my scripts
When I launch my script from within Sublime the program runs but the wxPython window does not open. It opens as expected if I run the program from the cmd prompt.
My internet searching leads me to believe that Sublime is suppressing the window from opening and that this behavior can be changed within Sublime's settings, but I can only find instructions for Sublime Text 2.
How can I prevent Sublime Text 3 from suppressing the wxPython window?
If you are using Windows, the correct extension would be *.pyw. Change the name of your WX Python script changing the extension ".py" for ".pyw" and try to run it from ST3.
Good luck.

Terminal window appears along with pygame window upon launch of the exe

I made a game using pygame and built it using cx_Freeze, now when I run the executable it launches a console window along with the pygame window, is there any way to remove/disable this window
I solved it
In the cx_Freeze setup file you need to add the line
base = “WIN32GUI”
When declaring your exeacutable

Categories