fixed CTkDialog

This commit is contained in:
Tom Schimansky
2022-02-21 15:48:59 +01:00
parent 16859991eb
commit 356ed917be
3 changed files with 21 additions and 17 deletions

View File

@@ -19,7 +19,6 @@ from distutils.version import StrictVersion as Version
import tkinter
import os
import sys
from ctypes import windll, byref, create_unicode_buffer, create_string_buffer
def enable_macos_darkmode():
@@ -62,18 +61,21 @@ def set_default_color_theme(color_string):
CTkColorManager.initialize_color_theme(color_string)
FR_PRIVATE = 0x10
FR_NOT_ENUM = 0x20
if sys.platform.startswith("win"):
from ctypes import windll, byref, create_string_buffer
FR_PRIVATE = 0x10
FR_NOT_ENUM = 0x20
def loadfont(fontpath: str, private=True, enumerable=False):
pathbuf = create_string_buffer(bytes(fontpath, "utf-8"))
add_font_resource_ex = windll.gdi32.AddFontResourceExA
flags = (FR_PRIVATE if private else 0) | (FR_NOT_ENUM if not enumerable else 0)
num_fonts_added = add_font_resource_ex(byref(pathbuf), flags, 0)
return bool(num_fonts_added)
def loadfont(fontpath: str, private=True, enumerable=False):
pathbuf = create_string_buffer(bytes(fontpath, "utf-8"))
add_font_resource_ex = windll.gdi32.AddFontResourceExA
flags = (FR_PRIVATE if private else 0) | (FR_NOT_ENUM if not enumerable else 0)
num_fonts_added = add_font_resource_ex(byref(pathbuf), flags, 0)
return bool(num_fonts_added)
# load custom font for rendering circles on the tkinter.Canvas with antialiasing
script_directory = os.path.dirname(os.path.abspath(__file__))
loadfont(os.path.join(script_directory, "assets", "canvas_shapes_font.otf"), private=True)
# load custom font for rendering circles on the tkinter.Canvas with antialiasing
script_directory = os.path.dirname(os.path.abspath(__file__))
loadfont(os.path.join(script_directory, "assets", "canvas_shapes_font.otf"), private=True)