()
Simple test program.
Simple test program.
Simple test program .
def test():
    """Simple test program."""
    root = Tk()
    root.withdraw()
    fd = LoadFileDialog(root)
    loadfile = fd.go(key="test")
    fd = SaveFileDialog(root)
    savefile = fd.go(key="test")
    print(loadfile, savefile)

    # Since the file name may contain non-ASCII characters, we need
    # to find an encoding that likely supports the file name, and
    # displays correctly on the terminal.

    # Start off with UTF-8
    enc = "utf-8"
    import sys

    # See whether CODESET is defined
    try:
        import locale
        locale.setlocale(locale.LC_ALL,'')
        enc = locale.nl_langinfo(locale.CODESET)
    except (ImportError, AttributeError):
        pass

    # dialog for opening files

    openfilename=askopenfilename(filetypes=[("all files", "*")])
    try:
        fp=open(openfilename,"r")
        fp.close()
    except:
        print("Could not open File: ")
        print(sys.exc_info()[1])

    print("open", openfilename.encode(enc))

    # dialog for saving files

    saveasfilename=asksaveasfilename()
    print("saveas", saveasfilename.encode(enc))
def test ( ) : root = Tk ( ) root . withdraw ( ) fd = LoadFileDialog ( root ) loadfile = fd . go ( key = "test" ) fd = SaveFileDialog ( root ) savefile = fd . go ( key = "test" ) print ( loadfile , savefile ) # Since the file name may contain non-ASCII characters, we need # to find an encoding that likely supports the file name, and # displays correctly on the terminal. # Start off with UTF-8 enc = "utf-8" import sys # See whether CODESET is defined try : import locale locale . setlocale ( locale . LC_ALL , '' ) enc = locale . nl_langinfo ( locale . CODESET ) except ( ImportError , AttributeError ) : pass # dialog for opening files openfilename = askopenfilename ( filetypes = [ ( "all files" , "*" ) ] ) try : fp = open ( openfilename , "r" ) fp . close ( ) except : print ( "Could not open File: " ) print ( sys . exc_info ( ) [ 1 ] ) print ( "open" , openfilename . encode ( enc ) ) # dialog for saving files saveasfilename = asksaveasfilename ( ) print ( "saveas" , saveasfilename . encode ( enc ) )