[Pharo Trick: #0006] - Run code from a button window
----------------------------------------------------------------------------------- [Pharo Trick: #0006] - Run code from a standalone button window ----------------------------------------------------------------------------------- Works in: Pharo 2.0, 3.0, ... ----------------------------------------------------------------------------------- In Pharo there is a class called ButtonModel - it is a model used for buttons when building UI's with the Spec framework. But it can be used also standalone to open a button window with an action block: |b| b := ButtonModel new. b openWithSpec; label: 'Run my code'; action: [ Transcript open ] So you just have to click to run some code.
----------------------------------------------------------------------------------- [Pharo Trick: #0007] - Write UI prototype in a workspace ----------------------------------------------------------------------------------- Works in: Pharo 2.0, 3.0, ... ----------------------------------------------------------------------------------- In Morphic, there is no way to quickly prototype a UI. But in Spec there is a Dynamic class supporting this, so one can try different things directly from a Workspace An example: m := DynamicComposableModel new. m instantiateModels: #( button ButtonModel list ListModel). m list items: #(1 2 3 4 5). m button label: 'Plip'; action: [ self halt ]. m openWithSpecLayout: (SpecLayout composed newColumn: [: c | c add: #list ; add: #button height: 26 ]; yourself). Ben
participants (2)
-
Benjamin -
Torsten Bergmann