Chris Sells wrote about the book Nobody Knows Shoes. Shoes is a tiny toolkit. For making windowy Ruby programs that run on Mac, Windows, Linux and so on. Download it HERE
Trivial Shoes App
Shoes.app {
button("Press Me") { alert("You pressed me") }
}
PowerShell Version
. .\Shoes
Shoes app {
button "Press Me" { alert "You pressed me" }
}
PowerShell Shoes Toolkit
[void] [Reflection.Assembly]::LoadWithPartialName("System.Windows.Forms") $frm $tlp function Shoes ($target, [scriptblock]$block) { switch ($target) { "app" { $frm = New-Object Windows.Forms.Form $tlp = New-Object System.Windows.Forms.TableLayoutPanel [void] $frm.Controls.Add($tlp) & $block $frm.Add_Shown( { $frm.Activate() } ) $frm.ShowDialog() } } } function button($text,[scriptblock]$block) { $ctl = New-Object Windows.Forms.Button $ctl.Text = $Text [void] $tlp.Controls.Add($ctl) $ctl.add_click($block) } function alert($what) { [System.Windows.Forms.MessageBox]::Show($what) }
{ 1 comment… read it below or add one }
This looks good … I started playing with the same idea from WPF http://huddledmasses.org/powerboots-shoes-for-powershell/ but I’m pipelining it because it just seems more natural in PowerShell. I do like the way you piggybacked on the scriptblocks to nest the controls the way they do in Shoes though …