2

I am trying to write a script that parses data from a folder and prompts the user to choose the folder first using: tkFileDialog.askdirectory(initialdir=" //network/folder/", parent=root).

However, my data are on a network folder and I can not make the initial directory to show the network folder. Code:

root=Tkinter.Tk()
root.withdraw()
dirSelected = tkFileDialog.askdirectory(initialdir=" //network/folder/", parent=root)

The initial directory on the tk ask directory dialogue will show as "My Computer" instead. But if I copy and paste the address onto the tk ask directory dialogue, my code works and can parse the data from the network folder.

Is there any way I can make the initial directory to show as my network folder? So that I don't have to copy-paste the address every time.

gary
  • 4,227
  • 3
  • 31
  • 58
user1667145
  • 21
  • 1
  • 3

2 Answers2

1

if you are on windows you can use the os.system("net use e: \\fin\letters") command. to map it to a drive and use it e.g. under e:\

Hope this helps.

User
  • 14,131
  • 2
  • 40
  • 59
0

Similar to this answer, you should be able to get it to work if you use proper character escaping. For example, the following line works for me, although it seems the tkFileDialog window is slow to appear (perhaps it is due to my network, though).

dirSelected = tkFileDialog.askdirectory(initialdir='\\\\<HOST>\\<path>\\', parent=root)

For reference, you can read up on Escape Sequences here.

Community
  • 1
  • 1
gary
  • 4,227
  • 3
  • 31
  • 58
  • I still can't make the initial directory to be my network folder with the escaping. The only way I can access my network folder is to copy-paste the path to Windows->Start->Run, it can not be found anywhere else on the computer, does this change anything? – user1667145 Sep 14 '12 at 18:18
  • So you do not see the drive in windows explorer? Have you tried mapping the drive to a drive letter? – gary Sep 15 '12 at 11:53
  • 1
    Yes, I tried mapping the drive to a drive letter and it works :D I am just curious why it doesn't work if I use the askdirectory(initialdir= ) directly. Thank you very much for the help! – user1667145 Sep 17 '12 at 18:19