We use Caption to specify a text string that identifies the control to the user.
To underline a character in a Caption that labels a component, include an ampersand (&) before the character. This type of character is called an accelerator character. The user can then select the component by pressing ALT while typing the underlined character. To display an ampersand character in the caption, use two ampersands (&&).
Notes:
- Controls that display text use either the Caption property or the Text property to specify the text value. The property that is used depends on the type of control. In general, Caption is used for text that appears as a window title or label, while Text is used for text that appears as the content of a control.
- For some controls, such as TButton, it is not possible to change the color of the Caption. If you want to change the color of a button caption, you should use an alternate button type such as TSpeedButton or TBitBtn instead of TButton. With either TSpeedButton or TBitBtn, you can change the color of the Caption property by using the Font property.
- For TLinkLabel, an HTML tag is declared inside the Caption property either at run time or at design time.
Here is the working example of the implementation of Caption to initialize the base form:
1 2 3 4 |
def __init__(self, Owner): self.Caption = "Components Overview Sample" self.Name = "BaseForm" self.SetBounds(10, 10, 700, 650) |
Here is the working example of the implementation of Caption in the main panel creation:
1 2 3 |
# Main panel creation pnlMain = CreateComponent('TPanel',Owner) pnlMain.SetProps(Parent=self, Caption="",align = "alClient", Name = "MainPanel") |
Here is the working example of the implementation of Caption in the tabsheet creation:
1 2 3 4 |
# Tabsheet one pgOne = TabSheet(pnlMain) pgOne.PageControl = pgConMain pgOne.Caption = "StandardControls" |
Here is the working example of the implementation of Caption in the label creation:
1 2 3 4 5 6 7 8 9 |
# Label creation lblHello = CreateComponent('TLabel',pgOne) lblHello.Parent = pgOne lblHello.Caption = 'FirstName' lblHello.Name = 'Name' lblHello.Left = 20 lblHello.Top = 14 lblHello.Width = 121 lblHello.Height = 30 |
Here is the working example of the implementation of Caption in the check box creation:
1 2 3 4 5 6 |
# Check box creation chkSingle = CheckBox(self) chkSingle.Parent = pgOne chkSingle.Caption = 'Single ?' chkSingle.Alignment = 'taLeftJustify' chkSingle.SetBounds(20, 44, 141, 30) |
Here is the working example of the implementation of Caption in the radiogroup creation:
1 2 3 4 5 6 |
# Radiogroup creation rbgRadioBox = RadioGroup(pgOne) rbgRadioBox.SetProps(Parent=pgOne,Caption='Gender') rbgRadioBox.SetBounds(20,250,242,90) rbgRadioBox.Items.Add('Male') rbgRadioBox.Items.Add('Female') |
Here is the working example of the implementation of Caption in the button creation:
1 2 3 4 |
# Button creation btnOK = Button(pgOne) btnOK.SetProps(Parent=pgOne,Caption = 'Submit',Name = 'btnOK') btnOK.SetBounds(145,540,60,30) |
Here is the working example of the implementation of Caption in the button onclick event:
1 2 |
def btnOKClick(self, Sender): btnOK.Caption = "Clicked" |
Check out DelphiVCL which easily allows you to build GUIs for Windows using Python.