Pmw.ButtonBox

Name

Pmw.ButtonBox() - manager widget for buttons

Inherits

Pmw.MegaWidget

Description

This class creates a manager widget for containing buttons. One of these buttons may be specified as the default button and it will be displayed with an indicator ring around it. The buttons may be laid out either horizontally or vertically.

Options

Options for this megawidget and its base classes are described below.

labelmargin
Initialisation option. If the labelpos option is not None, this specifies the distance between the label component and the rest of the megawidget. The default is 0.

labelpos
Initialisation option. Specifies where to place the label component. If not None, it should be a concatenation of one or two of the letters 'n', 's', 'e' and 'w'. The first letter specifies on which side of the megawidget to place the label. If a second letter is specified, it indicates where on that side to place the label. For example, if labelpos is 'w', the label is placed in the centre of the left hand side; if it is 'wn', the label is placed at the top of the left hand side; if it is 'ws', the label is placed at the bottom of the left hand side.

If None, a label component is not created. The default is None.

orient
Initialisation option. Specifies the orientation of the button box. This may be 'horizontal' or 'vertical'. The default is 'horizontal'.

padx
Initialisation option. Specifies a padding distance to leave between each button in the x direction and also between the buttons and the outer edge of the button box. The default is 8.

pady
Initialisation option. Specifies a padding distance to leave between each button in the y direction and also between the buttons and the outer edge of the button box. The default is 8.

ringborderwidth
Initialisation option. Specifies the width of the border of the ring which appears around the default button. The default is 1.

ringpadx
Initialisation option. Specifies a padding distance to leave in the x direction between each button and the default ring. The default is 1.

ringpady
Initialisation option. Specifies a padding distance to leave in the y direction between each button and the default ring. The default is 1.

Components

Components created by this megawidget and its base classes are described below.

frame
If the label component has been created (that is, the labelpos option is not None), the frame component is created to act as the container of the buttons created by the add() and insert() methods. If there is no label component, the hull component acts as the container. By default, this component is a Tkinter.Frame.

hull
This acts as the body for the entire megawidget. Other components are created as children of the hull to further specialise the widget. By default, this component is a Tkinter.Frame.

label
If the labelpos option is not None, this component is created as a text label for the megawidget. See the labelpos option for details. Note that to set, for example, the text option of the label, you need use the label_text component option. By default, this component is a Tkinter.Label.

Dynamic components

Button components are created dynamically by the add() and insert() methods. By default, the buttons are of type Tkinter.Button and are created with a component group of Button.

Methods

Only methods specific to this megawidget are described below. For a description of its inherited methods, see the manuals for its base classes.

add(name, **kw)
Add a button to the end of the button box as a component named name. Any keyword arguments present will be passed to the constructor when creating the button. If the text keyword argument is not given, the text option of the button defaults to name. The method returns the name component widget.

alignbuttons(when = 'later')
Set the widths of all the buttons to be the same as the width of the widest button. If when is later, this will occur when the interpreter next becomes idle, otherwise the resizing will occur immediately.

delete(index)
Delete the button given by index from the button box. See the index() method for the format of index.

index(index, forInsert = 0)
Return the numerical index of the button corresponding to index. This may be specified in any of the following forms:

number
Specifies the button numerically, where 0 corresponds to the left (or top) button.

end
Indicates the right (or bottom) button.

default
Indicates the current default button. This is the button with the default ring displayed.

name
Specifies the button named name.

If forInsert is set, end returns the number of buttons rather than the index of the last button.

insert(name, before = 0, **kw)
Add a button just before the button specified by before, as a component named name. Any keyword arguments present will be passed to the constructor when creating the button. See the index() method for the format of before. To add a button to the end of the button box, use add(). The method returns the name component widget.

invoke(index = 'default', noFlash = 0)
Invoke the callback command associated with the button specified by index. If noFlash is 0, flash the button to indicate to the user that something happened. See the index() method for the format of index.

numbuttons()
Return the number of buttons in the button box.

setdefault(index)
Set the default button to the button given by index. This causes the default ring to appear around the specified button. If index is None, there will be no default button and no default ring will be displayed. See the index() method for the format of index.

Home. Pmw 0.6.2 Maintainer gregm@iname.com. 23 Feb 1998