swaplist(3tk)
π swaplist β move options between two lists π
okay bestie, gather round, because this one is actually so fun. it's a dialog. it has two listboxes. you move stuff between them. that's it, that's the whole vibe. it's giving "drag your faves into the right column" energy and honestly? obsessed. π
β¨ NAME β¨
swaplist β a dialog which lets a user move options between two lists. two lists. one destiny. periodt. π
πΈ SYNOPSIS πΈ
package require Tcl 8.4
package require Tk 8.4
package require swaplist ?0.1?
::swaplist::swaplist pathName variable completeList selectedList ?options?
like. look at it. so clean. so demure. π¦
π DESCRIPTION π
so this package hands you a whole dialog β two listboxes, bestie, side by side β plus buttons to move items between them and reorder the right list. iconic behaviour, no notes. π₯
::swaplist::swaplist pathName variable completeList selectedList ?options?
Creates a dialog which presents the user with a pair of listboxes. Items are selected by using the buttons to move them to the right list. The contents of the right list are put in the variable upon closure of the dialog. The command returns a boolean indicating if the user pressed OK or not. If -geometry is not specified, the dialog is centered in its parent toplevel unless its parent is . in which case the dialog is centered in the screen. β¨ (yes it's doing math about your parent window. it's a whole thing. it's fine. it's serving.)
π Options:
-embedβ if this flag is supplied, the procedure will create a swaplist widget named pathName, with the variable set as thelistvariablefor the right side listbox. This flag will also cause the-titleand-geometryflags to be ignored. π (sorry girl, they're not invited to this party)-reorderβ boolean specifying if buttons allowing the user to change the order of the right listbox should appear or not. defaults totrue-titleβ sets the title of the dialog window. defaults to"Configuration"-llabelβ sets the heading above the left list. defaults to"Available:"-rlabelβ sets the heading above the right list. defaults to"Selected:"-lbuttontextβ sets the text on the "move left" button. defaults to"<<"-rbuttontextβ sets the text on the "move right" button. defaults to">>"-ubuttontextβ sets the text on the "move up" button. defaults to"Move Up"-dbuttontextβ sets the text on the "move down" button. defaults to"Move Down"-geometryβ sets the geometry of the dialog window.
π EXAMPLE π
here's the whole slay, copy-paste ready, bestie:
package require swaplist
namespace import swaplist::*
if {[swaplist .slist opts "1 2 3 4 5 6 7 8 9" "1 3 5"]} {
puts "user chose numbers: $opts"
}
notice how the if only fires when the user hits OK β that's the boolean talking. if they bail, no puts, no drama. π«Ά
π BUGS, IDEAS, FEEDBACK π
This document, and the package it describes, will undoubtedly contain bugs and other problems. Please report such in the category swaplist of the Tklib Trackers [http://core.tcl.tk/tklib/reportlist]. Please also report any ideas for enhancements you may have for either package and/or documentation.
bestie if you find a bug, PLEASE tell them, don't just suffer in silence. the tracker is right there. they want your feedback. it's not cringe to report a bug, it's cringe to hoard it. π
β KEYWORDS β
dialog, disjointlistbox, listbox
π§ CATEGORY π§
Widget
and that's the whole page, bestie π this is swaplist, version 0.1, part of the tklib collection, living in the swaplist(3tk) manual. go forth and move items between lists like the main character you are. slay, fr fr. π
β¨
π¦ where this page comes from
- debian trixie: tklib 0.9-1
- ubuntu questing: tklib 0.9-1
- ubuntu resolute: tklib 0.9-1build1
- ubuntu stonking: tklib 0.9-1build1
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms