0

I noticed using filedialog.askdirectory() creates two blank lines when it opens file explorer (see picture below). I've been looking into this for weeks and I can't figure out why this is happening. Is there a way to prevent these blank lines from being created?

enter image description here

#!/usr/bin/python3

import tkinter 
from  tkinter import filedialog

export_file_path = ""

#Export path for output file
def export_path():

    global export_file_path

    print("Before askdirectory() is called")
    is_empty = filedialog.askdirectory()
    print("After askdirectory() is called")

    if is_empty != '':

        export_file_path = is_empty.replace('/', '\\') 

export_path()
print(export_file_path)

input('PAUSE')
Andy Garcia
  • 79
  • 1
  • 10
  • Possible something windows-specific: can't reproduce on Ubuntu Linux 20.04 / Python 3.8.10 – Stanislav Ivanov Jul 12 '21 at 15:19
  • can't reproduce the issue either on Windows 8.1 / Python 3.8, it could be that there is something else in the full code that does this and not in this part of it or You have left out some parts out of this function, do You get the issue when running this small piece of code? – Matiiss Jul 12 '21 at 15:32
  • Cannot reproduce the issue on Windows 10 running Python 3.9.6. – acw1668 Jul 12 '21 at 15:38
  • @Matiiss I get this issue using the code I've posted. I'm using Python 3.9.5 on Windows 10 1909. – Andy Garcia Jul 12 '21 at 15:44
  • are You using the built in IDLE? it is built on tkinter too which may cause issues when running tkinter code, try running the code in terminal – Matiiss Jul 12 '21 at 15:52
  • I don't see the problem on OSX 11.4 with python 3.8.9 – Bryan Oakley Jul 12 '21 at 16:10
  • 1
    The problem is probably not tkinter or Python related at all. [Blank lines in console after using wxFileDialog on Windows](https://discuss.wxpython.org/t/blank-lines-in-console-after-using-wxfiledialog-on-windows/33027). – 8349697 Jul 12 '21 at 17:44

0 Answers0