PowerShell Core – Scripting GUI Controls / Widgets possible on RPI ?

Ever wondered if you could use PowerShell Core to script GUI controls on Linux ?

Well if you miss the Out-Gridview and more GUI controls (Widgets)

See below on how to simulated this in your Powershell scripts

PS :  There is an Out-GridView Module for PS Core on Linux.

https://www.powershellgallery.com/packages/Microsoft.PowerShell.GraphicalTools/0.2.0

But unfortunately it runs only on an x64 bit OS Sad smile


image

To solve the errors in WSL2 :

Error libGL error: No matching fbConfigs or visuals found can be fixed with

Run this command :

export LIBGL_ALWAYS_INDIRECT=1

There is also a commandline option, for Out-GrdiView Winking smile

image

But to get going with GTK widgets (Gui Controls) using PowerShell Scritping…

See below Smile

SOLUTION :

1. Make sure your ave installed PowerShell Core on your RPI

    See here for PS Core 7.2

2. Make sure you have installed Zenity on you RPI

    It should be installed out of the box in Raspbian

    Run this command to check it.

zenity --version

image

if not installed run this command

sudo apt-get install -y zenity

3. Run the Zenity commands to interact with PowerShell Core

Checkbox Example :

image

You can use the return options from the checkbox to use in your PowerShell script logic

image

This goes for all the GUI Controls ! Winking smile

….

4. Zenity PowerShell Module

To make life easy I created a PS Module to get most commands and options easy accessible.

Later I might decide to make it available on GitHub …

image

Module includes all relevant Widgets

image

image

image

image

image

image

image

image

image

image

image

image

image

Special treat is the Out-GridView Winking smile

(for the PowerShell users that are missing the 32bit version of Out-GridView)

image

Also see here for a dynamically returning an SQLite database in a LIST Gui

image

PS :

This has not yet been tested on the Bullseye – the new version of Raspberry Pi OS using GTK3

See here for more info.

If someone can confirm that all is worling well, that would be great Smile

Tips and Tricks :

If you want to run Zentiy Widgets on your Windows WSL. you will need a few more components

See here

If you want to know more about Developing GUI Apps using .NET Core Cross Platform

See here

Enjoy !!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: