|
2 | 2 |
|
3 | 3 | import csv
|
4 | 4 | import tkinter as tk
|
| 5 | +from typing import Callable, List, Optional, TypedDict, Union |
5 | 6 |
|
6 | 7 | from .constants import ( # noqa: F401
|
7 | 8 | ICON_ADD,
|
@@ -376,3 +377,340 @@ def new_sheet_options() -> DotDict:
|
376 | 377 | "tooltip_hover_delay": 1200,
|
377 | 378 | }
|
378 | 379 | )
|
| 380 | + |
| 381 | + |
| 382 | +class SetOptions(TypedDict, total=False): |
| 383 | + # Colors |
| 384 | + popup_menu_fg: str |
| 385 | + popup_menu_bg: str |
| 386 | + popup_menu_highlight_bg: str |
| 387 | + popup_menu_highlight_fg: str |
| 388 | + index_hidden_rows_expander_bg: str |
| 389 | + header_hidden_columns_expander_bg: str |
| 390 | + header_bg: str |
| 391 | + header_border_fg: str |
| 392 | + header_grid_fg: str |
| 393 | + header_fg: str |
| 394 | + header_editor_bg: str |
| 395 | + header_editor_fg: str |
| 396 | + header_editor_select_bg: str |
| 397 | + header_editor_select_fg: str |
| 398 | + header_selected_cells_bg: str |
| 399 | + header_selected_cells_fg: str |
| 400 | + index_bg: str |
| 401 | + index_border_fg: str |
| 402 | + index_grid_fg: str |
| 403 | + index_fg: str |
| 404 | + index_editor_bg: str |
| 405 | + index_editor_fg: str |
| 406 | + index_editor_select_bg: str |
| 407 | + index_editor_select_fg: str |
| 408 | + index_selected_cells_bg: str |
| 409 | + index_selected_cells_fg: str |
| 410 | + top_left_bg: str |
| 411 | + top_left_fg: str |
| 412 | + top_left_fg_highlight: str |
| 413 | + table_bg: str |
| 414 | + table_grid_fg: str |
| 415 | + table_fg: str |
| 416 | + table_editor_bg: str |
| 417 | + table_editor_fg: str |
| 418 | + table_editor_select_bg: str |
| 419 | + table_editor_select_fg: str |
| 420 | + table_selected_box_cells_fg: str |
| 421 | + table_selected_box_rows_fg: str |
| 422 | + table_selected_box_columns_fg: str |
| 423 | + table_selected_cells_border_fg: str |
| 424 | + table_selected_cells_bg: str |
| 425 | + table_selected_cells_fg: str |
| 426 | + resizing_line_fg: str |
| 427 | + drag_and_drop_bg: str |
| 428 | + outline_color: str |
| 429 | + header_selected_columns_bg: str |
| 430 | + header_selected_columns_fg: str |
| 431 | + index_selected_rows_bg: str |
| 432 | + index_selected_rows_fg: str |
| 433 | + table_selected_rows_border_fg: str |
| 434 | + table_selected_rows_bg: str |
| 435 | + table_selected_rows_fg: str |
| 436 | + table_selected_columns_border_fg: str |
| 437 | + table_selected_columns_bg: str |
| 438 | + table_selected_columns_fg: str |
| 439 | + tree_arrow_fg: str |
| 440 | + selected_cells_tree_arrow_fg: str |
| 441 | + selected_rows_tree_arrow_fg: str |
| 442 | + vertical_scroll_background: str |
| 443 | + horizontal_scroll_background: str |
| 444 | + vertical_scroll_troughcolor: str |
| 445 | + horizontal_scroll_troughcolor: str |
| 446 | + vertical_scroll_lightcolor: str |
| 447 | + horizontal_scroll_lightcolor: str |
| 448 | + vertical_scroll_darkcolor: str |
| 449 | + horizontal_scroll_darkcolor: str |
| 450 | + vertical_scroll_relief: str |
| 451 | + horizontal_scroll_relief: str |
| 452 | + vertical_scroll_troughrelief: str |
| 453 | + horizontal_scroll_troughrelief: str |
| 454 | + vertical_scroll_bordercolor: str |
| 455 | + horizontal_scroll_bordercolor: str |
| 456 | + vertical_scroll_active_bg: str |
| 457 | + horizontal_scroll_active_bg: str |
| 458 | + vertical_scroll_not_active_bg: str |
| 459 | + horizontal_scroll_not_active_bg: str |
| 460 | + vertical_scroll_pressed_bg: str |
| 461 | + horizontal_scroll_pressed_bg: str |
| 462 | + vertical_scroll_active_fg: str |
| 463 | + horizontal_scroll_active_fg: str |
| 464 | + vertical_scroll_not_active_fg: str |
| 465 | + horizontal_scroll_not_active_fg: str |
| 466 | + vertical_scroll_pressed_fg: str |
| 467 | + horizontal_scroll_pressed_fg: str |
| 468 | + |
| 469 | + # Fonts |
| 470 | + popup_menu_font: FontTuple |
| 471 | + table_font: FontTuple |
| 472 | + header_font: FontTuple |
| 473 | + index_font: FontTuple |
| 474 | + |
| 475 | + # Edit menu items |
| 476 | + edit_header_label: str |
| 477 | + edit_header_accelerator: str |
| 478 | + edit_header_image: tk.PhotoImage |
| 479 | + edit_header_compound: str |
| 480 | + edit_index_label: str |
| 481 | + edit_index_accelerator: str |
| 482 | + edit_index_image: tk.PhotoImage |
| 483 | + edit_index_compound: str |
| 484 | + edit_cell_label: str |
| 485 | + edit_cell_accelerator: str |
| 486 | + edit_cell_image: tk.PhotoImage |
| 487 | + edit_cell_compound: str |
| 488 | + |
| 489 | + # Cut/copy/paste/delete |
| 490 | + cut_label: str |
| 491 | + cut_accelerator: str |
| 492 | + cut_image: tk.PhotoImage |
| 493 | + cut_compound: str |
| 494 | + copy_label: str |
| 495 | + copy_accelerator: str |
| 496 | + copy_image: tk.PhotoImage |
| 497 | + copy_compound: str |
| 498 | + copy_plain_label: str |
| 499 | + copy_plain_accelerator: str |
| 500 | + copy_plain_image: tk.PhotoImage |
| 501 | + copy_plain_compound: str |
| 502 | + paste_label: str |
| 503 | + paste_accelerator: str |
| 504 | + paste_image: tk.PhotoImage |
| 505 | + paste_compound: str |
| 506 | + delete_label: str |
| 507 | + delete_accelerator: str |
| 508 | + delete_image: tk.PhotoImage |
| 509 | + delete_compound: str |
| 510 | + clear_contents_label: str |
| 511 | + clear_contents_accelerator: str |
| 512 | + clear_contents_image: tk.PhotoImage |
| 513 | + clear_contents_compound: str |
| 514 | + |
| 515 | + # Column/row operations |
| 516 | + delete_columns_label: str |
| 517 | + delete_columns_accelerator: str |
| 518 | + delete_columns_image: tk.PhotoImage |
| 519 | + delete_columns_compound: str |
| 520 | + insert_columns_left_label: str |
| 521 | + insert_columns_left_accelerator: str |
| 522 | + insert_columns_left_image: tk.PhotoImage |
| 523 | + insert_columns_left_compound: str |
| 524 | + insert_columns_right_label: str |
| 525 | + insert_columns_right_accelerator: str |
| 526 | + insert_columns_right_image: tk.PhotoImage |
| 527 | + insert_columns_right_compound: str |
| 528 | + insert_column_label: str |
| 529 | + insert_column_accelerator: str |
| 530 | + insert_column_image: tk.PhotoImage |
| 531 | + insert_column_compound: str |
| 532 | + delete_rows_label: str |
| 533 | + delete_rows_accelerator: str |
| 534 | + delete_rows_image: tk.PhotoImage |
| 535 | + delete_rows_compound: str |
| 536 | + insert_rows_above_label: str |
| 537 | + insert_rows_above_accelerator: str |
| 538 | + insert_rows_above_image: tk.PhotoImage |
| 539 | + insert_rows_above_compound: str |
| 540 | + insert_rows_below_label: str |
| 541 | + insert_rows_below_accelerator: str |
| 542 | + insert_rows_below_image: tk.PhotoImage |
| 543 | + insert_rows_below_compound: str |
| 544 | + insert_row_label: str |
| 545 | + insert_row_accelerator: str |
| 546 | + insert_row_image: tk.PhotoImage |
| 547 | + insert_row_compound: str |
| 548 | + |
| 549 | + # Sorting |
| 550 | + sort_cells_label: str |
| 551 | + sort_cells_x_label: str |
| 552 | + sort_row_label: str |
| 553 | + sort_column_label: str |
| 554 | + sort_rows_label: str |
| 555 | + sort_columns_label: str |
| 556 | + sort_cells_reverse_label: str |
| 557 | + sort_cells_x_reverse_label: str |
| 558 | + sort_row_reverse_label: str |
| 559 | + sort_column_reverse_label: str |
| 560 | + sort_rows_reverse_label: str |
| 561 | + sort_columns_reverse_label: str |
| 562 | + sort_cells_accelerator: str |
| 563 | + sort_cells_x_accelerator: str |
| 564 | + sort_row_accelerator: str |
| 565 | + sort_column_accelerator: str |
| 566 | + sort_rows_accelerator: str |
| 567 | + sort_columns_accelerator: str |
| 568 | + sort_cells_reverse_accelerator: str |
| 569 | + sort_cells_x_reverse_accelerator: str |
| 570 | + sort_row_reverse_accelerator: str |
| 571 | + sort_column_reverse_accelerator: str |
| 572 | + sort_rows_reverse_accelerator: str |
| 573 | + sort_columns_reverse_accelerator: str |
| 574 | + sort_cells_image: tk.PhotoImage |
| 575 | + sort_cells_x_image: tk.PhotoImage |
| 576 | + sort_row_image: tk.PhotoImage |
| 577 | + sort_column_image: tk.PhotoImage |
| 578 | + sort_rows_image: tk.PhotoImage |
| 579 | + sort_columns_image: tk.PhotoImage |
| 580 | + sort_cells_compound: str |
| 581 | + sort_cells_x_compound: str |
| 582 | + sort_row_compound: str |
| 583 | + sort_column_compound: str |
| 584 | + sort_rows_compound: str |
| 585 | + sort_columns_compound: str |
| 586 | + sort_cells_reverse_image: tk.PhotoImage |
| 587 | + sort_cells_x_reverse_image: tk.PhotoImage |
| 588 | + sort_row_reverse_image: tk.PhotoImage |
| 589 | + sort_column_reverse_image: tk.PhotoImage |
| 590 | + sort_rows_reverse_image: tk.PhotoImage |
| 591 | + sort_columns_reverse_image: tk.PhotoImage |
| 592 | + sort_cells_reverse_compound: str |
| 593 | + sort_cells_x_reverse_compound: str |
| 594 | + sort_row_reverse_compound: str |
| 595 | + sort_column_reverse_compound: str |
| 596 | + sort_rows_reverse_compound: str |
| 597 | + sort_columns_reverse_compound: str |
| 598 | + |
| 599 | + # Select/undo/redo |
| 600 | + select_all_label: str |
| 601 | + select_all_accelerator: str |
| 602 | + select_all_image: tk.PhotoImage |
| 603 | + select_all_compound: str |
| 604 | + undo_label: str |
| 605 | + undo_accelerator: str |
| 606 | + undo_image: tk.PhotoImage |
| 607 | + undo_compound: str |
| 608 | + redo_label: str |
| 609 | + redo_accelerator: str |
| 610 | + redo_image: tk.PhotoImage |
| 611 | + redo_compound: str |
| 612 | + |
| 613 | + # Bindings |
| 614 | + rc_bindings: List[str] |
| 615 | + copy_bindings: List[str] |
| 616 | + copy_plain_bindings: List[str] |
| 617 | + cut_bindings: List[str] |
| 618 | + paste_bindings: List[str] |
| 619 | + undo_bindings: List[str] |
| 620 | + redo_bindings: List[str] |
| 621 | + delete_bindings: List[str] |
| 622 | + select_all_bindings: List[str] |
| 623 | + select_columns_bindings: List[str] |
| 624 | + select_rows_bindings: List[str] |
| 625 | + row_start_bindings: List[str] |
| 626 | + table_start_bindings: List[str] |
| 627 | + tab_bindings: List[str] |
| 628 | + up_bindings: List[str] |
| 629 | + right_bindings: List[str] |
| 630 | + down_bindings: List[str] |
| 631 | + left_bindings: List[str] |
| 632 | + shift_up_bindings: List[str] |
| 633 | + shift_right_bindings: List[str] |
| 634 | + shift_down_bindings: List[str] |
| 635 | + shift_left_bindings: List[str] |
| 636 | + prior_bindings: List[str] |
| 637 | + next_bindings: List[str] |
| 638 | + find_bindings: List[str] |
| 639 | + find_next_bindings: List[str] |
| 640 | + find_previous_bindings: List[str] |
| 641 | + toggle_replace_bindings: List[str] |
| 642 | + escape_bindings: List[str] |
| 643 | + |
| 644 | + # Scrollbar options |
| 645 | + vertical_scroll_borderwidth: int |
| 646 | + horizontal_scroll_borderwidth: int |
| 647 | + vertical_scroll_gripcount: int |
| 648 | + horizontal_scroll_gripcount: int |
| 649 | + vertical_scroll_arrowsize: Union[str, int] |
| 650 | + horizontal_scroll_arrowsize: Union[str, int] |
| 651 | + |
| 652 | + # Other options |
| 653 | + set_cell_sizes_on_zoom: bool |
| 654 | + auto_resize_columns: Optional[int] |
| 655 | + auto_resize_rows: Optional[int] |
| 656 | + to_clipboard_dialect: csv.Dialect |
| 657 | + to_clipboard_delimiter: str |
| 658 | + to_clipboard_quotechar: str |
| 659 | + to_clipboard_lineterminator: str |
| 660 | + from_clipboard_delimiters: Union[str, List[str]] |
| 661 | + show_dropdown_borders: bool |
| 662 | + show_default_header_for_empty: bool |
| 663 | + show_default_index_for_empty: bool |
| 664 | + default_header_height: str |
| 665 | + default_row_height: str |
| 666 | + default_column_width: int |
| 667 | + default_row_index_width: int |
| 668 | + default_row_index: str |
| 669 | + default_header: str |
| 670 | + page_up_down_select_row: bool |
| 671 | + paste_can_expand_x: bool |
| 672 | + paste_can_expand_y: bool |
| 673 | + paste_insert_column_limit: Optional[int] |
| 674 | + paste_insert_row_limit: Optional[int] |
| 675 | + arrow_key_down_right_scroll_page: bool |
| 676 | + cell_auto_resize_enabled: bool |
| 677 | + auto_resize_row_index: bool |
| 678 | + max_undos: int |
| 679 | + column_drag_and_drop_perform: bool |
| 680 | + row_drag_and_drop_perform: bool |
| 681 | + empty_horizontal: int |
| 682 | + empty_vertical: int |
| 683 | + horizontal_grid_to_end_of_window: bool |
| 684 | + vertical_grid_to_end_of_window: bool |
| 685 | + show_vertical_grid: bool |
| 686 | + show_horizontal_grid: bool |
| 687 | + display_selected_fg_over_highlights: bool |
| 688 | + show_selected_cells_border: bool |
| 689 | + edit_cell_tab: str |
| 690 | + edit_cell_return: str |
| 691 | + editor_del_key: str |
| 692 | + treeview: bool |
| 693 | + treeview_indent: str |
| 694 | + rounded_boxes: bool |
| 695 | + alternate_color: str |
| 696 | + allow_cell_overflow: bool |
| 697 | + table_wrap: str |
| 698 | + header_wrap: str |
| 699 | + index_wrap: str |
| 700 | + min_column_width: int |
| 701 | + max_column_width: float |
| 702 | + max_header_height: float |
| 703 | + max_row_height: float |
| 704 | + max_index_width: float |
| 705 | + show_top_left: Optional[bool] |
| 706 | + sort_key: Callable[[str], str] |
| 707 | + tooltips: bool |
| 708 | + user_can_create_notes: bool |
| 709 | + note_corners: bool |
| 710 | + tooltip_width: int |
| 711 | + tooltip_height: int |
| 712 | + tooltip_hover_delay: int |
| 713 | + |
| 714 | + # Additional keys not in the dict |
| 715 | + name: str |
| 716 | + outline_thickness: int |
0 commit comments