This article will be a continuation of the review widgets graphic library Tk (tkx).

We'll consider:
Label
Button
Entry
Checkbutton
Radiobutton
Combobox
Frame
')
ttk :: buttonThe widget is a normal button, when clicked, an action (command) is performed.
button is in the ttk namespace, so using the Tkx module, the constructor will look like this:
my $ button = $ parent-> new_ttk__button (% args);
The most commonly used arguments are:
-text - the inscription on the button
-command - callback called when pressed (invoke).
-width - length (calculated in characters), usually there is no need to use
-state - the state of the widget (can be: normal, disabled)
Parameter values ββcan be changed at runtime using the configure method:
$ button-> configure (% args)
A small example:
Place on the form two buttons (first active, second inactive), when you press one, the other is activated.

#! / usr / bin / perl
use strict;
use Tkx;
my $ mw = Tkx :: widget-> new ('.');
$ mw-> g_wm_minsize (250,100);
my $ button_1 = $ mw-> new_ttk__button (-text => 'Button 1');
my $ button_2 = $ mw-> new_ttk__button (-text => 'Button 2', -state => 'disabled');
$ button_1-> configure (
-command => sub {
$ button_1-> configure (-state => 'disabled');
$ button_2-> configure (-state => 'normal');
},
);
$ button_2-> configure (
-command => sub {
$ button_2-> configure (-state => 'disabled');
$ button_1-> configure (-state => 'normal');
},
);
Tkx :: grid ($ button_1, -row => 0, -column => 0, -padx => 10, -pady => 10);
Tkx :: grid ($ button_2, -row => 0, -column => 1, -padx => 10, -pady => 10);
Tkx :: MainLoop ();
ttk :: labelThe usual inscription, you can use different fonts.
The text can be set in two ways, either through the option -text, or -textvariable (pointer to a variable).
my $ label = $ parent-> new_ttk__label (-text => 'Static text');
ormy $ textval = 'something';
my $ label = $ parent-> new_ttk__label (-textvariable => \ $ textval);
Options:
-text - text.
-textvariable - a variable that stores the text of the label
-font, -background, -foreground β font, background colors and captions.
-justify - text alignment, set like west-east, south-west (read more in Perl and Tkx. Packaging of widgets).
-relief - relief lettering (flat, groove, raised, ridge, solid, sunken)
-padding, -wraplength - set the indents at the edges, and the maximum length of the line in pixels (after which the transfer follows);
Let's embellish our first example:
ttk :: entryText box

Standard arguments:
-textvariable - a variable in which the value of the field will be stored
-state - state (normal, disabled, readonly)
-justify - alignment (left, center, right)
-validate, -validatecommand, -invalidcommand - allow you to use input validation.
When there are many such widgets, it is convenient for textvariable to use a hash (for example, text-variable => \ $ UI {login}).
ttk :: checkbuttonA button that has several states. The state is written to -variable.
When pressed, like ttk :: button, a procedure can be called.

Arguments
-text, -textvariable - set the label on the button
-onvalue, -offvalue - values ββwhen the option is checked or not. The default is 1 and 0.
-variable - the variable in which the value is written.
-command - the action performed when you click.
my $ checkbutton = $ mw-> new_ttk__checkbutton (
-text => 'enable bla-bla feature',
-variable => \ $ UI {enable_blabla},
-command => sub {
# Updating other widgets
},
);
ttk :: radiobutton
The device is as follows: each radiobutton is assigned a unique value, which is written to the variable
When it is necessary to combine, let's say two buttons in one group, then we set the values ββfor each of them, and the -variable will be common.
my $ radiobutton_1 = $ mw-> new_ttk__radiobutton (-text => 'Option 1', -value => 1, -variable => \ $ UI {radio});
my $ radiobutton_2 = $ mw-> new_ttk__radiobutton (-text => 'Option 2', -value => 2, -variable => \ $ UI {radio});
Options:
-text, -textvariable, -width, -underline, -style etc. For more information, see the Tcl / Tk documentation.
ttk :: comboboxInput box with drop-down list. When the state is readonly, it works only as a list.

Options:
-textvariable - a variable in which the value of the text field will be stored.
-state - state (normal, readonly, disabled)
-values ββ- anonymous array, list.
-postcommand - the command that is executed after selecting an item from the list.
-justify, -height, -width - widget geometry.
ttk :: frameWhen there are many objects on the form, it is convenient to group them using frames.
for example
my $ frame = $ mw-> new_ttk__frame ();
my $ button = $ frame-> new_ttk_button ();
...
One frame can be in another frame and so on ...
Arguments are:
-borderwidth, -relief - thickness of the border, flat relief, groove, raised, ridge, solid, sunken)
-width, -height - length, width
-padding - indent around the edges.
ttk :: labelframeThis is the same frame with header only (-text)
ttk :: progressbarProgressbar, you can set a range of values ββ(by default 0..100)

Options:
-orient - orientation (horizontal and vertical)
-length - length in pixels
-maximum - maximum value (100)
-value - current value
-variable - the variable storing the value.
Previous posts:
Menu operationPackaging WidgetsTkx and streamsLiterature:
Tcl8.5.7 / Tk8.5.7 Documentation