The Sender property specifies which component notifies the change link object of changes.
We use Sender to access the component that has changed.
Here is a working example of the implementation of Sender property in DelphiVCL:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
# Implementation in Color Box Creation def ColorChangeHandler(Sender): shpRectangle.Brush.Color = clbSelect.Selected # Implementation in Draw Grid Creation def grdTestDrawCell(Sender, Col, Row, Rect, State): if gdSelected in State: Sender.Canvas.Brush.Color = clBlue # 0x00ff0000 # blue Sender.Canvas.TextRect(Rect, Rect.Left+2, Rect.Top+2, "%d @ %d" % (Col, Row)) def grdTestSelectCell(Sender, Col, Row, CanSelect): if Col == 2 and Row == 2: CanSelect.Value = False grdTest.OnDrawCell = grdTestDrawCell grdTest.OnSelectCell = grdTestSelectCell |
Using the Sender property allows us to create better abstractions in our code so that we do not refer to a specific component directly.
See the much longer complete code here.
Check out DelphiVCL which easily allows you to build GUIs for Windows using Python.