Last active
January 9, 2020 10:23
-
-
Save seandenigris/4981414 to your computer and use it in GitHub Desktop.
Pharo: Dynamically Create a UI with Spec
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"Requires at least the Spec version from Pharo 2.0" | |
| layout widget | | |
model := DynamicComposableModel new. | |
layout := SpecLayout composed. | |
layout newColumn: [ :col | | |
{1. 2. 3} do: [:e | | selector | | |
selector := ('accessorTo', e asString) asSymbol. | |
model instantiateModels: {selector. #TextInputFieldModel}. | |
widget := model perform: selector. | |
widget text: e asString. | |
col newRow: [ :r | r add: selector ] height: 25 ]. | |
model instantiateModels: {#addButton. #ButtonModel}. | |
widget := model addButton. | |
widget | |
label: 'Add 4'; | |
action: [ ]. | |
col newRow: [ :r | r add: #addButton ] height: 30 ]. | |
model openWithSpecLayout: layout. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment