maliang.theme¶
字数 11 个 阅读时间不到 1 分钟 访问量
A subpackage that provides theme-related features.
Listen to the system’s theme and respond accordingly, modify the style of the window, and more.
模块:
-
manager
–Support for theme
函数:
-
set_color_mode
–Set the color mode of the program
-
get_color_mode
–Get the color mode of the program.
-
register_event
–When the system accent color changes, the registered function will be
-
remove_event
–Remove a registered function.
-
apply_file_dnd
–Apply file drag and drop in a widget.
-
apply_theme
–Apply some Windows themes to the window.
-
customize_window
–Customize the relevant properties of the window
set_color_mode ¶
Set the color mode of the program
mode
: it can be"light"
,"dark"
, and"system"
TIP:
"system"
is the following system
get_color_mode ¶
Get the color mode of the program.
register_event ¶
When the system accent color changes, the registered function will be called, and the parameter is a boolean value indicating whether it is currently a dark theme.
func
: callback functionargs
: extra arguments
remove_event ¶
remove_event(func: collections.abc.Callable[..., typing.Any]) -> None
Remove a registered function.
func
: callback function
apply_file_dnd ¶
Apply file drag and drop in a widget.
window
: the window which being customizedcommand
: callback function, accept a parameter that represents the path of the file
This function is only works on Windows OS!
apply_theme ¶
apply_theme(
window: tkinter.Tk,
*,
theme: typing.Literal[
"mica",
"acrylic",
"acrylic2",
"aero",
"transparent",
"optimised",
"win7",
"inverse",
"native",
"popup",
"dark",
"normal",
]
) -> None
Apply some Windows themes to the window.
window
: the window which being customizedtheme
: different themes for windows
This function is only works on Windows OS! And some parameters are useless on Windows 7/10!
customize_window ¶
customize_window(
window: tkinter.Tk,
*,
border_color: str | None = None,
header_color: str | None = None,
title_color: str | None = None,
hide_title_bar: bool | None = None,
hide_button: typing.Literal["all", "maxmin", "none"] | None = None,
disable_minimize_button: bool | None = None,
disable_maximize_button: bool | None = None,
border_type: typing.Literal["rectangular", "smallround", "round"] | None = None
) -> None
Customize the relevant properties of the window
window
: the window which being customizedborder_color
: border color of the windowheader_color
: header color of the windowtitle_color
: title color of the windowhide_title_bar
: Wether hide the whole title barhide_button
: Wether hide part of buttons on title bardisable_minimize_button
: Wether disable minimize buttondisable_maximize_button
: Wether disable maximize buttonborder_type
: border type of the window
This function is only works on Windows OS! And some parameters are useless on Windows 7/10!