[PowerShell] Object initialiser does not work for Label but does for Window
See original GitHub issueHi
I’m investigating Terminal.Gui in PowerShell. I found that I can create a Label
using the constructor, but not using object initialisation. I get no errors, but the label is not displayed. However, object initialisation works for Window
. What am I doing wrong?
Sample code (please excuse the quality, it’s my first attempt):
using namespace Terminal.Gui
Add-Type -Path 'C:\Users\<removed>\.nuget\packages\terminal.gui\1.0.0-pre.99.1\lib\net5.0\Terminal.Gui.dll'
Add-Type -Path 'C:\Users\<removed>\.nuget\packages\nstack.core\0.16.0\lib\netstandard2.0\NStack.dll'
[Application]::Init()
$top = [Application]::Top
# This object initialiser works for Window
$mainWindow = [Window] @{
Title = 'Testing'
X = 0
Y = 1
Width = [Dim]::Fill()
Height = [Dim]::Fill()
}
$top.Add($mainWindow)
# Using the constructor works. Label is displayed
$testLabel1 = [Label]::new(0, 0, 'Test1')
# Using object initialiser does not work for Label
# No errors, but the label is not displayed
$testLabel2 = [Label] @{
X = 0
Y = 1
Text = 'Test2'
}
$mainWindow.Add($testLabel1)
$mainWindow.Add($testLabel2)
$menu1 = [MenuBar]::new(
@(
[MenuBarItem] @{
Title = '_File'
Children = @(
[MenuItem] @{
Title = '_Quit'
Action = {[Application]::RequestStop()}
}
)
}
)
)
$top.Add($menu1)
[Application]::Run()
[Application]::Shutdown()
Issue Analytics
- State:
- Created 3 years ago
- Comments:8 (3 by maintainers)
Top Results From Across the Web
PowerShell Form not displaying full Label message
I am using a label for this and I added a text. The problem is that my text does not show completely in...
Read more >Use PowerShell to Initialize Raw Disks and to Partition and ...
To do this I use the Get-Disk function, and I use the Where-Object cmdlet to limit the results to those with a 'Raw'...
Read more >PowerShell connection from MacOS not working
I trying PowerShell 7 on MacOS and I have installed SharePoint Online Management Shell but the " Connect-SPOService" command is not found.
Read more >Statements - PowerShell
A statement specifies some sort of action that is to be performed.
Read more >Initialize-Disk (Storage) - PowerShell
The Initialize-Disk cmdlet initializes a Disk object with the RAW ... Disks must be initialized before they can be formatted and used to...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
PowerShell 7
and latest master works:Hopefully there is a solution to it working in
Windows Terminal
.I only could make it working with this code:
If you don’t need this issue open anymore, please close it. Thanks.