DelphiVCL.BitBtn is a push button control that can include a bitmap on its face. It’s an alternative to the regular button control which can’t directly use graphics on it.
Bitmap buttons exhibit the same behavior as button controls. We use them to initiate actions from forms and dialog boxes.
Bitmap buttons implement properties that specify the bitmap images, along with their appearance and placement on the button. You can choose from predefined bitmap buttons styles or use your own customized bitmap for the button. Although the button can be associated with only one bitmap, the bitmap (glyph property) can be subdivided into four equal-sized portions, which are displayed based on the state of the button: Up, down, disabled, and clicked.
The Kind property of BitBtn provides commonly used buttons, such as OK, Cancel, Help, and so on. These predefined button types have corresponding graphical images and default behaviors, so you can easily add them to your application with little or no coding necessary.
The recommended way to implement the response of other button kinds to user clicks is to assign action from an action list as the value of the Action property. By setting the Action property, you make the button a client of the action, and the action handles updating the button’s properties and responding when the user clicks the button.
If you are not using the built-in response to a specific kind of button or action to respond when the user clicks the button, then you can specify the button’s response by writing an OnClick event handler.
Table of Contents
What properties and methods are available on the DelphiVCL.BitBtn?
Let’s browse all the properties and methods of the DelphiVCL.BitBtn using dir() command:
1 2 3 |
import DelphiVCL dir(DelphiVCL.BitBtn) |
See the responses in our Windows command prompt:
Is there an example of using the DelphiVCL.BitBtn?
Here is the working example of the implementation of BitBtn:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
#Button OK btnOK = BitBtn(pgOne, Kind = 'OK') btnOK.SetProps(Parent=pgOne,Caption = 'OK', Name = 'OK') btnOK.SetBounds(65,50,60,30) #Button Cancel btnCancel = BitBtn(pgOne, Kind = 'Cancel') btnCancel.SetProps(Parent=pgOne,Caption = 'Cancel', Name = 'Cancel') btnCancel.SetBounds(145,50,60,30) #Button Help btnHelp = BitBtn(pgOne, Kind = 'Help') btnHelp.SetProps(Parent=pgOne,Caption = 'Help',Name = 'Help') btnHelp.SetBounds(65,100,60,30) #Button Insert btnInsert = BitBtn(pgOne, Kind = 'Insert') btnInsert.SetProps(Parent=pgOne,Caption = 'Insert',Name = 'Insert') btnInsert.SetBounds(145,100,60,30) |
To see the result, let’s run the complete script:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
from DelphiVCL import * # Create a Class to build a basic Form class MainForm(Form): def __init__(self, Owner): self.Caption = "Introduction to VCL Components" self.Name = "BaseForm" self.SetBounds(10, 10, 500, 450) # Create a Main Panel component pnlMain = CreateComponent('TPanel',Owner) pnlMain.SetProps(Parent=self, Caption="",align = "alClient", Name = "MainPanel") # Page control creation pgConMain = PageControl(pnlMain) pgConMain.Name = "MyPageControl" pgConMain.Parent = pnlMain pgConMain.Align = "alClient" # Tabsheet one pgOne = TabSheet(pnlMain) pgOne.PageControl = pgConMain pgOne.Caption = "Tab 1" #Button OK btnOK = BitBtn(pgOne, Kind = 'OK') btnOK.SetProps(Parent=pgOne,Caption = 'OK', Name = 'OK') btnOK.SetBounds(65,50,60,30) #Button Cancel btnCancel = BitBtn(pgOne, Kind = 'Cancel') btnCancel.SetProps(Parent=pgOne,Caption = 'Cancel', Name = 'Cancel') btnCancel.SetBounds(145,50,60,30) #Button Help btnHelp = BitBtn(pgOne, Kind = 'Help') btnHelp.SetProps(Parent=pgOne,Caption = 'Help',Name = 'Help') btnHelp.SetBounds(65,100,60,30) #Button Insert btnInsert = BitBtn(pgOne, Kind = 'Insert') btnInsert.SetProps(Parent=pgOne,Caption = 'Insert',Name = 'Insert') btnInsert.SetBounds(145,100,60,30) # Initialize your application def main(): Application.Initialize() Application.Title = "MyDelphiApp" f = MainForm(Application) f.Show() FreeConsole() Application.Run() Application.Destroy() main() |
Check out DelphiVCL which easily allows you to build GUIs for Windows using Python.