iwidgets::messagebox(1)

πŸ’Œ iwidgets::messagebox β€” the [incr Widgets] era, bestie edition

okay so you found the iwidgets::messagebox page, welcome, pull up a chair, we're doing this πŸ’…


🌸 NAME 🌸

iwidgets::messagebox β€” bestie, it creates and manipulates a messagebox text widget. that's the whole vibe. a text widget that shows messages. iconic.


✨ SYNOPSIS ✨

iwidgets::messagebox pathName ?options?

that's it. that's the summoning ritual 🫢


🧬 INHERITANCE 🧬

the family tree goes like this, no cap:

itk::Widget  <-  iwidgets::Labeledwidget  <- iwidgets::Scrolledwidget <-
iwidgets::Messagebox

so it inherited the whole bloodline: itk::Widget, then iwidgets::Labeledwidget, then iwidgets::Scrolledwidget, and finally iwidgets::Messagebox itself. main character energy from every ancestor πŸ’œ


⭐ STANDARD OPTIONS ⭐

these are the classics, the standard-issue glow-up options:

  • activeBackground
  • activeForeground
  • background
  • borderWidth
  • cursor
  • exportSelection
  • font
  • foreground
  • highlightColor
  • highlightThickness
  • padX
  • padY
  • relief
  • setGrid
if you want the tea on what each one actually does, go read the "options" manual entry, bestie. it's all in there.

πŸŽ€ ASSOCIATED OPTIONS πŸŽ€

these come from its friends. group project, but make it fashion:

from the labeledwidget class β€” go read the "labeledwidget" class manual entry for the details:

  • labelBitmap
  • labelFont
  • labelImage
  • labelMargin
  • labelPos
  • labelText
  • labelVariable

from the scrollbar widget β€” details live in the "scrollbar" widget manual entry:

  • activeRelief
  • elementBorderWidth
  • jumptroughColor

from the scrolledtext widget β€” details are in the "scrolledtext" widget manual entry:

  • height
  • hscrollMode
  • sbWidth
  • scrollMargin
  • textBackground
  • visibleItems
  • vscrollMode
  • width

from the text widget β€” and the "text" widget manual entry has the receipts for these:

  • spacing1
  • spacing2
  • spacing3

πŸ‘‘ WIDGET-SPECIFIC OPTIONS πŸ‘‘

these are the ones that are hers, okay? homegrown, one of a kind πŸ’–

  • Name: fileName / Class: FileName / Command-Line Switch: -filename β€” specifies the filename to be displayed in the file selection dialog when it pops up during a save of the messagebox contents operation. so when you go to save, this is the name it's already got typed in there. thoughtful fr fr.
  • Name: maxLines / Class: MaxLines / Command-Line Switch: -maxlines β€” specifies the maximum number of lines allowed in the text area of the messagebox. when this limit is reached, the oldest line will be deleted such that the total number of lines remains maxlines. it's giving "we're at capacity, grandma's leaving" 😭
  • Name: saveDir / Class: SaveDir / Command-Line Switch: -savedir β€” specifies the default directory to display when the file selection dialog pops up during a save of the messagebox contents operation. and if this parameter is not specified, then the files in the current working directory are displayed. default behavior, we love her.

🌈 DESCRIPTION 🌈

so the iwidgets::messagebox command creates a scrolled information messages area widget. a whole little zone for your messages, scrollable, chef's kiss.

message types can be user defined and configured β€” you're the designer, you're the creative director. their options include foreground, background, font, bell, and their display mode of on or off. which means message types can be defined as needed, removed when no longer so, and modified when necessary. flexible queen πŸ¦‹ and there's an export method provided for file I/O, because of course.

the number of lines displayed may be limited, with the default being 1000. when this limit is reached, the oldest line is removed. (rip to that line, you served well 🫑)

there's a popup menu that appears when the right mouse button has been pressed in the message area, and it's already predefined for you. its contents by default support clearing the area and saving its contents to a file. additional operations may be defined, or existing operations removed, by using the component command to access the popup menu. customize away, bestie.


πŸ’¬ MESSAGE TYPES πŸ’¬

