def get_open_filename(defaultfilename: str,
                      defaultextension: str,
                      title: str = "Open") -> str:
    """
    Provides a GUI "Open" dialogue (via ``tkinter``) and returns the filename.
    """
    root = tkinter.Tk()  # create and get Tk topmost window
    # (don't do this too early; the command prompt loses focus)
    root.withdraw()  # won't need this; this gets rid of a blank Tk window
    root.attributes('-topmost', True)  # makes the tk window topmost
    filename = filedialog.askopenfilename(
        initialfile=defaultfilename,
        defaultextension=defaultextension,
        parent=root,
        title=title
    )
    root.attributes('-topmost', False)  # stop the tk window being topmost
    return filename
def get_open_filename ( defaultfilename : str , defaultextension : str , title : str = "Open" ) -> str : root = tkinter . Tk ( ) root . withdraw ( ) root . attributes ( '-topmost' , True ) filename = filedialog . askopenfilename ( initialfile = defaultfilename , defaultextension = defaultextension , parent = root , title = title ) root . attributes ( '-topmost' , False ) return filename
Provides a GUI "Open" dialogue (via ``tkinter``) and returns the filename.