A container for GUI elements similar to tkinter.Frame
, but the contents are collapsible by clicking on the title. Used for sections of the control panel.
This class inherits from tkinter.Frame
and will contain all the methods and properties of that class as well. These are not listed here.
Initialization Parameters
parent — tkinter.Frame, optional
The Tkinter frame to which the expandable frame should be attached.
Default value: None
text — str, optional
The title of the frame, clickable to expand and collapse.
Default value: ''
fg — str, optional
A hex value for the text color.
Default value: '#333'
bg — str, optional
A hex value for the background color.
Default value: '#FFF'
padx — int, optional
The container frame's horizontal padding.
Default value: 8
pady — int, optional
The container frame's vertical padding.
Default value: None
font — tuple(str,int), optional
A font name/size pair.
Default value: None
startOpen — bool, optional
If
True
, the frame is drawn expanded initially. IfFalse
, the frame is drawn collapsed initially.Default value: True
Methods
Click a method name for more detailed documentation.
toggle( )
Expands a collapsed frame, and collapses an expanded frame.
Note that the function signature takes one optional argument, a Tkinter event string, in order to be used as a callback for a click event. This argument is not used in the function.
Object Properties
padx — int
The container frame's horizontal padding.
pady — int
The container frame's vertical padding.
text — str
The title of the expandable frame.
titleLabel — tkinter.Label
The Tkinter
Label
element corresponding to the clickable title.open — tkinter.IntVar
Whether the frame is expanded or collapsed. Setting this parameter will also open and close the frame.
Initial value: bool
subframe — tkinter.Frame
The Tkinter
Frame
element that gets expanded and collapsed. Can be interacted with and have elements placed into it like anyFrame
element.Initial value:
charwick
Jun 28, 2022 at 4:19Action buttons can be added to either side of the
expandableFrame
as follows:This will place an arrow button on the right side of the expandable frame’s title that runs
efAction()
.