the display characteristics of messages issued to the messagebox vary with the message type. types are defined by the user, and they may be added, removed, and configured. the options of the message type that control the display include the following:

  • -background color β€” color specifies the background color to use for characters associated with the message type. it may have any of the forms accepted by Tk_GetColor. paint it, girl 🎨
  • -bell boolean β€” specifies whether or not to ring the bell whenever a message of this type is issued. boolean may have any of the forms accepted by Tk_GetBoolean. the default is 0. (so no, it does not go ding by default, you have to ask for the ding πŸ””)
  • -font fontName β€” fontName is the name of a font to use for drawing characters. it may have any of the forms accepted by Tk_GetFontStruct. pick your typography, it matters ✨
  • -foreground color β€” color specifies the foreground color to use for characters associated with the message type. it may have any of the forms accepted by Tk_GetColor. the text itself. the lewk.
  • -show boolean β€” specifies whether or not to display this message type when issued. boolean may have any of the forms accepted by Tk_GetBoolean. the default is 1. (so yes, by default it SHOWS. she's not shy πŸ’…)

πŸ› οΈ METHODS πŸ› οΈ

the iwidgets::messagebox command creates a new Tcl command whose name is pathName. this command may be used to invoke various operations on the widget. it has the following general form:

pathName option ?arg arg ...?

option and the args determine the exact behavior of the command. and the following commands are possible for messagebox widgets:


🫢 WIDGET-SPECIFIC METHODS 🫢

  • pathName cget option β€” returns the current value of the configuration option given by option. option may have any of the values accepted by the iwidgets::messagebox command.
  • pathName clear β€” clear the messagebox of all messages. boom, empty, fresh start, clean slate 🧼
  • pathName export filename β€” write text to a file. if filename exists then contents are replaced with text widget contents. > ⚠️ heads up: it replaces what's already in that file. no undo, bestie. be sure.
  • 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 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 iwidgets::messagebox command.
  • pathName type option msgtype ?arg arg ...? β€” this command is used to manipulate message types. the behavior of the command depends on the option argument that follows the type keyword. the following forms of the command are supported:
    • pathName type add msgtype ?option value ...? β€” adds a new message type given by msgtype with the display properties defined by the option value pairs. see MESSAGE TYPES for information on the options that are supported. new type just dropped πŸ”₯
    • pathName type cget msgtype option β€” returns the value of a configuration option for a message type. msgtype identifies the message type, and option specifies a particular configuration option, which must be one of the ones listed in the section MESSAGE TYPES.
    • pathName type configure msgtype ?option value ...? β€” query or modify the configuration options for a message type. if no option is specified, returns a list describing all of the available options for the message type msgtype. if option is specified with no value, then the command returns a list describing the one named option. if one or more option-value pairs are specified, then the command modifies the given option(s) to have the given value(s); in this case the command returns an empty string. see MESSAGE TYPES for information on the options that are supported.
    • pathName type remove msgtype β€” removes an existing message type given by msgtype. gone, deleted, blocked, unfollowed πŸ’€
  • pathName issue string ?level? ?tags? β€” print a string to the text area at the given level and with any additional tags specified. this is the one you'll be calling the most, fr fr.

🧩 COMPONENTS 🧩

  • Name: itemMenu / Class: Menu β€” this is the popup menu that gets displayed when you right-click in the text area of the messagebox. its contents may be modified via the component command. right-click rights πŸ’…
  • Name: text / Class: Scrolledtext β€” the text component is the scrolledtext widget. see the "scrolledtext" widget manual entry for details on the text component item.

🌟 EXAMPLE 🌟

steal this, it's cute:

package require Iwidgets 4.0
iwidgets::messagebox .mb -hscrollmode dynamic \
   -labeltext "Messages" -labelpos n \
   -height 120 -width 550 -savedir "/tmp" -textbackground #d9d9d9

pack .mb -padx 5 -pady 5 -fill both -expand yes

.mb type add ERROR -background red -foreground white -bell 1
.mb type add WARNING -background yellow -foreground black
.mb type add INFO -background white -foreground black

.mb issue "This is an error message in red with a beep" ERROR
.mb issue "This warning message in yellow" WARNING
.mb issue "This is an informational message" INFO

see? three whole message types, each with its own outfit, and then you just issue them into existence. slay πŸŽ€


πŸ‘©πŸ’» AUTHOR πŸ‘©πŸ’»

Alfredo Jahn V and Mark L. Ulferts β€” the icons who wrote this. thank you for your service 🫢


πŸ”‘ KEYWORDS πŸ”‘

messagebox, scrolledtext, text, widget


and that's the page, bestie! this came out of the Tk source, and it's the iwidgets::messagebox(1) manual entry β€” so go forth, make your messages pretty, and remember: if you're saving over a file, that's on you πŸ’– bye!! 🌸✨

πŸ“¦ where this page comes from