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 option is specified, it returns a list describing all of the available options for pathName (see Tk_ConfigureInfo for information on the format of this list).
  • if option is specified with no value, 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 no option is specified).
  • if one or more option-value pairs 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 🌈

(the frame family reunion, fr fr 🫢)


⭐ KEYWORDS ⭐

  • frame
  • widget

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