__init__.py 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. __version__ = "5.2.2"
  2. import os
  3. import sys
  4. from tkinter import Variable, StringVar, IntVar, DoubleVar, BooleanVar
  5. from tkinter.constants import *
  6. import tkinter.filedialog as filedialog
  7. # import manager classes
  8. from .windows.widgets.appearance_mode import AppearanceModeTracker
  9. from .windows.widgets.font import FontManager
  10. from .windows.widgets.scaling import ScalingTracker
  11. from .windows.widgets.theme import ThemeManager
  12. from .windows.widgets.core_rendering import DrawEngine
  13. # import base widgets
  14. from .windows.widgets.core_rendering import CTkCanvas
  15. from .windows.widgets.core_widget_classes import CTkBaseClass
  16. # import widgets
  17. from .windows.widgets import CTkButton
  18. from .windows.widgets import CTkCheckBox
  19. from .windows.widgets import CTkComboBox
  20. from .windows.widgets import CTkEntry
  21. from .windows.widgets import CTkFrame
  22. from .windows.widgets import CTkLabel
  23. from .windows.widgets import CTkOptionMenu
  24. from .windows.widgets import CTkProgressBar
  25. from .windows.widgets import CTkRadioButton
  26. from .windows.widgets import CTkScrollbar
  27. from .windows.widgets import CTkSegmentedButton
  28. from .windows.widgets import CTkSlider
  29. from .windows.widgets import CTkSwitch
  30. from .windows.widgets import CTkTabview
  31. from .windows.widgets import CTkTextbox
  32. from .windows.widgets import CTkScrollableFrame
  33. # import windows
  34. from .windows import CTk
  35. from .windows import CTkToplevel
  36. from .windows import CTkInputDialog
  37. # import font classes
  38. from .windows.widgets.font import CTkFont
  39. # import image classes
  40. from .windows.widgets.image import CTkImage
  41. from .windows import ctk_tk
  42. _ = Variable, StringVar, IntVar, DoubleVar, BooleanVar, CENTER, filedialog # prevent IDE from removing unused imports
  43. def set_appearance_mode(mode_string: str):
  44. """ possible values: light, dark, system """
  45. AppearanceModeTracker.set_appearance_mode(mode_string)
  46. def get_appearance_mode() -> str:
  47. """ get current state of the appearance mode (light or dark) """
  48. if AppearanceModeTracker.appearance_mode == 0:
  49. return "Light"
  50. elif AppearanceModeTracker.appearance_mode == 1:
  51. return "Dark"
  52. def set_default_color_theme(color_string: str):
  53. """ set color theme or load custom theme file by passing the path """
  54. ThemeManager.load_theme(color_string)
  55. def set_widget_scaling(scaling_value: float):
  56. """ set scaling for the widget dimensions """
  57. ScalingTracker.set_widget_scaling(scaling_value)
  58. def set_window_scaling(scaling_value: float):
  59. """ set scaling for window dimensions """
  60. ScalingTracker.set_window_scaling(scaling_value)
  61. def deactivate_automatic_dpi_awareness():
  62. """ deactivate DPI awareness of current process (windll.shcore.SetProcessDpiAwareness(0)) """
  63. ScalingTracker.deactivate_automatic_dpi_awareness = True
  64. def set_ctk_parent_class(ctk_parent_class):
  65. ctk_tk.CTK_PARENT_CLASS = ctk_parent_class