MCPcopy Create free account
hub / github.com/RT-Thread/env-windows / test

Function test

tools/python-3.11.9-amd64/Lib/tkinter/filedialog.py:448–489  ·  view source on GitHub ↗

Simple test program.

()

Source from the content-addressed store, hash-verified

446# test stuff
447
448def test():
449 """Simple test program."""
450 root = Tk()
451 root.withdraw()
452 fd = LoadFileDialog(root)
453 loadfile = fd.go(key="test")
454 fd = SaveFileDialog(root)
455 savefile = fd.go(key="test")
456 print(loadfile, savefile)
457
458 # Since the file name may contain non-ASCII characters, we need
459 # to find an encoding that likely supports the file name, and
460 # displays correctly on the terminal.
461
462 # Start off with UTF-8
463 enc = "utf-8"
464 import sys
465
466 # See whether CODESET is defined
467 try:
468 import locale
469 locale.setlocale(locale.LC_ALL,'')
470 enc = locale.nl_langinfo(locale.CODESET)
471 except (ImportError, AttributeError):
472 pass
473
474 # dialog for opening files
475
476 openfilename=askopenfilename(filetypes=[("all files", "*")])
477 try:
478 fp=open(openfilename,"r")
479 fp.close()
480 except:
481 print("Could not open File: ")
482 print(sys.exc_info()[1])
483
484 print("open", openfilename.encode(enc))
485
486 # dialog for saving files
487
488 saveasfilename=asksaveasfilename()
489 print("saveas", saveasfilename.encode(enc))
490
491
492if __name__ == '__main__':

Callers 1

filedialog.pyFile · 0.70

Calls 10

TkClass · 0.90
LoadFileDialogClass · 0.85
SaveFileDialogClass · 0.85
askopenfilenameFunction · 0.85
asksaveasfilenameFunction · 0.85
printFunction · 0.50
openFunction · 0.50
goMethod · 0.45
closeMethod · 0.45
encodeMethod · 0.45

Tested by

no test coverage detected