2

Closed

What am I doing wrong ?

description

I've "installed" the ShowUI (1.4 zip) module, and tried some of the examples trying to get familiar with it, but none of them actually work as advertised. What's going on ? I'm running powershell with -STA, tried elevated aswell, but even something simple as this example:

$pr=StackPanel -ControlName "Prompt" -Margin "8,0,8,8" {
Label "Please Enter Your Full Name:"
StackPanel -Orientation Horizontal {
TextBox -Name FullName -Width 100
Button "OK" -IsDefault -Width 50 -Margin "8,0,0,0" -On_Click { 
    Set-UIValue $Prompt -Passthru | Close-Control
}
}
} -On_Loaded { $FullName.Focus() } -Show

$pr

already fails because when I write text, hitting enter or pressing OK-button it just sits there. If I close the window, it returns nothing...
The alternative example of this:

$pr=StackPanel -ControlName "Prompt" -Margin "8,0,8,8" {
Label "Please Enter Your Full Name:"
StackPanel -Orientation Horizontal {
TextBox -Name FullName -Width 100
Button "OK" -IsDefault -Width 50 -Margin "8,0,0,0" -On_Click { 
    $Prompt.Tag = $FullName.Text
    $Window.Close()
}
}
} -On_Loaded { $FullName.Focus() } -Show

$pr

works, but delivers an error:
Error in On_Click Event Handler on Button
At line:7 char:13
$Prompt.Tag = $FullName.Text
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Property 'Tag' cannot be found on this object; make sure it exists and is settable.
Running on Windows Server 2012 standard with powershell 3.0

I also tried powershell.exe -STA -version 2, but that even gives me more errors
So, did I install it wrong, or is ShowUI not entirely compatible with powershell 3 ?
Perhaps .net 4.5 (2012) is the issue ?
Closed Oct 14 at 6:46 AM by Jaykul

comments

jtpolizzi wrote Aug 9, 2013 at 2:57 PM

I'm having the same problem. The samples don't work correctly - some don't work at all.

Example:

$getCommandInput = UniformGrid -ControlName 'Get-InputForGetCommand' -Columns 2 {
"Command Name"
New-TextBox -Name Name
"Verb"
New-TextBox -Name Verb
"Noun"
New-TextBox -Name Noun
"In Module"
New-TextBox -Name Module  
" " # Some Empty Space
New-Button "Get Command" -On_Click {
    Get-ParentControl |
        Set-UIValue -passThru | 
        Close-Control
}
} -show

Get-Command @getCommandInput

When I run it - I get an empty - very small window.

Jaykul wrote Aug 10, 2013 at 5:07 AM

I'm going to have to find and kill those examples (although we should also look at whether they worked as-is in the previous ShowUI release, or are relics from WPK or PowerBoots -- we want to keep the regressions to a minimum!)

It looks like we lost the automatic labels from the "quoted strings" -- you're going to need to explicitly say Label in there:
$getCommandInput = UniformGrid -ControlName 'Get-InputForGetCommand' -Columns 2 {

   Label "Command Name"
   New-TextBox -Name Name

   Label "Verb"
   New-TextBox -Name Verb

   Label "Noun"
   New-TextBox -Name Noun

   Label "In Module"
   New-TextBox -Name Module  

   Label " " # Some Empty Space
   New-Button "Get Command" -On_Click {
      Get-ParentControl |
         Set-UIValue -passThru |
         Close-Control
   }

} -show
The first example is failing just because the StackPanel has a "ControlName" instead of a "Name" -- if you change that, it will work properly.
StackPanel -Name "Prompt" -Margin "8,0,8,8" {
   Label "Please Enter Your Full Name:"
   StackPanel -Orientation Horizontal {
      TextBox -Name FullName -Width 100
      Button "OK" -IsDefault -Width 50 -Margin "8,0,0,0" -On_Click {
         Set-UIValue $Prompt -Passthru | Close-Control
      }
   }
} -On_Loaded { $FullName.Focus() } -Show
Oh, and please, don't go back to PowerShell 2 for this stuff, everything WPF should work better in PowerShell 3 (and .Net 4) ;-)

Jerre wrote Sep 30, 2013 at 2:10 PM

Same here, just installed ShowUI 1.4 and tried the Twitter democode from here:

TwitterAPI

Pasted code into powershell ISE and run, all that is shown is a black window.

Running on windows 8.1 RTM by the way.

What could be wrong?

Jaykul wrote Sep 30, 2013 at 6:00 PM

The Twitter API has changed. You're not going to get anything back using that URL pattern, so your screen is basically going to be blank because everything on it in his script is generated from the results of the RSS feed.

Jaykul wrote Sep 30, 2013 at 6:05 PM

I'm going to close this, since I don't think these problems are related to shipped examples (which I am checking to make sure they all still work). If you have problems with examples on people's blogs, the appropriate place to get help is the forums (or the blog post's comments).

If we have bad examples on the CodePlex site or Show-UI.com please do open another bug with a URL so that I can fix them.