toplevel(n)

πŸ’– NAME πŸ’–

okay so welcome to the toplevel manual page, bestie β€” it's one of Tk's built-in commands, and it's literally the one that makes main and popup window widgets ✨


πŸ¦‹ SYNOPSIS πŸ¦‹

toplevel pathName ?options?

🌸 STANDARD OPTIONS 🌸

these are the classics, the standard-issue slay:

  • -borderwidth
  • -cursor
  • -highlightbackground
  • -highlightcolor
  • -highlightthickness
  • -padx
  • -pady
  • -relief
  • -takefocus

go check out the options manual entry for the tea on all the standard options πŸ’…


πŸŽ€ WIDGET-SPECIFIC OPTIONS πŸŽ€

these ones are hers and hers alone:

-background

  • Command-Line Name: -background
  • Database Name: background
  • Database Class: Background

same energy as the standard -background option, EXCEPT its value can also be an empty string πŸ‘€ if you do that, the widget displays no background or border at all, and no colors get consumed from its colormap for its background and border. also, an empty background will disable drawing the background image. periodt.

-backgroundimage

  • Command-Line Name: -backgroundimage
  • Database Name: backgroundImage
  • Database Class: BackgroundImage

this one picks an image to display on the toplevel's background, inside the border of the toplevel (i.e., the image gets clipped by the toplevel's highlight ring and border, if either are present) β€” and it sits on top of the background, with the toplevel's subwidgets drawn on top of it. the image must have been created with the image create command. if you set it to the empty string, no image shows up, no cap. πŸ–ΌοΈ

-class

  • Command-Line Name: -class
  • Database Name: class
  • Database Class: Class

sets a class for the window. that class gets used when querying the option database for the window's other options, and it also gets used later for other purposes like bindings. some window managers display the class name for windows in their dock, while some others display the window title instead. heads up tho: the -class option may not be changed with the configure widget command 🚫

-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 brand 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 uses the colormap from the specified window. if you don't specify -colormap, the new window just uses the default colormap of its screen. also: 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 is gonna 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 stuff like geometry requests. in this application, the window should not have any children of its own. and yes β€” this option may not be changed with the configure widget command πŸ“¦

-height

  • Command-Line Name: -height
  • Database Name: height
  • Database Class: Height

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 won't request any size at all. iconic honestly.

  • Command-Line Name: -menu
  • Database Name: menu
  • Database Class: Menu

specifies a menu widget to be used as a menubar. on the Macintosh, the menubar will be displayed across the top of the main monitor. on Microsoft Windows and all UNIX platforms, the menu will appear across the toplevel window as part of the window dressing maintained by the window manager πŸ”

-screen

  • Command-Line Name: -screen
  • Database Name:
  • Database Class:

specifies the screen on which to place the new window. any valid screen name works, even one associated with a different display. defaults to the same screen as its parent. this option is special, bestie: it may not be specified via the option database, and it may not be modified with the configure widget command πŸ–₯️

-tile

  • Command-Line Name: -tile
  • Database Name: tile
  • Database Class: Tile

this specifies how to draw the background image (see -backgroundimage) on the toplevel. if true (according to Tcl_GetBoolean), the image gets tiled to fill the whole toplevel, with the origin of the first copy of the image being the top left of the interior of the toplevel. if false (which is the default), the image gets centered within the toplevel. ✨

-use

  • Command-Line Name: -use
  • Database Name: use
  • Database Class: Use

this option is for embedding. if the value is not an empty string, it must be the window identifier of a container window, specified as a hexadecimal string like the ones returned by the winfo id command. the toplevel widget will be created as a child of the given container instead of the root window for the screen. if the container window is in a Tk application, it must be a frame or toplevel widget for which the -container option was specified. and ofc, this option may not be changed with the configure widget command 🫢

-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 isn't specified, the new window will use the default visual for its screen. the -visual option may not be modified with the configure widget command πŸ‘οΈ

-width

  • Command-Line Name: -width
  • Database Name: width
  • Database Class: Width

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 won't request any size at all. same energy as -height, fr fr.


🌈 DESCRIPTION 🌈

the toplevel command creates a new toplevel widget (given by the pathName argument). extra options β€” all the ones described above β€” can be specified on the command line or in the option database to configure aspects of the toplevel like its background color and relief. the toplevel command returns the path name of the new window. slay.

a toplevel is similar to a frame except that it's created as a top-level window: its X parent is the root window of a screen rather than the logical parent from its Tk path name. the primary purpose of a toplevel is to serve as a container for dialog boxes and other collections of widgets. the only visible features of a toplevel are its background and an optional 3-D border to make the toplevel appear raised or sunken. that's it. that's the whole look. minimalism ate πŸ’…


πŸ‘‘ WIDGET COMMAND πŸ‘‘

the toplevel command creates a new Tcl command whose name is the same as the path name of the toplevel's window. you use this command to invoke various operations on the widget. general form goes like this:

pathName option ?arg ...?

PathName is the name of the command, which is the same as the toplevel widget's path name. Option and the args determine the exact behavior of the command. the following commands are possible for toplevel 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 toplevel command.

pathName configure ?option? ?value option value ...?

query or modify the configuration options of the widget. if no option is specified, returns a list describing all of the available options for pathName (see Tk_ConfigureInfo for info on the format of this list). if option is specified with no value, then the command returns a list describing that 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) β€” and in that case the command returns an empty string. option may have any of the values accepted by the toplevel command.


🧚 BINDINGS 🧚

when a new toplevel is created, it has no default event bindings: toplevels are not intended to be interactive.

⚠️ real talk: be aware that bindings on toplevels may receive events from subwidgets. not a vibe check you want to fail, so keep that in mind πŸ’€

πŸ’œ SEE ALSO πŸ’œ


⭐ KEYWORDS ⭐

toplevel, widget


and that's the whole page, bestie πŸŽ€ this one came straight out of Tk 8.4, under the name toplevel(n) β€” go build something iconic with it 🫢✨

πŸ“¦ where this page comes from
  • fedora 43: tk 1:9.0.2-2.fc43 Β· TCL AND HPND-Pbmplus AND CC-BY-SA-3.0 AND MIT-open-group AND MIT
  • fedora 43: tk 1:9.0.2-2.fc43 Β· TCL AND HPND-Pbmplus AND CC-BY-SA-3.0 AND MIT-open-group AND MIT
  • fedora 44: tk 1:9.0.2-2.fc44 Β· TCL AND HPND-Pbmplus AND CC-BY-SA-3.0 AND MIT-open-group AND MIT
  • fedora 44: tk 1:9.0.2-2.fc44 Β· TCL AND HPND-Pbmplus AND CC-BY-SA-3.0 AND MIT-open-group AND MIT
  • πŸ’– girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms