Skip to content

Modal Class

Construct a modal widget with the parent MASTER."

Parameters

NameTypeDescription
mastertkinter.Tk
bg_colorstr
titlebar_bg_colorstr
titlebar_fg_colorstr
delete_window_statestr
hitboxbool
padxint
padyint

Methods

moveto

Move the modal to a diffrent place. int the pos on the screen. CENTER center on the screen. None keep in the same pos.

Parameters

NameTypeDescription
xint
yint
errorbool

update

Update with widgets properties

show

Shows the modal

hide

Closes the modal

configure

winfo_height

winfo_width

winfo_x

winfo_y

bind

Bind to this widget at event SEQUENCE a call to function FUNC.

Parameters

NameTypeDescription
sequencestr
funcCallable
addbool

unbind

Unbind for this widget for event SEQUENCE the function identified with FUNCID.

Parameters

NameTypeDescription
sequencestr
funcidstr

wm_maxsize

Set max WIDTH and HEIGHT for this widget. If the window is gridded the values are given in grid units. Return the current values if None is given.

Parameters

NameTypeDescription
widthint
heightint

wm_minsize

Set min WIDTH and HEIGHT for this widget. If the window is gridded the values are given in grid units. Return the current values if None is given.

Parameters

NameTypeDescription
widthint
heightint

wm_geometry

Set geometry to NEWGEOMETRY of the form =widthxheight+x+y. Return current value if None is given.

Parameters

NameTypeDescription
newGeometrystr

wm_iconbitmap

Set bitmap for the iconified widget to BITMAP. Return the bitmap if None is given.

Parameters

NameTypeDescription
bitmapstr

wm_protocol

Bind function FUNC to command NAME for this widget. Return the function bound to NAME if None is given. NAME could be e.g. "WM_SAVE_YOURSELF" or "WM_DELETE_WINDOW".

Parameters

NameTypeDescription
namestr
funcCallable

wm_title

Set the title of this widget.

Parameters

NameTypeDescription
stringstr

focus_set

wm_overridedirect

Parameters

NameTypeDescription
booleanbool

destroy

Destroy this and all descendant widgets.

Example

py
import tkinter
import tkinterplus

root = tkinter.Tk()

modal = Modal(root)
tkinter.Label(modal, text='Hello World').pack()

tkinter.Button(root, text='Open Modal', command=modal.show).pack()
root.mainloop()

example-Modal

Not associated with or approved by Mojang Studios or Microsoft