maliang.toolbox.utility¶
字数 9 个 阅读时间不到 1 分钟 访问量
源代码:maliang/toolbox/utility.py
Some useful utility classes or utility functions.
函数:
-
get_parent–Get the HWND of
tkinter.Widget. -
embed_window–Embed a widget into another widget.
-
load_font–Make fonts located in file
font_pathavailable to the font system, and -
screen_size–Returns the size of the screen.
-
get_text_size–Get the size of a text with a special font family and font size.
-
fix_cursor–Fix the cursor name.
-
create_smoke–Create a temporary smoke zone. Return the
enhanced.PhotoImage.
Trigger ¶
Trigger(command: collections.abc.Callable[..., typing.Any])
Single trigger.
It can only be triggered once before the reset, and multiple triggers are invalid. When triggered, the callback function is called.
command: the function that is called when triggered
方法:
-
get–Get the status of the trigger.
-
reset–Reset the status of the trigger.
-
lock–Lock the trigger so that it can’t be updated.
-
unlock–Unlock this trigger so that it can be updated again.
-
update–Update the status of the trigger.
get_parent ¶
Get the HWND of tkinter.Widget.
widget: the widget
embed_window ¶
Embed a widget into another widget.
window: Widget that will be embedded inparent: parent widget,Noneindicates that the parent widget is the screenfocus: whether direct input focus to this window
load_font ¶
Make fonts located in file font_path available to the font system, and return True if the operation succeeds, False otherwise.
font_path: the font file pathprivate: if True, other processes cannot see this font(Only Windows OS), and this font will be unloaded when the process diesenumerable: if True, this font will appear when enumerating fonts(Only Windows OS)
This function only works on Windows and Linux OS.
This function is referenced from customtkinter.FontManager.load_font, CustomTkinter: TomSchimansky/CustomTkinter.
get_text_size ¶
get_text_size(
text: str,
fontsize: int | None = None,
family: str | None = None,
*,
padding: int = 0,
master: tkinter.Canvas | virtual.Widget | None = None,
**kwargs
) -> tuple[int, int]
Get the size of a text with a special font family and font size.
text: the textfontsize: font size of the textfamily: font family of the textpadding: extra padding of the sizemaster: default canvas or widget providedkwargs: kwargs oftkinter.font.Font
This function only works when the fontsize is negative number!
create_smoke ¶
create_smoke(
size: tuple[int, int], *, color: str | tuple[int, int, int, int] = "#00000066"
) -> enhanced.PhotoImage
Create a temporary smoke zone. Return the enhanced.PhotoImage.
size: size of the smoke zonecolor: color of the smoke zone
This function need PIL to run.
About the “smoke”, see: fluent2.microsoft.design/material#smoke