Toplevel(n)
π Toplevel(n) β the glow-up guide π
okay so bestie, welcome to the manual page for Toplevel, straight outta [incr Tk]. This is the whole thing, no skips, no cap. π«Ά
β¨ NAME β¨
Toplevel β the base class for mega-widgets that live in a top-level window. π
πΈ INHERITANCE πΈ
itk::Archetype <- itk::Toplevel
so it's giving "Archetype is the parent, Toplevel is the baby that inherited everything and then added its own lil extras." π
π STANDARD OPTIONS π
backgroundcursor
for the deets on the standard options, go read the options manual entry β it's right there, iykyk.
π¦ WIDGET-SPECIFIC OPTIONS π¦
- Name:
title - Class:
Title - Command-Line Switch:
-title
Sets the title that the window manager displays in the title bar above the window. The default title is the null string.
literally the little text up top in the title bar, that's it, that's the whole vibe. default = empty string, no title, silence, ghost mode π»
π DESCRIPTION π
The Toplevel class inherits everything from the Archetype class, and adds a Tk toplevel called the "hull" component to represent the body of the mega-widget. the hull is the moment, the hull is the body, the hull is the main character. The window class name for the hull is set to the most-specific class name for the mega-widget. The protected variable itk_interior contains the window path name for the "hull" component. Derived classes specialize this widget by packing other widget components into the hull.
Since the hull for the Toplevel class is implemented with a Tk toplevel, mega-widgets in the Toplevel class have their own toplevel window. their OWN window, periodt. This class is used to create dialog boxes and other pop-up windows. πͺβ¨
π§ COMPONENTS π§
- Name:
hull - Class:
Toplevel
The "hull" component acts as the body for the entire mega-widget. Other components are packed into the hull to further specialize the widget.
hull = the body, the vessel, the container. everything else gets packed inside it like lil sisters sharing a room. π
π₯ EXAMPLE π₯
The following example implements a MessageInfo mega-widget. It creates a pop-up message that the user can dismiss by pushing the "Dismiss" button. a whole pop-up window from scratch, we love to see it. π
option add *MessageInfo.title "Notice" widgetDefault
itcl::class MessageInfo {
inherit itk::Toplevel
constructor {args} {
itk_component add dismiss {
button $itk_interior.dismiss -text "Dismiss" -command "destroy $itk_component(hull)"
}
pack $itk_component(dismiss) -side bottom -pady 4
itk_component add separator {
frame $itk_interior.sep -height 2 -borderwidth 1 -relief sunken
}
pack $itk_component(separator) -side bottom -fill x -padx 4
itk_component add icon {
label $itk_interior.icon -bitmap info
}
pack $itk_component(icon) -side left -padx 8 -pady 8
itk_component add infoFrame {
frame $itk_interior.info
}
pack $itk_component(infoFrame) -side left -expand yes -fill both -padx 4 -pady 4
itk_component add message {
label $itk_interior.mesg -width 20
} {
usual
rename -text -message message Text
}
pack $itk_component(message) -expand yes -fill both
eval itk_initialize $args
after idle [code $this centerOnScreen]
}
protected method centerOnScreen {} {
update idletasks
set wd [winfo reqwidth $itk_component(hull)]
set ht [winfo reqheight $itk_component(hull)]
set x [expr ([winfo screenwidth $itk_component(hull)]-$wd)/2]
set y [expr ([winfo screenheight $itk_component(hull)]-$ht)/2]
wm geometry $itk_component(hull) +$x+$y
}
}
itk::usual MessageInfo {
keep -background -cursor -foreground -font
keep -activebackground -activeforeground -disabledforeground
keep -highlightcolor -highlightthickness
}
#
# EXAMPLE: Create a notice window:
#
MessageInfo .m -message "File not found:\n/usr/local/bin/foo"
not me reading this and being like "the after idle [code $this centerOnScreen] is so real" β centering yourself on screen is literally self-care. π«Ά
β KEYWORDS β
itk, Archetype, Widget, mega-widget
k bye bestie, that's the whole page!! this one came from itk version 3.0 and it's the Toplevel(n) page, mwah π stay iconic, go build a pop-up window or something. ππβ¨
π¦ where this page comes from
- fedora 43: itk 4.2.3-1.fc43 Β· TCL
- fedora 44: itk 4.2.3-1.fc44 Β· TCL
- Copyright (c) 1993-1998 Lucent Technologies, Inc
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms