Caillou
Caillou

Reputation: 11

filedialog using external initial directory

Is there a way to use an 'initialdir' option of tkinter filedialog to point an external directories? I see that it works fine for local lirectories (C:\Program Files...) but fails for something external (ftp://1.2.3.4 ...)

If not, do you have any alternatives for getting the file path from external ftp server using some GUI filedialog?

This is what I have now:

import tkinter as tk
from tkinter import *
from tkinter import filedialog as fd

root = tk.Tk()

def location():
    filename = fd.askopenfilename(initialdir = "ftp://1.2.3.4")
    print(filename)


b = Button(root, text="GetFile", command=location)
b.grid(column=0, row=15, sticky='EW')

root.mainloop()

Thanks!

Upvotes: 1

Views: 469

Answers (1)

scotty3785
scotty3785

Reputation: 7006

No. Not unless the underlying OS supports mounting an FTP as an external drive. The tkinter filedialog class uses the python OS module which doesn't directly support FTP.

You would have to write your own filedialog with FTP support or find one that someone has already written.

Upvotes: 1

Related Questions