I'm using PyCharm community edition to create a love2d application. I've created a hotkey that runs a .bat
file to run it with lovec.exe
which is opens the console as the app runs, then i've created an external tool
to run the .bat
file through a keyboard shortcut, when i use it, the console opens within PyCharm, which doesn't write anything, and after closing the app, everything that was meant to have been written appears, when i run the .bat
file outside of PyCharm it functions perfectly.
I would like to know if there's either an obvious fix to that or, just how to run the console outside of pycharm through an external tool.
This issue is due to the way Lua delays writing files, known as "buffering." To change it, put the following command at the top of your file:
io.stdout:setvbuf( 'no' ) -- Switches buffering for stdout to be off
Read more in Lua's manual:
file:setvbuf (mode [, size])
Sets the buffering mode for an output file. There are three available modes:
- "no": no buffering; the result of any output operation appears immediately.
- "full": full buffering; output operation is performed only when the buffer is full or when you explicitly
flush
the file (seeio.flush
).- "line": line buffering; output is buffered until a newline is output or there is any input from some special files (such as a terminal device).
For the last two cases,
size
specifies the size of the buffer, in bytes. The default is an appropriate size.