Button

The Button is a Control subclass which represents Cocoa’s NSButton.

class Button(parent, title[, action=None])
Parameters:
buttonType

Cocoa constant. The type of the button. Equivalent to [self buttonType]. Use with NSButtonType constants.

bezelStyle

Cocoa constant. The style of the button. Equivalent to [self bezelStyle]. Use with NSBezelStyle constants.

bordered

Boolean. Whether the button has a border.

title

String. The text on the button. Equivalent to [self title].

font

Font. The font of the button. Equivalent to [self font].

state

Cocoa constant. Use with NSCellStateValue constants.

shortcut

A string that represent the keyboard shortcut that triggers the button. This string has the format “modifiers+letter”, for example, “cmd+f”. Available modifiers are “cmd”, “ctrl”, “alt” and “shift”.

Some special characters are supported through special identifiers. The list of supported identifiers is there. For example, if you want a shortcut that is activated on cmd+<up arrow>, your shorcut would be cmd+arrowup.

image

String. The name of an image for the button. Equivalent to [self image].

imagePosition

Cocoa constant. Equivalent to [self imagePosition]. Use with NSCellImagePosition constants.

Buttons and Layouts

If you fire up Interface Builder and try to play with a button bezel style, you’ll notice that changing it changes many more things too, such as the layouts and the fonts. xibless does it too (it tries to do exactly as IB does). Whenever Button.bezelStyle is changed, layout delta values and fonts are changed. Therefore, if you should always change the Button.font and/or do the layouts after you’ve changed your bezel style.

Checkbox

Checkbox is a subclass of Button, behaves the same way and adds no method or attributes. The only differences is that it sets the button buttonType to NSSwitchButton and tweaks the margins to fit XCode’s behavior.

class Checkbox(parent, title)
Parameters:

Table Of Contents

Previous topic

Menu

Next topic

TextField

This Page