Simple test program.
()
| 446 | # test stuff |
| 447 | |
| 448 | def 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 | |
| 465 | # See whether CODESET is defined |
| 466 | try: |
| 467 | import locale |
| 468 | locale.setlocale(locale.LC_ALL,'') |
| 469 | enc = locale.nl_langinfo(locale.CODESET) |
| 470 | except (ImportError, AttributeError): |
| 471 | pass |
| 472 | |
| 473 | # dialog for opening files |
| 474 | |
| 475 | openfilename=askopenfilename(filetypes=[("all files", "*")]) |
| 476 | try: |
| 477 | fp=open(openfilename,"r") |
| 478 | fp.close() |
| 479 | except BaseException as exc: |
| 480 | print("Could not open File: ") |
| 481 | print(exc) |
| 482 | |
| 483 | print("open", openfilename.encode(enc)) |
| 484 | |
| 485 | # dialog for saving files |
| 486 | |
| 487 | saveasfilename=asksaveasfilename() |
| 488 | print("saveas", saveasfilename.encode(enc)) |
| 489 | |
| 490 | |
| 491 | if __name__ == '__main__': |
no test coverage detected
searching dependent graphs…