I'm making my own chess GUI and am using python chess and stockfish for it. After freezing it into an executable, every time I call chess.engine.SimpleEngine.popen_uci('location\\of\\stockfish')
, it opens the shell for stockfish and if I close the shell, stockfish stops working. What do I do so that the shell is only running in the background and is not visible to the user?
Asked
Active
Viewed 1,014 times
1

IgnisNoctum
- 41
- 1
- 8
2 Answers
2
Expanding on @BoarGules answer:
engine = chess.engine.SimpleEngine.popen_uci(sf,startupinfo = subprocess.STARTUPINFO(dwFlags=subprocess.STARTF_USESHOWWINDOW))

ploy
- 21
- 1
1
This is a platform-specific question and I am guessing from 'location\\of\\stockfish'
that Windows is the platform you are interested in.
popen_uci
accepts a ** (extra keywords) parameter and you can use that to pass parameters through to subprocess.Popen()
. Use the passthrough parameter startupinfo
to provide an instance of subprocess.STARTUPINFO
. That in turn can set the win32 flag wShowWindow
to do what you want.

BoarGules
- 16,440
- 2
- 27
- 44
-
Yes I do use Windows 10. when i call `chess.engine.SimpleEngine.popen_uci('location\\of\\stockfish'startupinfo=subprocess.STARTUPINFO)`, Im getting the error TypeError: copy() missing 1 required positional argument: 'self' – IgnisNoctum Aug 15 '20 at 10:08