# -*- tcl -*- # Maintenance Instruction: leave the 999999.xxx.x as is and use punkshell 'dev make' or bin/punkmake to update from -buildversion.txt # module template: punkshell/src/decktemplates/vendor/punk/modules/template_module-0.0.3.tm # # Please consider using a BSD or MIT style license for greatest compatibility with the Tcl ecosystem. # Code using preferred Tcl licenses can be eligible for inclusion in Tcllib, Tklib and the punk package repository. # ++ +++ +++ +++ +++ +++ +++ +++ +++ +++ +++ # (C) 2025 # # @@ Meta Begin # Application punk::args::moduledoc::tkcore 999999.0a1.0 # Meta platform tcl # Meta license MIT # @@ Meta End # ++ +++ +++ +++ +++ +++ +++ +++ +++ +++ +++ # doctools header # ++ +++ +++ +++ +++ +++ +++ +++ +++ +++ +++ #*** !doctools #[manpage_begin punkshell_module_punk::args::moduledoc::tkcore 0 999999.0a1.0] #[copyright "2025"] #[titledesc {Module API}] [comment {-- Name section and table of contents description --}] #[moddesc {-}] [comment {-- Description at end of page heading --}] #[require punk::args::moduledoc::tkcore] #[keywords module] #[description] #[para] - # ++ +++ +++ +++ +++ +++ +++ +++ +++ +++ +++ #*** !doctools #[section Overview] #[para] overview of punk::args::moduledoc::tkcore #[subsection Concepts] #[para] - # ++ +++ +++ +++ +++ +++ +++ +++ +++ +++ +++ ## Requirements # ++ +++ +++ +++ +++ +++ +++ +++ +++ +++ +++ #*** !doctools #[subsection dependencies] #[para] packages used by punk::args::moduledoc::tkcore #[list_begin itemized] package require Tcl 8.6- package require punk::args package require punk::ansi package require textblock #*** !doctools #[item] [package {Tcl 8.6}] #[item] [package {punk::args}] #[item] [package {textblock}] #*** !doctools #[list_end] # ++ +++ +++ +++ +++ +++ +++ +++ +++ +++ +++ #*** !doctools #[section API] tcl::namespace::eval punk::args::moduledoc::tkcore { # ++ +++ +++ +++ +++ +++ +++ +++ +++ +++ +++ # Base namespace # ++ +++ +++ +++ +++ +++ +++ +++ +++ +++ +++ #*** !doctools #[subsection {Namespace punk::args::moduledoc::tkcore}] #[para] Core API functions for punk::args::moduledoc::tkcore #[list_begin definitions] tcl::namespace::export {[a-z]*} ;# Convention: export all lowercase set A_WARN \x1b\[7m set A_RST \x1b\[0m variable manbase variable manbase_ext set patch [info patchlevel] lassign [split $patch .] major if {$major < 9} { set manbase "https://tcl.tk/man/tcl/TkCmd" set manbase_ext .htm } else { set manbase "https://tcl.tk/man/tcl9.0/TkCmd" set manbase_ext .html } proc manpage {cmd} { variable manbase variable manbase_ext return ${manbase}/${cmd}${manbase_ext} } variable PUNKARGS namespace eval argdoc { tcl::namespace::import ::punk::ansi::a+ tcl::namespace::import ::punk::args::moduledoc::tkcore::manpage # -- --- --- --- --- #non colour SGR codes # we can use these directly via ${$I} etc without marking a definition with @dynamic #This is because they don't need to change when colour switched on and off. set I [a+ italic] set NI [a+ noitalic] set B [a+ bold] set N [a+ normal] set T [a+ bold underline] set NT [a+ normal nounderline] # -- --- --- --- --- namespace import ::punk::args::helpers::* #proc example {str} { # #sample override of punk::args::helpers::example (without highlighting and inner placeholder processing) # set str [string trimleft $str \n] # set block [punk::ansi::ansiwrap Web-gray [textblock::frame -ansibase [a+ Web-gray bold white] -ansiborder [a+ black White] -boxlimits {hl} -type block $str]] # set result [textblock::bookend_lines $block [a] "[a defaultbg] [a]"] # return $result #} } namespace eval argdoc { lappend PUNKARGS [list { @id -id "(default)::punk::args::moduledoc::tkcore::common" } "@doc -name Manpage: -url [manpage index]" ] #list all tk_standardoptions #use punk::args::resolved_spec #{${[punk::args::resolved_def -types opts (default)::punk::args::moduledoc::tkcore::tk_standardoptions -disabledforeground -font ...]}} ::punk::args::define { @id -id "(default)::punk::args::moduledoc::tkcore::tk_standardoptions" -activebackground -type colour -help\ "Specifies background color to use when drawing active elements. An element (a widget or portion of a widget) is active if the mouse cursor is positioned over the element and pressing a mouse button will cause some action to occur. If strict Motif compliance has been requested by setting the tk_strictMotif variable, this option will normally be ignored; the normal background color will be used instead. For some elements on Windows and Macintosh systems, the active color will only be used while mouse button 1 is pressed over the element." -activeborderwidth -type tk_screen_units -help\ "Specifies a non-negative value indicating the width of the 3-D border drawn around active elements. See above for definition of active elements. The value may have any of the forms acceptable to Tk_GetPixels. This option is typically only available in widgets displaying more than one element at a time (e.g. menus but not buttons)." -activeforeground -type colour -help\ "Specifies foreground color to use when drawing active elements. See above for definition of active elements." -activerelief -type string -choicecolumns 6 -choices {raised sunken flat ridge solid groove} -help\ "Specifies the 3-D effect desired for the active item of the widget. See the -relief option for details." -anchor -type string -choicecolumns 9 -choices {n ne e se s sw w nw center} -help\ "Specifies how the information in a widget (e.g. text or a bitmap) is to be displayed in the widget. For example, ${$B}nw${$N} means display the information such that its top-left corner is at the top-left corner of the widget." -background|-bg -type colour -help\ "Specifies the normal background color to use when displaying the widget." -bitmap -type bmp -help\ "Specifies a bitmap to display in the widget, in any of the forms acceptable to Tk_GetBitmap. The exact way in which the bitmap is displayed may be affected by other options such as -anchor or -justify. Typically, if this option is specified then it overrides other options that specify a textual value to display in the widget but this is controlled by the ${$B}-compound${$N} option; the -bitmap option may be reset to an empty string to re-enable a text display. In widgets that support both -bitmap and -image options, -image will usually override -bitmap." -borderwidth|-bd -type tk_screen_units -help\ "Specifies a non-negative value indicating the width of the 3-D border to draw around the outside of the widget (if such a border is being drawn; the -relief option typically determines this). The value may also be used when drawing 3-D effects in the interior of the widget. The value may have any of the forms acceptable to Tk_GetPixels." #todo - something better for large -choices lists #list of cursors is large, not obtainable dynamically, and has some that are platform specific. -cursor -type string -help\ "" -compound -type string -choicecolumns 6 -choices {none bottom top left right center} -help\ "Specifies if the widget should display text and bitmaps/images at the same time, and if so, where the bitmap/image should be placed relative to the text. Must be one of the values none, bottom, top, left, right, or center. For example, the (default) value none specifies that the bitmap or image should (if defined) be displayed instead of the text, the value ${$B}left${$N} specifies that the bitmap or image should be displayed to the left of the text, and the value ${$B}center${$N} specifies that the bitmap or image should be displayed on top of the text." -disabledforeground -type colour|literal() -help\ "Specifies foreground color to use when drawing a disabled element. If the option is specified as an empty string (which is typically the case on monochrome displays), disabled elements are drawn with the normal foreground color but they are dimmed by drawing them with a stippled fill pattern." -exportselection -type boolean -help\ "Specifies whether or not a selection in the widget should also be the X selection. The value may have any of the forms accepted by Tcl_GetBoolean, such as true, false, 0, 1, yes, or no. If the selection is exported, then selecting in the widget deselects the current X selection, selecting outside the widget deselects any widget selection, and the widget will respond to selection retrieval requests when it has a selection. The default is usually for widgets to export selections." -font -type tk_font -help\ "Specifies the font to use when drawing text inside the widget. The value may have any of the forms described in the font manual page under FONT DESCRIPTION." -foreground|-fg -type colour -help\ "Specifies the normal foreground color to use when displaying the widget." -highlightbackground -type colour -help\ "Specifies the color to display in the traversal highlight region when the widget does not have the input focus." -highlightcolor -type colour -help\ "Specifies the color to use for the traversal highlight rectangle that is drawn around the widget when it has the input focus." -highlightthicknes -type tk_screen_units -help\ "Specifies a non-negative value indicating the width of the highlight rectangle to draw around the outside of the widget when it has the input focus. The value may have any of the forms acceptable to Tk_GetPixels. If the value is zero, no focus highlight is drawn around the widget." -image -type string -help\ "Specifies an image to display in the widget, which must have been created with the image create command. Typically, if the -image option is specified then it overrides other options that specify a bitmap or textual value to display in the widget, though this is controlled by the -compound option; the -image option may be reset to an empty string to re-enable a bitmap or text display." -insertbackground -type colour -help\ "Specifies the color to use as background in the area covered by the insertion cursor. This color will normally override either the normal background for the widget (or the selection background if the insertion cursor happens to fall in the selection)." -insertborderwidth -type tk_screen_units -help\ "Specifies a non-negative value indicating the width of the 3-D border to draw around the insertion cursor. The value may have any of the forms acceptable to Tk_GetPixels." -insertofftime -type integer -typesynopsis {${$I}ms${$NI}} -range {0 ""} -help\ "Specifies a non-negative integer value indicating the number of milliseconds the insertion cursor should remain “off” in each blink cycle. If this option is zero then the cursor does not blink: it is on all the time." -insertontime -type integer -typesynopsis {${$I}ms${$NI}} -range {0 ""} -help\ "Specifies a non-negative integer value indicating the number of milliseconds the insertion cursor should remain “on” in each blink cycle." -insertwidth -type tk_screen_units -help\ "Specifies a non-negative value indicating the total width of the insertion cursor. The value may have any of the forms acceptable to Tk_GetPixels. If a border has been specified for the insertion cursor (using the -insertborderwidth option), the border will be drawn inside the width specified by the -insertwidth option." -jump -type boolean -help\ "For widgets with a slider that can be dragged to adjust a value, such as scrollbars, this option determines when notifications are made about changes in the value. The option's value must be a boolean of the form accepted by Tcl_GetBoolean. If the value is false, updates are made continuously as the slider is dragged. If the value is true, updates are delayed until the mouse button is released to end the drag; at that point a single notification is made (the value “jumps” rather than changing smoothly)." -justify -type string -choicecolumns 3 -choices {left center right} -help\ "When there are multiple lines of text displayed in a widget, this option determines how the lines line up with each other. Must be one of left, center, or right. Left means that the lines' left edges all line up, center means that the lines' centers are aligned, and right means that the lines' right edges line up." -orient -type string -choiceprefix 1 -choicecolumns 2 -choices {horizontal vertical} -help\ "For widgets that can lay themselves out with either a horizontal or vertical orientation, such as scrollbars, this option specifies which orientation should be used. Must be either horizontal or vertical or an abbreviation of one of these." -padx -type tk_screen_units -help\ "Specifies a non-negative value indicating how much extra space to request for the widget in the X-direction. The value may have any of the forms acceptable to Tk_GetPixels. When computing how large a window it needs, the widget will add this amount to the width it would normally need (as determined by the width of the things displayed in the widget); if the geometry manager can satisfy this request, the widget will end up with extra internal space to the left and/or right of what it displays inside. Most widgets only use this option for padding text: if they are displaying a bitmap or image, then they usually ignore padding options." -pady -type tk_screen_units -help\ "Specifies a non-negative value indicating how much extra space to request for the widget in the Y-direction. The value may have any of the forms acceptable to Tk_GetPixels. When computing how large a window it needs, the widget will add this amount to the height it would normally need (as determined by the height of the things displayed in the widget); if the geometry manager can satisfy this request, the widget will end up with extra internal space above and/or below what it displays inside. Most widgets only use this option for padding text: if they are displaying a bitmap or image, then they usually ignore padding options." -placeholder -type string -help\ "Specifies a help text string to display if no text is otherwise displayed, that is when the widget is empty. The placeholder text is displayed using the values of the -font and -justify options." -placeholderforeground -type colour -help\ "Specifies the foreground color to use when the placeholder text is displayed. The default color is platform-specific." -relief -type string -choicecolumns 6 -choices {raised sunken flat ridge solid groove} -help\ "Specifies the 3-D effect desired for the widget. Acceptable values are raised, sunken, flat, ridge, solid, and groove. The value indicates how the interior of the widget should appear relative to its exterior; for example, raised means the interior of the widget should appear to protrude from the screen, relative to the exterior of the widget." -repeatdelay -type integer -typesynopsis {${$I}ms${$NI}} -help\ "Specifies the number of milliseconds a button or key must be held down before it begins to auto-repeat. Used, for example, on the up- and down-arrows in scrollbars." -repeatinterval -type integer -typesynopsis {${$I}ms${$NI}} -help\ "Used in conjunction with -repeatdelay: once auto-repeat begins, this option determines the number of milliseconds between auto-repeats." -selectbackground -type colour -help\ "Specifies the background color to use when displaying selected items." -selectborderwidth -type tk_screen_units -help\ "Specifies a non-negative value indicating the width of the 3-D border to draw around selected items. The value may have any of the forms acceptable to Tk_GetPixels." -selectforeground -type colour -help\ "Specifies the foreground color to use when displaying selected items." -setgrid -type boolean -help\ "Specifies a boolean value that determines whether this widget controls the resizing grid for its top-level window. This option is typically used in text widgets, where the information in the widget has a natural size (the size of a character) and it makes sense for the window's dimensions to be integral numbers of these units. These natural window sizes form a grid. If the -setgrid option is set to true then the widget will communicate with the window manager so that when the user interactively resizes the top-level window that contains the widget, the dimensions of the window will be displayed to the user in grid units and the window size will be constrained to integral numbers of grid units. See the section GRIDDED GEOMETRY MANAGEMENT in the wm manual entry for more details." -takefocus -type literal(0)|literal(1)|literal() -help\ "Determines whether the window accepts the focus during keyboard traversal (e.g., Tab and Shift-Tab). Before setting the focus to a window, the traversal scripts consult the value of the -takefocus option. A value of 0 means that the window should be skipped entirely during keyboard traversal. 1 means that the window should receive the input focus as long as it is viewable (it and all of its ancestors are mapped). An empty value for the option means that the traversal scripts make the decision about whether or not to focus on the window: the current algorithm is to skip the window if it is disabled, if it has no key bindings, or if it is not viewable. If the value has any other form, then the traversal scripts take the value, append the name of the window to it (with a separator space), and evaluate the resulting string as a Tcl script. The script must return 0, 1, or an empty string: a 0 or 1 value specifies whether the window will receive the input focus, and an empty string results in the default decision described above. Note that this interpretation of the option is defined entirely by the Tcl scripts that implement traversal: the widget implementations ignore the option entirely, so you can change its meaning if you redefine the keyboard traversal scripts." -text -type string -help\ "Specifies a string to be displayed inside the widget. The way in which the string is displayed depends on the particular widget and may be determined by other options, such as -anchor or -justify." -textvariable -type string -help\ "Specifies the name of a global variable. The value of the variable is a text string to be displayed inside the widget; if the variable value changes then the widget will automatically update itself to reflect the new value. The way in which the string is displayed in the widget depends on the particular widget and may be determined by other options, such as -anchor or -justify." -troughcolor -type colour -help\ "Specifies the color to use for the rectangular trough areas in widgets such as scrollbars and scales. This option is ignored for scrollbars on Windows (native widget does not recognize this option)." -underline -type indexexpression -help\ "Specifies the integer index of a character to underline in the widget. This option is used by the default bindings to implement keyboard traversal for menu buttons and menu entries. 0 corresponds to the first character of the text displayed in the widget, 1 to the next character, and so on. end corresponds to the last character, end-1 to the before last character, and so on." -wraplength -type tk_screen_units -help\ "For widgets that can perform word-wrapping, this option specifies the maximum line length. Lines that would exceed this length are wrapped onto the next line, so that no line is longer than the specified length. The value may be specified in any of the standard forms for screen distances. If this value is negative or zero then no wrapping is done: lines will break only at newline characters in the text." -xscrollcommand -type list -typesynopsis {${$I}cmdprefix${$NI}} -help\ "Specifies the prefix for a command used to communicate with horizontal scrollbars. When the view in the widget's window changes (or whenever anything else occurs that could change the display in a scrollbar, such as a change in the total size of the widget's contents), the widget will generate a Tcl command by concatenating the scroll command and two numbers. Each of the numbers is a fraction between 0 and 1, which indicates a position in the document. 0 indicates the beginning of the document, 1 indicates the end, .333 indicates a position one third the way through the document, and so on. The first fraction indicates the first information in the document that is visible in the window, and the second fraction indicates the information just after the last portion that is visible. The command is then passed to the Tcl interpreter for execution. Typically the -xscrollcommand option consists of the path name of a scrollbar widget followed by “set”, e.g. “.x.scrollbar set”: this will cause the scrollbar to be updated whenever the view in the window changes. If this option is not specified, then no command will be executed." -yscrollcommand -type list -typesynopsis {${$I}cmdprefix${$NI}} -help\ "Specifies the prefix for a command used to communicate with vertical scrollbars. This option is treated in the same way as the -xscrollcommand option, except that it is used for vertical scrollbars and is provided by widgets that support vertical scrolling. See the description of -xscrollcommand for details on how this option is used." } "@doc -name Manpage: -url [manpage options]" # -- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- lappend PUNKARGS [list { @id -id ::bell @cmd -name "Tk Builtin: bell"\ -summary\ "Ring a display's bell."\ -help\ "This command rings the bell on the display for ${$I}window${$NI} and returns an empty string. If the ${$B}-displayof${$N} option is omitted, the display of the application's main window is used by default. The command uses the current bell-related settings for the display, which may be modified with programs such as ${$B}xset${$N}. If ${$B}-nice${$N} is not specified, this command also resets the screen saver for the screen. Some screen savers will ignore this, but others will reset so that the screen becomes visible again." @opts -displayof -type stringstartswith(.) -typesynopsis window -nice -type none @values -min 0 -max 0 } "@doc -name Manpage: -url [manpage bell]" ] # -- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- lappend PUNKARGS_aliases {::button ::tk::button} punk::args::define { @id -id ::tk::button @cmd -name "Tk Builtin: tk::button"\ -summary\ "Create and manipulate 'button' action widgets."\ -help\ "The ${$B}button${$N} command creates a new window (given by the ${$I}pathName${$NI} argument) and makes it into a button widget. Additional options, described above, may be specified on the command line or in the option database to configure aspects of the button such as its colors, font, text, and initial relief. The ${$B}button${$N} command returns its ${$I}pathName${$NI} argument. At the time this command is invoked, there must not exist a window named ${$I}pathName${$NI}, but ${$I}pathName${$NI}'s parent must exist. A button is a widget that displays a textual string, bitmap or image. If text is displayed, it must all be in a single font, but it can occupy multiple lines on the screen (if it contains newlines or if wrapping occurs because of the ${$B}-wraplength${$N} option) and one of the characters may optionally be underlined using the ${$B}-underline${$N} option. It can display itself in either of three different ways, according to the ${$B}-state${$N} option; it can be made to appear raised, sunken, or flat; and it can be made to flash. When a user invokes the button (by pressing mouse button 1 with the cursor over the button), then the Tcl command specified in the ${$B}-command${$N} option is invoked." @leaders pathName -type tk_path @opts -type string -parsekey "" -group "STANDARD OPTIONS" -grouphelp\ "" } { ${[punk::args::resolved_def -types opts (default)::punk::args::moduledoc::tkcore::tk_standardoptions\ -activebackground\ -activeforeground\ -anchor\ -background|-bg\ -bitmap\ -borderwidth|-bd\ -compound\ -cursor\ -disabledforeground\ -font\ -foreground|-fg\ -highlightbackground\ -highlightcolor\ -highlightthickness\ -image\ -justify\ -padx\ -pady\ -relief\ -takefocus\ -text\ -textvariable\ -underline\ -wraplength\ ]} } { @opts -type string -parsekey "" -group "WIDGET-SPECIFIC OPTIONS" -grouphelp\ "" -command -type script -help\ "Specifies a Tcl command to associate with the button. This command is typically invoked when mouse button 1 is released over the button window." -default -type string -choices {normal active disabled} -help\ "Specifies one of three states for the default ring: normal, active, or disabled. In active state, the button is drawn with the platform specific appearance for a default button. In normal state, the button is drawn with the platform specific appearance for a non-default button, leaving enough space to draw the default button appearance. The normal and active states will result in buttons of the same size. In disabled state, the button is drawn with the non-default button appearance without leaving space for the default appearance. The disabled state may result in a smaller button than the active state." -height -type tk_screen_units -help\ "Specifies a desired height for the button. If an image or bitmap is being displayed in the button then the value is in screen units (i.e. any of the forms acceptable to Tk_GetPixels); for text it is in lines of text. If this option is not specified, the button's desired height is computed from the size of the image or bitmap or text being displayed in it." -overrelief -type string -default "" -choicecolumns 7 -choices {raised sunken flat ridge solid groove ""} -help\ "Specifies an alternative relief for the button, to be used when the mouse cursor is over the widget. This option can be used to make toolbar buttons, by configuring -relief flat -overrelief raised. If the value of this option is the empty string, then no alternative relief is used when the mouse cursor is over the button. The empty string is the default value." -state -type string -choices {normal active disabled} -help\ "Specifies one of three states for the button: normal, active, or disabled. In normal state the button is displayed using the ${$B}-foreground${$N} and ${$B}-background${$N} options. The active state is typically used when the pointer is over the button. In active state the button is displayed using the ${$B}-activeforeground${$N} and ${$B}-activebackground${$N} options. Disabled state means that the button should be insensitive: the default bindings will refuse to activate the widget and will ignore mouse button presses. In this state the ${$B}-disabledforeground${$N} and ${$B}-background${$N} options determine how the button is displayed." -width -type tk_screen_units -help\ "Specifies a desired width for the button. If an image or bitmap is being displayed in the button then the value is in screen units (i.e. any of the forms acceptable to Tk_GetPixels). For a text button (no image or with -compound none) then the width specifies how much space in characters to allocate for the text label. If the width is negative then this specifies a minimum width. If this option is not specified, the button's desired width is computed from the size of the image or bitmap or text being displayed in it." } "@doc -name Manpage: -url [manpage button]"\ { @examples -help { This is the classic Tk “Hello, World!” demonstration: ${[example { ${$B}button${$N} .b -text "Hello, World!" -command exit pack .b }]} This example demonstrates how to handle button accelerators: ${[example { ${$B}button${$N} .b1 -text Hello -underline 0 ${$B}button .b2${$N} -text World -underline 0 bind . {.b1 flash; .b1 invoke} bind . {.b2 flash; .b2 invoke} pack .b1 .b2 }]} } } punk::args::define { @id -id "(widgetcommand)Class_Button cget" @cmd -name "(widgetcommand)Class_Button cget" -help\ "Returns the current value of the configuration option given by option. Option may have any of the values accepted by the button command." @leaders -min 1 -max 1 option -type string } set CLASS_BUTTON_CHOICES [list cget configure flash invoke] #manual synopses for subcommands not yet defined set CLASS_BUTTON_CHOICELABELS [subst -novariables { }] set CLASS_BUTTON_CHOICEINFO [dict create] foreach sub $CLASS_BUTTON_CHOICES { #default for all dict set CLASS_BUTTON_CHOICEINFO $sub {{doctype native}} } foreach id [punk::args::get_ids "(widgetcommand)Class_Button *"] { if {[llength $id] == 2} { lassign $id _ sub dict set CLASS_BUTTON_CHOICEINFO $sub {{doctype native} {doctype punkargs}} #override manual synopsis entry #puts stderr "override manual synopsis entry with [punk::ns::synopsis "::package $sub"]" #dict set CLASS_BUTTON_CHOICELABELS $sub [punk::ansi::a+ normal][punk::ns::synopsis "(widgetcommand)Class_Button $sub"] dict set CLASS_BUTTON_CHOICELABELS $sub [punk::ansi::a+ normal][punk::args::synopsis "(widgetcommand)Class_Button $sub"] } } punk::args::define { @id -id (widgetcommand)Class_Button # ?? (instance)Class_Button ?? @cmd -name "Tk widget: (widgetcommand)Class_Button"\ -summary\ "widgetcommand for Tk class Button"\ -help\ "widgetcommand for Tk class Button" @leaders -min 1 -max 1 option -type string\ -choicecolumns 2\ -choicegroups { "actions" {flash invoke} }\ -choicelabels {${$CLASS_BUTTON_CHOICELABELS}}\ -choiceinfo {${$CLASS_BUTTON_CHOICEINFO}} } "@doc -name Manpage: -url [manpage button]" # -- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- # -- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- # ::wm subcommands # -- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- punk::args::define { @id -id "::wm aspect" @cmd -name "Tk Built-in: ::wm aspect"\ -summary\ "Get/set aspect ratio restrictions."\ -help\ "If ${$I}minNumer${$NI}, ${$I}minDenom${$NI}, ${$I}maxNumer${$NI}, and ${$I}maxDenom${$NI} are all specified, then they will be passed to the window manager and the window manager should use them to enforce a range of acceptable aspect ratios for window. The aspect ratio of window (width/length) will be constrained to lie between ${$I}minNumer${$NI}/${$I}minDenom${$NI} and ${$I}maxNumer${$NI}/${$I}maxDenom${$NI}. If ${$I}minNumer${$NI} etc. are all specified as empty strings, then any existing aspect ratio restrictions are removed. If ${$I}minNumer${$NI} etc. are specified, then the command returns an empty string. Otherwise, it returns a Tcl list containing four elements, which are the current values of ${$I}minNumer${$NI}, ${$I}minDenom${$NI}, ${$I}maxNumer${$NI}, and ${$I}maxDenom${$NI} (if no aspect restrictions are in effect, then an empty string is returned)." @values -min 1 window -type string #todo - punk::args - way to specify all number or all empty e.g # -type {(number number number number)|(literal() literal() literal() literal())} aspectratio\ -type {number|literal() number|literal() number|literal() number|literal()}\ -typesynopsis "${$I}minNumer${$NI} ${$I}minDenom${$NI} ${$I}maxNumer${$NI} ${$I}maxDenom${$NI}"\ -optional 1 } "@doc -name Manpage: -url [manpage wm]" #attributes punk::args::define { @id -id "::wm client" @cmd -name "Tk Built-in: ::wm client"\ -summary\ "Get/set WM_CLIENT_MACHINE name for the window."\ -help\ "If ${$I}name${$NI} is specified, this command stores ${$I}name${$NI} (which should be the name of the host on which the application is executing) in ${$I}window${$NI}'s ${$B}WM_CLIENT_MACHINE${$N} property for use by the window manager or session manager. The command returns an empty string in this case. If ${$I}name${$NI} is not specified, the command returns the last name set in a wm client command for window. If ${$I}name${$NI} is specified as an empty string, the command deletes the ${$B}WM_CLIENT_MACHINE${$N} property from ${$I}window${$NI}." @values -min 1 -max 2 window -type string name\ -type string\ -optional 1 } "@doc -name Manpage: -url [manpage wm]" #colormapwindows #command #deiconify #focusmodel punk::args::define { @id -id "::wm forget" @cmd -name "Tk Built-in: ::wm forget"\ -summary\ "Unmap/Unmanage window."\ -help\ "The window will be unmapped from the screen and will no longer be managed by ${$B}wm${$N}. Windows created with the ${$B}toplevel${$N} command will be treated like frame windows once they are no longer managed by ${$B}wm${$N}, however, the ${$B}-menu${$N} configuration will be remembered and the menus will return once the widget is managed again." @values -min 1 -max 1 window -type string } "@doc -name Manpage: -url [manpage wm]" punk::args::define { @id -id "::wm frame" @cmd -name "Tk Built-in: ::wm frame"\ -summary\ "Identifier of outermost frame containing window."\ -help\ "If ${$I}window${$NI} has been reparented by the window manager into a decorative frame, the command returns the platform specific window identifier for the outermost frame that contains ${$I}window${$NI} (the window whose parent is the root or virtual root). If ${$I}window${$NI} has not been reparented by the window manager then the command returns the platform specific window identifier for ${$I}window${$NI}." @values -min 1 -max 1 window -type string } "@doc -name Manpage: -url [manpage wm]" #geometry #grid #group #iconbadge #iconbitmap #iconify #iconmask #iconname #iconphoto #iconposition #iconwindow punk::args::define { @id -id "::wm manage" @cmd -name "Tk Built-in: ::wm manage"\ -summary\ "Make frame/labelframe a toplevel."\ -help\ "The ${$I}widget${$NI} specified will become a stand alone top-level window. The window will be decorated with the window managers title bar, etc. Only frame, labelframe and toplevel widgets can be used with this command. Attempting to pass any other widget type will raise an error. Attempting to manage a toplevel widget is benign and achieves nothing. See also ${$B}GEOMETRY MANAGEMENT${$N}." @values -min 1 -max 1 widget -type string -help\ "frame, labelframe or toplevel" } "@doc -name Manpage: -url [manpage wm]" #maxsize #minsize #overrideredirect #positionfrom #protocol punk::args::define { @id -id "::wm resizable" @cmd -name "Tk Built-in: ::wm resizable"\ -summary\ "Get/Set window width and height resizability."\ -help\ "This command controls whether or not the user may interactively resize a top-level window. If ${$I}width${$NI} and ${$I}height${$NI} are specified, they are boolean values that determine whether the width and height of window may be modified by the user. In this case the command returns an empty string. If ${$I}width${$NI} and ${$I}height${$NI} are omitted then the command returns a list with two 0/1 elements that indicate whether the width and height of window are currently resizable. By default, windows are resizable in both dimensions. If resizing is disabled, then the window's size will be the size from the most recent interactive resize or ${$B}wm geometry${$N} command. If there has been no such operation then the window's natural size will be used." @values -min 1 window -type string width_height\ -type {boolean boolean}\ -typesynopsis "${$I}width${$NI} ${$I}height${$NI}"\ -optional 1 } "@doc -name Manpage: -url [manpage wm]" #sizefrom #stackorder punk::args::define { @id -id "::wm state" @cmd -name "Tk Built-in: ::wm state"\ -summary\ "Get/set window state."\ -help\ "If newstate is specified, the window will be set to the new state, otherwise it returns the current state of window: either ${$B}normal${$N}, ${$B}iconic${$N}, ${$B}withdrawn${$N}, ${$B}icon${$N}, or (Windows and macOS only) ${$B}zoomed${$N}. The difference between ${$B}iconic${$N} and ${$B}icon${$N} is that ${$B}iconic${$N} refers to a window that has been iconified (e.g., with the wm iconify command) while ${$B}icon${$N} refers to a window whose only purpose is to serve as the icon for some other window (via the ${$B}wm iconwindow${$N} command). The ${$B}icon${$N} state cannot be set." @values -min 1 -max 2 window -type string newstate\ -type string\ -optional 1\ -choices {normal iconic withdrawn zoomed}\ -choicelabels {\ normal\ "" iconic\ "" withdrawn\ "" zoomed\ " (Windows and macOS only)" } } "@doc -name Manpage: -url [manpage wm]" #title #transient #withdraw # -- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- # ::wm # -- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- set WM_CHOICES [list aspect attributes client colormapwindows command deiconify focusmodel forget frame\ geometry grid group iconbadge iconbitmap iconify iconmask iconname iconphoto iconposition iconwindow\ manage maxsize minsize overrideredirect positionfrom protocol resizable sizefrom stackorder\ state title transient withdraw\ ] #manual synopses for subcommands not yet defined set WM_CHOICELABELS [subst -novariables { }] set WM_CHOICEGROUPS [dict create {*}{ "" {} icon {iconbadge iconbitmap iconmask iconphoto iconposition iconwindow} }] set WM_GROUPALLOCATED [list] dict for {g glist} $WM_CHOICEGROUPS { lappend WM_GROUPALLOCATED {*}$glist } foreach sub $WM_CHOICES { if {$sub ni $WM_GROUPALLOCATED} { dict lappend WM_CHOICEGROUPS "" $sub } } set WM_CHOICEINFO [dict create] foreach sub $WM_CHOICES { #default for all dict set WM_CHOICEINFO $sub {{doctype native}} } foreach id [punk::args::get_ids "::wm *"] { if {[llength $id] == 2} { lassign $id _ sub dict set WM_CHOICEINFO $sub {{doctype native} {doctype punkargs}} #override manual synopsis entry #puts stderr "override manual synopsis entry with [punk::ns::synopsis "::wm $sub"]" dict set WM_CHOICELABELS $sub [punk::ansi::a+ normal][punk::args::synopsis "::wm $sub"] } } punk::args::define { @id -id ::wm @cmd -name "Tk Built-in: ::wm"\ -summary\ "Communicate with window manager."\ -help\ "The ${$B}wm${$N} command is used to interact with window managers in order to control such things as the title for a window, its geometry, or the increments in terms of which it may be resized. The ${$B}wm${$N} command can take any of a number of different forms, depending on the option argument. All of the forms expect at least one additional argument, window, which must be the path name of a top-level window. ${$T}GEOMETRY MANAGMENT${$NT} By default a top-level window appears on the screen in its natural size, which is the one determined internally by its widgets and geometry managers. If the natural size of a top-level window changes, then the window's size changes to match. A top-level window can be given a size other than its natural size in two ways. First, the user can resize the window manually using the facilities of the window manager, such as resize handles. Second, the application can request a particular size for a top-level window using the wm geometry command. These two cases are handled identically by Tk; in either case, the requested size overrides the natural size. You can return the window to its natural by invoking wm geometry with an empty geometry string. Normally a top-level window can have any size from one pixel in each dimension up to the size of its screen. However, you can use the wm minsize and wm maxsize commands to limit the range of allowable sizes. The range set by wm minsize and wm maxsize applies to all forms of resizing, including the window's natural size as well as manual resizes and the wm geometry command. You can use any value accepted by Tk_GetPixels. You can also use the command wm resizable to completely disable interactive resizing in one or both dimensions. The wm manage and wm forget commands may be used to perform undocking and docking of windows. After a widget is managed by wm manage command, all other wm subcommands may be used with the widget. Only widgets created using the toplevel command may have an attached menu via the -menu configure option. A toplevel widget may be used as a frame and managed with any of the other geometry managers after using the wm forget command. Any menu associated with a toplevel widget will be hidden when managed by another geometry managers. The menus will reappear once the window is managed by wm. All custom bindtags for widgets in a subtree that have their top-level widget changed via a wm manage or wm forget command, must be redone to adjust any top-level widget path in the bindtags. Bindtags that have not been customized do not have to be redone. ${$T}GRIDDED GEOMETRY MANAGEMENT${$NT} Gridded geometry management occurs when one of the widgets of an application supports a range of useful sizes. This occurs, for example, in a text editor where the scrollbars, menus, and other adornments are fixed in size but the edit widget can support any number of lines of text or characters per line. In this case, it is usually desirable to let the user specify the number of lines or characters-per-line, either with the wm geometry command or by interactively resizing the window. In the case of text, and in other interesting cases also, only discrete sizes of the window make sense, such as integral numbers of lines and characters-per-line; arbitrary pixel sizes are not useful. Gridded geometry management provides support for this kind of application. Tk (and the window manager) assume that there is a grid of some sort within the application and that the application should be resized in terms of grid units rather than pixels. Gridded geometry management is typically invoked by turning on the setGrid option for a widget; it can also be invoked with the wm grid command or by calling Tk_SetGrid. In each of these approaches the particular widget (or sometimes code in the application as a whole) specifies the relationship between integral grid sizes for the window and pixel sizes. To return to non-gridded geometry management, invoke wm grid with empty argument strings. When gridded geometry management is enabled then all the dimensions specified in wm minsize, wm maxsize, and wm geometry commands are treated as grid units rather than pixel units. Interactive resizing is also carried out in even numbers of grid units rather than pixels. ${$T}BUGS${$NT} Most existing window managers appear to have bugs that affect the operation of the ${$B}wm${$N} command. For example, some changes will not take effect if the window is already active: the window will have to be withdrawn and de-iconified in order to make the change happen." @leaders -min 1 -max 1 subcommand -type string\ -choicecolumns 2\ -choicegroups\ {${$WM_CHOICEGROUPS}}\ -unindentedfields {-choicelabels}\ -choicelabels\ {${$WM_CHOICELABELS}}\ -choiceinfo {${$WM_CHOICEINFO}} @values -unnamed true } "@doc -name Manpage: -url [manpage wm]"\ { @examples -help { A fixed-size window that says that it is fixed-size too: ${[example { toplevel .fixed ${$B}wm title${$N} .fixed "Fixed-size Window" ${$B}wm resizable${$N} .fixed 0 0 }]} A simple dialog-like window, centred on the screen: ${[example { # Create and arrange the dialog contents. toplevel .msg label .msg.l -text "This is a very simple dialog demo." button .msg.ok -text OK -default active -command {destroy .msg} pack .msg.ok -side bottom -fill x pack .msg.l -expand 1 -fill both # Now set the widget up as a centred dialog. # But first, we need the geometry managers to finish setting # up the interior of the dialog, for which we need to run the # event loop with the widget hidden completely... ${$B}wm withdraw${$N} .msg update set x [expr {([winfo screenwidth .] - [winfo width .msg]) / 2}] set y [expr {([winfo screenheight .] - [winfo height .msg]) / 2}] ${$B}wm geometry${$N} .msg +$x+$y ${$B}wm transient${$N} .msg . ${$B}wm title${$N} .msg "Dialog demo" ${$B}wm deiconify${$N} .msg }]} }} } #*** !doctools #[list_end] [comment {--- end definitions namespace punk::args::moduledoc::tkcore ---}] } # ++ +++ +++ +++ +++ +++ +++ +++ +++ +++ +++ # ++ +++ +++ +++ +++ +++ +++ +++ +++ +++ +++ # Secondary API namespace # ++ +++ +++ +++ +++ +++ +++ +++ +++ +++ +++ tcl::namespace::eval punk::args::moduledoc::tkcore::lib { tcl::namespace::export {[a-z]*} ;# Convention: export all lowercase tcl::namespace::path [tcl::namespace::parent] #*** !doctools #[subsection {Namespace punk::args::moduledoc::tkcore::lib}] #[para] Secondary functions that are part of the API #[list_begin definitions] #*** !doctools #[list_end] [comment {--- end definitions namespace punk::args::moduledoc::tkcore::lib ---}] } # ++ +++ +++ +++ +++ +++ +++ +++ +++ +++ +++ # == === === === === === === === === === === === === === === # Sample 'about' function with punk::args documentation # == === === === === === === === === === === === === === === tcl::namespace::eval punk::args::moduledoc::tkcore { tcl::namespace::export {[a-z]*} ;# Convention: export all lowercase variable PUNKARGS variable PUNKARGS_aliases lappend PUNKARGS [list { @id -id "(package)punk::args::moduledoc::tkcore" @package -name "punk::args::moduledoc::tkcore" -help\ "punk::args documentation for Tk package" }] namespace eval argdoc { #namespace for custom argument documentation proc package_name {} { return punk::args::moduledoc::tkcore } proc about_topics {} { #info commands results are returned in an arbitrary order (like array keys) set topic_funs [info commands [namespace current]::get_topic_*] set about_topics [list] foreach f $topic_funs { set tail [namespace tail $f] lappend about_topics [string range $tail [string length get_topic_] end] } #Adjust this function or 'default_topics' if a different order is required return [lsort $about_topics] } proc default_topics {} {return [list Description *]} # ------------------------------------------------------------- # get_topic_ functions add more to auto-include in about topics # ------------------------------------------------------------- proc get_topic_Description {} { punk::args::lib::tstr [string trim { package punk::args::moduledoc::tkcore punk::args documentation for Tk } \n] } proc get_topic_License {} { return "MIT" } proc get_topic_Version {} { return "$::punk::args::moduledoc::tkcore::version" } proc get_topic_Contributors {} { set authors {{Julian Noble