I want to make an existing CLI application more user friendly with wxPython FileDialog. But on several machines running Windows 7, the console is slowly filled with blank lines (say: one line every minute - didn’t measure precisely) after a FileDialog has been created.
Below is a small piece of code that triggers the problem:
import msvcrt
import wx
if __name__ == '__main__':
print("Starting...")
app = wx.App()
openFileDialog = wx.FileDialog(None, message="Open a .tiff image", defaultFile="", wildcard="Tiff images (*.tiff)|*.tiff", style=wx.FD_OPEN | wx.DIALOG_NO_PARENT)
# after the call to ShowModal, extra lines in the console output appear every x seconds.
# Destroying the dialog or App does not solve the problem
print("Showing openFileDialog...")
openFileDialog.ShowModal()
print("Destroying openFileDialog...")
openFileDialog.Destroy()
openFileDialog = None
app.Destroy()
app = None
msvcrt.getch()
print("Exiting...")
Tested on 2 machines running Windows 10, and everything works just fine.
I’ve tried capturing sys.stdout, but the blank lines still appear. Capturing stdout via the file descriptor (https://eli.thegreenplace.net/2015/redirecting-all-kinds-of-stdout-in-python/) does work: the blank lines no longer appear.
So on this Windows 7 computer, something writes blank lines to the stdout file descriptor after a FileDialog has been created.
Is this a known problem ? Any ideas / tips on how to debug this ?
- Windows 7
- Python 3.7, 64-bit
- wxPython installed via pip