tkintertools.core.containers¶
字数 876 个 代码 168 行 阅读时间 5 分钟 访问量
All container widgets
There are two container widgets at the window level: Tk
and Toplevel
. Tk
is generally used for the main window, while Toplevel
is a pop-up window.
There are two container widgets at the canvas level: Canvas
and Frame
. Canvas
is the main widget carrier in tkintertools, and Frame
is similar to Canvas
, but with a different default color. Frame
is generally used for layout.
🟢Canvas
¶
class
public
| Canvas
Scalable Canvas
The parent widget of all virtual widgets of tkintertools is Canvas
master
: parent widgetexpand
: the mode of expand,x
is horizontal, andy
is verticalzoom_item
: whether or not to scale its itemskeep_ratio
: the mode of aspect ratio,min
follows the minimum value,max
follows the maximum valuefree_anchor
: whether the anchor point is free-floatingkwargs
: compatible with other parameters of classtkinter.Canvas
🟡_click
¶
method
protected
🟡_copy
¶
method
protected
🟡_cut
¶
method
protected
🟡_initialization
¶
method
protected
🟡_input
¶
method
protected
🟡_move
¶
method
protected
🟡_paste
¶
method
protected
🟡_re_place
¶
method
protected
Resize and position the Canvas
based on the relevant parameters
WARNING:
This method only works for Canvas with Place layout
🟡_release
¶
method
protected
🟡_select_all
¶
method
protected
🟡_theme
¶
method
protected
Change the color theme of the Canvas and its items
dark
: whether it is in dark mode
🟡_wheel
¶
method
protected
🟡_zoom_children
¶
method
protected
🟡_zoom_self
¶
method
protected
Canvas
itself 🟡clear
¶
method
public
🟡create_text
¶
method
public
🟡destroy
¶
method
public
🟢Frame
¶
class
public
| Canvas
master
: parent widgetexpand
: the mode of expand,x
is horizontal, andy
is verticalzoom_item
: whether or not to scale its itemskeep_ratio
: the mode of aspect ratio,min
follows the minimum value,max
follows the maximum valuefree_anchor
: whether the anchor point is free-floatingkwargs
: compatible with other parameters of classtkinter.Canvas
🟢Tk
¶
class
public
| Tk
Main window
In general, there is only one main window
size
: the size of the window, default value is 1280x720(px)position
: the position of the window, default value indicates that the location is randomtitle
: the title of the window, default value is an empty string**kwargs
: compatible with other parameters of classtkinter.Tk
🟡_fixed_theme
¶
method
protected
This is a decorator that to fix a problem that some methods cause the window to lose its theme
method
: the method of being decorated
🟡_theme
¶
method
protected
Change the color theme of the window
dark
: whether it is in dark modeinclude_children
: wether include its children, like Toplevelinclude_canvases
: wether include its canvases
🟡_wrap_method
¶
method
protected
🟡_zoom
¶
method
protected
🟡alpha
¶
method
public
Set or get the transparency of the window
value
: the transparency of the window, range is 0~1
🟡center
¶
method
public
Center the widget
master
: The area of the reference widget, if it is None, means that the reference area is the entire screen
🟡fullscreen
¶
method
public
Set or get whether the window is full-screen
value
: indicate whether the window is full-screen
TIPS:
The method should be called at the end of the code, or after some time after the program has started
🟡geometry
¶
method
public
Change the size and position of the window and return the current size and position of the window
size
: the size of the window, if it is None, does not change anythingposition
: the position of the window, if it is None, does not change anything
TIPS:
If you want to use tkinter.Tk.geometry
, please use tkinter.Tk.wm_geometry
instead
CAUTION:
This method causes the event <configure>
to be triggered
🟡shutdown
¶
method
public
Set a function that will be called when the window is closed
command
: the function that was calledensure_destroy
: whether the window is guaranteed to be closedargs
: the variable-length argument of the called functionkwargs
: the keyword argument of the function being called
TIPS:
Regardless of whether the function is successfully called or not, the window will still close gracefully
🟡toolwindow
¶
method
public
Set or get whether the window is tool-window
value
: indicate whether the window is tool-window
🟡topmost
¶
method
public
Set or get whether the window is pinned or not
value
: indicate whether the window is topmost
🟡transparentcolor
¶
method
public
Set or get the penetration color of the window
value
: the penetration color of the window
🟢Toplevel
¶
class
public
| Toplevel
Tk
Toplevel window
It can be used as a pop-up window, or it can be customized to put anything you want to show in it
master
: parent widgetsize
: the size of the window, default value is 960x540(px)position
: the position of the window, default value indicates that the location is randomtitle
: title of window, default is the same as title of mastergrab
: set grab for this windowfocus
: whether direct input focus to this window**kwargs
: compatible with other parameters of classtkinter.Toplevel
🟡destroy
¶
method
public