#!/usr/bin/perl
use strict;
use warnings;
use Tk qw{ MainLoop };
my $mw = 'MainWindow'->new;
$mw->iconimage($mw->Pixmap(-data => << '__XPM__'));
/* XPM */
static char * pm_xpm[] = {
"32 32 4 1",
" c black",
". c blue",
"X c yellow",
"o c red",
" ",
" .............................. ",
" .............................. ",
" .............................. ",
" .............................. ",
" .............................. ",
" .............................. ",
" .............................. ",
" .............................. ",
" ..........ooooooo............. ",
" ........ooooooooooo........... ",
" .......oo.........oo.......... ",
" ......oo...XXXXX...oo......... ",
" .....oo...X.....X...oo........ ",
" .....oo..X.......X..oo........ ",
" .....oo..X.......X..oo........ ",
" .....oo...X.....X...oo........ ",
" ......oo...XXXXX...oo......... ",
" .......oo.........oo.......... ",
" ........ooooooooooo........... ",
" ..........ooooooo............. ",
" .............................. ",
" .............................. ",
" .............................. ",
" .............................. ",
" .............................. ",
" .............................. ",
" .............................. ",
" .............................. ",
" .............................. ",
" .............................. ",
" "};
__XPM__
MainLoop();
map{substr$_->[0],$_->[1]||0,1}[\*||{},3],[[]],[ref qr-1,-,-1],[{}],[sub{}^*ARGV,3]
| [reply] [d/l] [select] |
Hello choroba, thank for the reply.
After I attempted to use your solution I've got an error message:
.../bin>windows_list_scrollable_gnome_terminal &
[1] 1970608
.../bin>Semicolon seems to be missing at windows_list_scrollable_gnome
+_terminal line 508.
syntax error at windows_list_scrollable_gnome_terminal line 469, near
+"* pm_xpm["
Execution of windows_list_scrollable_gnome_terminal aborted due to com
+pilation errors.
Line #508 is the line after
__XPM__
I thought a semicolon had been forgotten, added it after __XPM__
and got another error message:
.../bin>windows_list_scrollable_gnome_terminal &
[1] 1972397
.../bin>syntax error at windows_list_scrollable_gnome_terminal line 46
+9, near "* pm_xpm["
Bareword "__XPM__" not allowed while "strict subs" in use at windows_l
+ist_scrollable_gnome_terminal line 469.
Execution of windows_list_scrollable_gnome_terminal aborted due to com
+pilation errors.
Does "__XPM__" is supposed to be a label in the code, an address of which is passed by "-data => << '__XPM__')"?
TIA!
| [reply] [d/l] [select] |
Very probably this is a subsequential error. Do you get the same error when you try choroba's code unedited as a standalone script?
| [reply] |
Some more info:
In addition to attempting the "inline" XPM code, I also tried creating XPM file.
After few format errors I got it to load but the result was the same blank (gray) square.
I also attempted PBM file (tried P1 and P4).
The P1 file loaded without errors but resulted in the same blank (gray) square.
Attempt to create and load P4 file resulted in format error.
I also created a JPG file from the PNG file, it too loaded without errors but resulted in the
same blank square.
I think that in all cases where I didn't have format errors, the PerlTk could read the image correctly
and produce it's own internal image data correctly but somewhere "at higher authority", somewhere
"under the hood" of EL8+GNOME3 the application image had been overriden by the OS and the GNOME3.
Can it be the case?
TIA!
| [reply] |
Hi kaza_perl_ip, another option for Photo is to use base64 encoded data using the -data argument instead of the -file argument.
A solution I used was to store the base64 encoded value in a variable and pass it to the -data argument to Photo.
Untested sample foo code...
my $encodedImg = q{very long
multi line
multi line
multi line
multi line
multi line
multi line
multi line
multi line
multi line
multi line
multi line
encoded data};
my $can_encImg = $canvas->Photo( -data => $encodedImg );
Hope it helps! | [reply] [d/l] |