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

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

Related

How to hide console window in python in Ubuntu?

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 )

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.

Pinning python application running through Python interpreter

I have an application I run using pythonw.exe. I just click on my .pyw file and it runs. It's using Qt and I have set up an icon that both shows in the window and in the taskbar.
However when I try to pin it, it pins the python IDLE incorrectly instead of the application itself. It makes some sense since it is a python file run from pythonw.exe. Example below:
So how do I proceed to run the application the right way so I can pin it to the taskbar?
As eryksun said you need a shortcut with pythonw.exe "Path to pyw file" in target.

trouble with pygame in python version 3.3

I have successfully used pygame in the past, but now it won't work.
my source is
import pygame, sys
from pygame.locals import *
pygame.init()
DISPLAYSURF = pygame.display.set_mode((400, 300))
pygame.display.set_caption('Hello World!')
while True: # main game loop
for event in pygame.event.get():
if event.type == QUIT:
pygame.quit()
sys.exit()
pygame.display.update()
using this in the shell works fine and creates a pygame window, but it will not work when making a module. it says pygame is not a package.
You have two different versions of Python installed (Python(x,y) and the python.org version), and pygame is only installed on one of them. When you run the interpreter through IDLE or the command line for the version that has pygame associated with you, you can import pygame and use it just fine. However, in Windows Explorer, .py files are associated with the other version of Python, that does not have pygame installed, so when you try to run a file by double-clicking on it the wrong Python interpreter starts, and it can't import pygame because it's not installed for that version.
To fix this, all you need to do is re-associate .py files with the correct version of Python. Right-click on a .py file, select Properties, and in the dialog box that comes up find where it says something like "Opens with:" and click the Change button. Browse to C:\Python33 and select python.exe, and you should be all set. Make sure the option "Always use the selected program to open this kind of file" is set, then click OK.
I'm on XP right now, so the process might be slightly different depending on which version of Windows you're running, but it should be fairly similar.

How to make PyQt App give up window focus?

I have a python command line script that starts a PyQt Application showing the input of the video device in a little window. Then it starts a curses screen so that the user can control the camera with the keyboard.
After starting the script, the window focus is automatically on the PyQt window. Is there any way to tell PyQt to give up the window focus or curses / the terminal to reclaim it?
I use Linux (Mint Cinnamon) and the solution does not have to be OS independent.
You can try with setFocusPolicy here is the documentation. http://pyqt.sourceforge.net/Docs/PyQt4/qwidget.html#setFocusPolicy

Categories