frame(3tk)
π frame(3tk) β the Tk Built-In Command that's just a cute lil box π
okay bestie, so this is frame from the 3tk manual section β one of Tk's Built-In Commands. it's the simplest, most unbothered widget in the whole toolkit and honestly? iconic. let's get into it. β¨
β¨ NAME β¨
frame β create and manipulate frame simple container widgets
no cap, that's the whole job description. it makes boxes. beautiful, humble boxes. π
πΈ SYNOPSIS πΈ
frame pathName ?options?
that's it. that's the whole summoning ritual. π
π STANDARD OPTIONS π
these are the standard ones, they come free with the widget:
-borderwidth-cursor-highlightbackground-highlightcolor-highlightthickness-padx-pady-relief-takefocus
lowkey important: go read the options manual entry for the deets on all these standard options, okay? i'm not gonna re-explain them here, that's their whole page's job. π«Ά
π¦ WIDGET-SPECIFIC OPTIONS π¦
these are the ones that are specifically frame's thing. the main character options, if you will. β
-backgroundβ Command-Line Name:-background, Database Name:background, Database Class:Background
this is the same as the standard -background option, except its value can also be an empty string. and if you do that? the widget displays no background and no border, and no colors get consumed from its colormap for its background and border. also, an empty background will disable drawing the background image. so like, truly nothing. ghost mode. π
-backgroundimageβ Command-Line Name:-backgroundimage, Database Name:backgroundImage, Database Class:BackgroundImage
this one specifies an image to display on the frame's background, within the border of the frame (meaning: the image gets clipped by the frame's highlight ring and border, if either are present). subwidgets of the frame get drawn on top. the image must have been created with the image create command β no random pngs, bestie. and if you specify it as the empty string, no image gets displayed. simple as. π
-classβ Command-Line Name:-class, Database Name:class, Database Class:Class
specifies a class for the window. this class gets used when querying the option database for the window's other options, and it also gets used later for other stuff like bindings. π¨ heads up: the -class option may not be changed with the configure widget command. it's set in stone fr fr.
-colormapβ Command-Line Name:-colormap, Database Name:colormap, Database Class:Colormap
specifies a colormap to use for the window. the value can be either new β in which case a new colormap is created for the window and its children β or the name of another window (which must be on the same screen and have the same visual as pathName), in which case the new window will use the colormap from that specified window. if you don't specify -colormap at all, the new window just uses the same colormap as its parent. and again: this option may not be changed with the configure widget command. π
-containerβ Command-Line Name:-container, Database Name:container, Database Class:Container
the value must be a boolean. if true, it means this window will be used as a container in which some other application will be embedded (for example, a Tk toplevel can be embedded using the -use option). the window will support the appropriate window manager protocols for things like geometry requests. the window should not have any children of its own in this application. this option may not be changed with the configure widget command. and note that -borderwidth, -padx and -pady are ignored when configured as a container, since a container has no border. it's giving minimalist. π
-heightβ Command-Line Name:-height, Database Name:height, Database Class:Height
specifies the desired height for the window, in any of the forms acceptable to Tk_GetPixels. if this option is negative or zero, then the window will not request any size at all. note that this sets the total height of the frame β any -borderwidth or similar is not added. and normally you should not use -height if a propagating geometry manager, such as grid or pack, is used within the frame, because the geometry manager will override the height of the frame. it's a whole power struggle and the geometry manager wins. π
-tileβ Command-Line Name:-tile, Database Name:tile, Database Class:Tile
this specifies how to draw the background image (see -backgroundimage) on the frame. if true (according to Tcl_GetBoolean), the image will be tiled to fill the whole frame, with the origin of the first copy of the image being the top left of the interior of the frame. if false (the default), the image will be centered within the frame. centered is the vibe check default. π§
-visualβ Command-Line Name:-visual, Database Name:visual, Database Class:Visual
specifies visual information for the new window, in any of the forms accepted by Tk_GetVisual. if this option is not specified, the new window will use the same visual as its parent. the -visual option may not be modified with the configure widget command. (spot the pattern yet? π)
-widthβ Command-Line Name:-width, Database Name:width, Database Class:Width
specifies the desired width for the window, in any of the forms acceptable to Tk_GetPixels. if this option is negative or zero, then the window will not request any size at all. note that this sets the total width of the frame β any -borderwidth or similar is not added. and normally you should not use -width if a propagating geometry manager, such as grid or pack, is used within the frame, since the geometry manager will override the width of the frame. same drama as -height, just horizontal. π
π DESCRIPTION π
the frame command creates a new window (given by the pathName argument) and makes it into a frame widget. additional options, described above, may be specified on the command line or in the option database, to configure aspects of the frame such as its background color and relief. the frame command returns the path name of the new window. π«Ά
a frame is a simple widget. its primary purpose is to act as a spacer or container for complex window layouts. the only features of a frame are its background and an optional 3-D border to make the frame appear raised or sunken.
literally that's it. no behavior, no drama, just vibes and geometry. it's the reliable bestie of the widget world. π
π WIDGET COMMAND π
the frame command creates a new Tcl command whose name is the same as the path name of the frame's window. this command may be used to invoke various operations on the widget. it has the following general form:
pathName option ?arg ...?
PathName is the name of the command, which is the same as the frame widget's path name. Option and the args determine the exact behavior of the command. the following commands are possible for frame widgets:
pathName cget option
returns the current value of the configuration option given by option. option may have any of the values accepted by the frame command. it's giving "tell me everything you're currently set to". β¨
pathName configure ?option? ?value option value ...?
query or modify the configuration options of the widget.
- if no
optionis specified, it returns a list describing all of the available options forpathName(seeTk_ConfigureInfofor information on the format of this list). - if
optionis specified with novalue, then the command returns a list describing the one named option (this list will be identical to the corresponding sublist of the value returned if nooptionis specified). - if one or more
option-valuepairs are specified, then the command modifies the given widget option(s) to have the given value(s); in this case the command returns an empty string.
option may have any of the values accepted by the frame command. so basically: ask questions, get answers, or give orders, get silence. π
π BINDINGS π
when a new frame is created, it has no default event bindings: frames are not intended to be interactive.
periodt. frames don't do anything. they're not clickable, they're not keyboard-y. they just are. don't expect them to respond to you. π
π SEE ALSO π
labelframe(3tk)toplevel(3tk)ttk::frame(3tk)
(the frame family reunion, fr fr π«Ά)
β KEYWORDS β
framewidget
and that's the whole page, bestie!! you now officially understand the humble little frame π
cute sign-off time: this page lives in Tk 8.4, and yeah, it's the frame(3tk) page β that's the one you just read. go build something with a whole bunch of nested frames in it. the layout will slay, i promise. π¦π
β¨
π¦ where this page comes from
- ubuntu resolute: tk9.0-doc 9.0.3-1
- ubuntu stonking: tk9.0-doc 9.0.4-1
- Copyright (c) 1990-1994 The Regents of the University of California
- Copyright (c) 1994-1996 Sun Microsystems, Inc
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms