Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I create pop-up windows for Perl6 in Windows?

Tags:

raku

I am using Windows 7 and 10 rakudo-star-2019.03-x86_64 (JIT). I would like to know how I can create a pop up window in Perl6 to give information to the user? Something like Linux's send-notify or Windows Pro msg (without the networking)

Many thanks, -T

like image 989
Todd Avatar asked Dec 17 '22 15:12

Todd


1 Answers

Is a simple Messagebox good enough? Then

use NativeCall;

constant WCHAR              = uint16;
constant INT                = int32;
constant UINT               = uint32;
constant HANDLE             = Pointer[void];
constant LPWCTSTR           = CArray[WCHAR];
constant MB_ICONEXCLAMATION = 0x00000030;

sub MessageBoxW( HANDLE, LPWCTSTR, LPWCTSTR, UINT ) is native('user32') returns INT { * };

MessageBoxW( my $handle, to-c-str("๘❤ Raku is awesome ❤๖"), to-c-str("Hellö Wαrld"), MB_ICONEXCLAMATION );

sub to-c-str( Str $str ) returns CArray[WCHAR]
{
    my @str := CArray[WCHAR].new;
    for ( $str.comb ).kv -> $i, $char { @str[$i] = $char.ord; }
    @str[ $str.chars ] = 0;
    @str;
}

For anything more complex, the only option available right now for GUIs are bindings for Tk I believe.

like image 140
Holli Avatar answered Jan 08 '23 10:01

Holli