Reference 〉 Class

expandableFrame(parenttkinter.FrameNone, textstr'', fgstr'#333', bgstr'#FFF', padxint8, padyintNone, fonttuple(str,int)None, startOpenboolTrue)

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. If False, the frame is drawn collapsed initially.

    Default value: True


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 any Frame element.

    Initial value:

  • buttons dict{str: Btn}

    A dictionary with elements 'right' and 'left' containing two action buttons that can be placed on either side of the frame's title. Used in CheckGrids for the toggle-all button, for example.

    Initial value: dict{'left': Btn(), 'right': Btn()}

Notes and Examples

  1. charwick

    Jun 28, 2022 at 4:19

    Action buttons can be added to either side of the expandableFrame as follows:

    EF = expandableFrame(frame, text=param.title)
    def efAction():
    	#Do something here
    EF.buttons['right'].setup('→', efAction)

    This will place an arrow button on the right side of the expandable frame’s title that runs efAction().

  2. Contribute a Note

    Your email address will not be published. Required fields are marked *

    You may use limited HTML for formatting. Please embed blocks of code in <pre><code> </code></pre> tags.