hook-ttkthemes.py 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. # ------------------------------------------------------------------
  2. # Copyright (c) 2020 PyInstaller Development Team.
  3. #
  4. # This file is distributed under the terms of the GNU General Public
  5. # License (version 2.0 or later).
  6. #
  7. # The full license is available in LICENSE, distributed with
  8. # this software.
  9. #
  10. # SPDX-License-Identifier: GPL-2.0-or-later
  11. # ------------------------------------------------------------------
  12. """
  13. Hook for use with the ttkthemes package
  14. ttkthemes depends on a large set of image and Tcl-code files contained
  15. within its package directory. These are not imported, and thus this hook
  16. is required so they are copied.
  17. The file structure of the ttkthemes package folder is:
  18. ttkthemes
  19. ├───advanced
  20. | └───*.tcl
  21. ├───themes
  22. | ├───theme1
  23. | | ├───theme1
  24. | | | └───*.gif
  25. | | └───theme1.tcl
  26. | ├───theme2
  27. | ├───...
  28. | └───pkgIndex.tcl
  29. ├───png
  30. └───gif
  31. The ``themes`` directory contains themes which only have a universal
  32. image version (either base64 encoded in the theme files or GIF), while
  33. ``png`` and ``gif`` contain the PNG and GIF versions of the themes which
  34. support both respectively.
  35. All of this must be copied, as the package expects all the data to be
  36. present and only checks what themes to load at runtime.
  37. Tested hook on Linux (Ubuntu 18.04, Python 3.6 minimal venv) and on
  38. Windows 7 (Python 3.7, minimal system-wide installation).
  39. >>> from tkinter import ttk
  40. >>> from ttkthemes import ThemedTk
  41. >>>
  42. >>>
  43. >>> if __name__ == '__main__':
  44. >>> window = ThemedTk(theme="plastik")
  45. >>> ttk.Button(window, text="Quit", command=window.destroy).pack()
  46. >>> window.mainloop()
  47. """
  48. from PyInstaller.utils.hooks import collect_data_files
  49. datas = collect_data_files("ttkthemes")