Table of Contents
Description
In previous examples, we already use .Items
several times (see Getting Started with DelphiVCL III: Overview of Commonly used VCL Components). We use it in ListBox
, ComboBox
, and RadioGroup
. Items
contain the strings that appear in the ListBox
, ComboBox
, and RadioGroup
.
Use Items
to add, insert, delete, and move items. By default, the items in a list box are of type Strings
. Use this item type to access its methods or properties to manipulate the items in the list.
Code example
Here is the working example of the implementation of .Items
in the list box:
1 2 3 4 5 6 7 8 |
# Items in list box lboxCountry = ListBox(pgOne) lboxCountry.SetProps(Parent=pgOne) lboxCountry.SetBounds(145,88,121,60) lboxCountry.Items.Add('RUSSIA') lboxCountry.Items.Add('USA') lboxCountry.Items.Add('INDIA') lboxCountry.Items.Add('AUSTRALIA') |
The result:
Here is the working example of the implementation of .Items
in combo box:
1 2 3 4 5 6 7 8 |
# Combo box cbxCity = ComboBox(pgOne) cbxCity.SetProps(Parent=pgOne,Name='ComboBox') cbxCity.SetBounds(145,206,121,60) cbxCity.Items.Add('New York') cbxCity.Items.Add('Sydney') cbxCity.Items.Add('Banglore') cbxCity.Items.Add('Tokyo') |
The result:
Here is the working example of the implementation of .Items
in radio group:
1 2 3 4 5 6 |
# Radio group Creation rbgRadioBox = RadioGroup(pgOne) rbgRadioBox.SetProps(Parent=pgOne,Caption='Gender') rbgRadioBox.SetBounds(20,250,242,90) rbgRadioBox.Items.Add('Male') rbgRadioBox.Items.Add('Female') |
The result:
Note for beta release users
In practice, the only difference between DelphiVCL4Python release version and the beta version is only in how you write the DelphiVCL
. Here is the example for how you import the library:
- Release version:
1 |
from delphivcl import * |
- Beta version:
1 |
from DelphiVCL import * |
Watch this comprehensive introduction to Python GUI Development with DelphiVCL library video by Jim McKeeth:
Also, watch the following webinar by Ian Barker on How to create a real Windows app step-by-step guide:
Check out DelphiVCL which easily allows you to build GUIs for Windows using Python.
Check out Python4Delphi which easily allows you to build Python GUIs for Windows using Delphi.
References & further readings
[1] Embarcadero DocWiki. (2012).
Vcl.StdCtrls.TListBox.Items
. Embarcadero DocWiki. Embarcadero Technologies. docwiki.embarcadero.com/Libraries/Sydney/en/Vcl. StdCtrls.TListBox.Items
[2] Embarcadero DocWiki. (2012).
Vcl.StdCtrls.TComboBox.Items
. Embarcadero DocWiki. Embarcadero Technologies. docwiki.embarcadero.com/Libraries/Sydney/en/Vcl. StdCtrls.TComboBox.Items
[3] Embarcadero DocWiki. (2012).
Vcl.ExtCtrls.TRadioGroup.Items
. Embarcadero DocWiki. Embarcadero Technologies. docwiki.embarcadero.com/Libraries/Sydney/en/Vcl. ExtCtrls.TRadioGroup.Items