tkFileDialog.askopenfilename()

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • rahulnag22@yahoo.com

    #1

    tkFileDialog.askopenfilename()

    Hi,
    When I call tkFileDialog.as kopenfilename() , the dialog box opens with
    the current directory as the default directory. Is it possible to open
    the dialog box with a directory other than the current directory. Can
    we pass in a user defined starting directory.
    Thanks
    Rahul

  • John McMonagle

    #2
    Re: {Possible_Spam} tkFileDialog.as kopenfilename()

    rahulnag22@yaho o.com wrote:
    Hi,
    When I call tkFileDialog.as kopenfilename() , the dialog box opens with
    the current directory as the default directory. Is it possible to open
    the dialog box with a directory other than the current directory. Can
    we pass in a user defined starting directory.
    Thanks
    Rahul
    >
    tkFileDialog.as kopenfilename() uses the tk command tk_getOpenFile, the
    documentation for which is at:



    Regards,

    John

    Comment

    • Kevin Walzer

      #3
      Re: tkFileDialog.as kopenfilename()

      rahulnag22@yaho o.com wrote:
      Hi,
      When I call tkFileDialog.as kopenfilename() , the dialog box opens with
      the current directory as the default directory. Is it possible to open
      the dialog box with a directory other than the current directory. Can
      we pass in a user defined starting directory.
      Thanks
      Rahul
      >
      Use the "initialdir " flag:

      filename = askopenfilename (title="Open File",
      initialdir=(os. path.expanduser ('~/'))

      HTH,
      Kevin
      --
      Kevin Walzer
      Code by Kevin

      Comment

      • martin.laloux@gmail.com

        #4
        Re: tkFileDialog.as kopenfilename()

        look at "Basic Tkinter dialogs" from python cookbook at



        Comment

        Working...