ttk::sizegrip
Guide: Themed widgets (ttk)
Makes a themed size grip: a handle in the corner of a window that the user drags to resize the window.
ttk::sizegrip PATHNAME ?OPTION VALUE ...?
Description
Makes a themed size grip with the name PATHNAME and the options of the call, and makes the command PATHNAME for the widget commands below. The grip draws three rows of dots. A drag of the grip changes the width and the height of its toplevel with wm geometry.
Put the grip in the bottom right corner of the toplevel, such as with grid -sticky se in the last row and column. The grip asks for 16 by 16 logical pixels, and its default cursor is bottom_right_corner.
The parent of PATHNAME must exist, and PATHNAME must not. The class of the grip is TSizegrip, the name of its style.
Widget commands
| Command | Description |
|---|---|
ttk::sizegrip state | Gives the state flags of the widget, or turns flags on and off. |
ttk::sizegrip instate | Tests the state flags of the widget, and runs a script when they match. |
ttk::sizegrip identify | Gives the name of the element of the widget at a point. |
ttk::sizegrip cget | Gives the value of an option of the widget. |
ttk::sizegrip configure | Gives or sets the options of the widget. |
Options
| Option | Type | Default | Database name | Description |
|---|---|---|---|---|
-class | class name | empty | The class of the widget for the option database and for the bindings, set only at creation. | |
-cursor | cursor name | empty | cursor | The shape of the pointer over the widget. |
-style | style name | empty | style | The style of the widget, such as TSizegrip or a style of the script such as Accent.TSizegrip. |
-takefocus | boolean, empty, or script | empty | takeFocus | Whether the Tab key can move the focus to the widget. |
-class CLASS
The class of the widget for the option database and for the bindings, set only at creation.
The class name replaces the class of the style, such as TSizegrip, in winfo class and in the bind tags of the widget. Give it in the call that makes the widget. A later configure of the option gives an error.
% ttk::sizegrip .tsgcl -class Fancy
> winfo class .tsgcl
Fancy
% ttk::sizegrip .tsgcl3
> winfo class .tsgcl3
TSizegrip% ttk::sizegrip .tsgcl2
> .tsgcl2 configure -class Other
attempt to change read-only option
-errorcode NONE-cursor CURSOR
The shape of the pointer over the widget.
Each value side by side: the contact sheet of the cursors
A cursor name of Tk, such as hand2 or xterm. An empty value uses the cursor of the parent.
% ttk::sizegrip .tsgcu -cursor hand2
> .tsgcu cget -cursor
hand2ztk stores each value of the option with no check.
-style STYLE
The style of the widget, such as TSizegrip or a style of the script such as Accent.TSizegrip.
An empty value uses the style TSizegrip. A style name of the script ends with the name of the base style, such as Accent.TSizegrip, and ttk::style configure and ttk::style map give it its options. A style with no settings looks like its base style.
% ttk::style configure Accent.TSizegrip -foreground white
> ttk::sizegrip .tsgsy -style Accent.TSizegrip
> .tsgsy cget -style
Accent.TSizegripztk stores each value of the option with no check, as Tk 8.6.16 does at creation.
-takefocus VALUE
Whether the Tab key can move the focus to the widget.
1 puts the widget in the order of the Tab key, and 0 leaves it out. The default empty value uses the default rule of Tk, and this widget is not in the order of the Tab key with it. A script runs with the path of the widget appended, and its result is the answer.
% ttk::sizegrip .tsgtf -takefocus 1
> .tsgtf cget -takefocus
1ztk stores each value of the option with no check.
Returns
PATHNAME.
Examples
% wm geometry . 300x200
> ttk::sizegrip .grip
> pack .grip -side right -anchor se
> update
> event generate .grip <Button-1> -x 2 -y 2 -rootx 100 -rooty 100
> event generate .grip <B1-Motion> -x 22 -y 12 -rootx 120 -rooty 110
> event generate .grip <ButtonRelease-1>
> update
> list [winfo width .] [winfo height .]
320 210
% winfo class [ttk::sizegrip .corner]
TSizegrip
Errors
% ttk::sizegrip .x -orient vertical
unknown option "-orient"
-errorcode TK LOOKUP OPTION -orient
% ttk::sizegrip .twice
> ttk::sizegrip .twice
window name "twice" already exists in parent
-errorcode TK VALUE WINDOW EXISTS
# The parent .no does not exist.
% ttk::sizegrip .no.s
bad window path name ".no"
-errorcode TK LOOKUP WINDOW .no
% ttk::sizegrip
wrong # args: should be "ttk::sizegrip pathName ?-option value ...?"
-errorcode TCL WRONGARGS
Differences from Tcl
-cursoraccepts each value with no check. Tk 8.6.16 gives an error for a cursor name that does not exist.- The errors of
state,instate,identify, and of an unknown widget command have the error codeNONE. Tk 8.6.16 gives a code such asTTK VALUE STATEorTCL LOOKUP INDEX. The error of-underlinehas the codeTCL VALUE NUMBER, where Tk 8.6.16 givesTCL VALUE INTEGER. - The states
activeandhoverare one flag, sostate activeturns on both.
Facts
- Capability
- None.
- Tcl release
- Tcl 9.1 and 8.6.
- Since
- ztk 1.0.0-beta.1