Copyright (c) 2020, Antal Koós
License: MIT
mouse buttons on item:
mouse buttons on group separator:
Selecting with dragging the mouse and clicking on “Select/Unselect all” acts only on the selected items.
import tkinter as tk
import thebigselector as tbs
...
bsb= tbs.BigSelBox(win, items= items, callback= cb, intro= intro, see="items_start")
...
See the demos for the details!
BigSelBox is an option selector, derived from ttk.Frame and contains a tk.Text widget associated with a vertical ttk.Scrollbar.
BigSelBox( master, items=[], selections=[], callback=None,
separators={}, sepprops={}, textprops={},
frameprops={}, itemprops={},
pickedprops={}, intro=" ", introprops={},
compl=" ", complprops={}, see=None)
callback: called by clicking on an item or group separator or button with these arguments:
the trigger action that can be:
the index of the selected/unselected item/group separator, or None in case of pressing “Ok”, “Select”, “Unselect all”, “Cancel”
index:separator_string
pairs, where index
is the index of the item before the string must be inserted.see: a text widget index for scroll the text until the part on that position is visible.
Special indexes:
pickedcolors: (foreground, background) colors of the selected items
The callback can be set two ways, e.g.: sb.callback=cb
or sb["callback"]=cb
set_items(items,selections=[], see=None): sets the items.
set_selections(selections, see=None): sets the selections.
set_intro(txt, see=None): sets the introductory text.
set_compl(txt, see=None): sets the completion text.
see(self,index): scrolls the text until the part on that position is visible.
disable_button(btnstr): disables/enables a button.
enable_button(btnstr): disables/enables a button.
A Tkinter top level window class with a ‘BigSelBox’ inside.
TopBSB(parent, items=[], selections=[], callback=None,
separators={}, sepprops={}, textprops={},
frameprops={}, itemprops={},
pickedprops={}, intro="", introprops={},
compl="", complprops={},
**toplevel_kwargs)
The other args will be passed to the inner BigSelBox instance.
When the window is destroyed, the callback also will be called with (box, actnCancel, None)
.
geom(wdg): returns the widget’s geometry values as ints: (width, height, x, y)
.
fix_minsize(wdg): freezes the widget size to the recommended minimal size.