Re: Set Icon
by kcott (Archbishop) on Dec 22, 2020 at 19:39 UTC
|
G'day PilotinControl,
If you're interested in icons that are a little fancier that solid squares,
check out "Perl/Tk Transparent Icons".
The page itself is rather old; it was last updated in 2007.
I only found it a month or two ago when I was trying to create a hexagonal icon.
The Perl code, as far as I remember, was all valid and I didn't need to change or fix anything.
Some of the Gimp instructions were a little dated;
however, it was easy enough to adjust the 2007 instructions for my 2019 Gimp version.
I've never used any modules in the Win32:: namespace — I can't offer any help with that part of your question.
| [reply] [d/l] |
Re: Set Icon
by Bod (Parson) on Dec 22, 2020 at 18:28 UTC
|
use Tk;
use Tk::PNG;
my $tk_win = new MainWindow;
my $icon = $tk_win->Photo(-width => 32, -height => 32, -file => 'files
+/icon.gif');
$tk_win->iconimage($icon);
| [reply] [d/l] |
|
| [reply] |
|
Hello PilotinControl
I have been playing with Tk a little bit recently, but the question of whether Win32::Console does, in terms of icons, what Tk does seems a little off the mark.
Tk and Console are two different applications. When you ask does this work with Console in the same way, I think you need to explain in a little more detail what it is that you are trying to do that should be the same for both Tk and Console.
Win32::Console provides an api for interacting with the console, whereas Icons are usally an aspect of the window manager. In Tk terms you could think of Console as a special type of interactive Text widget, housed within a Top-Level frame.
It doesnt really make sense to output an icon to a Text widget, although not saying that cannot be done, however consider the prevalance of ascii art on consoles. The smallest units of the console screen or output buffer is the character/font. Whereas the window manager needs to place an icon within say a top-level window bar, or for example on the desktop screen if the app is minimized.
For Win32::Console to do something like this you might have to look for a related namespace that interacts with the window-manager of the console, rather than the console itself. Are you trying to create a new application or a new shell?
I would suggest to continue hacking on Tk. And to gain better insight to differences of the screen and the widget also revisit the geometry managers, as well as the seemingly innocuous entry and scrollbar widgets. Understanding these widgets properly, as well as how the Top-Level windows interact may help towards understanding issues around when and where icon images can be used.
If you have a bit of time of the holidays, maybe try using different geometry managers to position the widgets within different top-level windows. This is actually a very insightful practice.
Of course, if I have missed the point of what it is you are trying to do, please do re-iterate in a little more detail what it is you are trying to achieve with Win32::Console that you are achieving with Tk::*
hope this helps
| [reply] |
|
|
|
| [reply] |
|
Re: Set Icon
by Discipulus (Canon) on Dec 22, 2020 at 18:53 UTC
|
my $mw = MainWindow->new ();
$mw->Icon(-image => $mw->Pixmap(-data => &tart_icon));
# ...
sub tart_icon {
return <<EOI
/* XPM */
static char * Icon_xpm[] = {
"32 32 4 1",
" c #000000000000",
"g c #00FF00",
"X c #FF0000",
"D c #FFFF00",
" ",
" ",
# ...
See the sub returning the icon
L*
There are no rules, there are no thumbs..
Reinvent the wheel, then learn The Wheel; may be one day you reinvent one of THE WHEELS.
| [reply] [d/l] |
Re: Set Icon
by Bod (Parson) on Dec 23, 2020 at 23:19 UTC
|
Win32 Console code below:
sub icon {
my $sIcon = Win32::Console::SetIcon("logo.gif");
}
Thanks in advance!
According to the Win32::Console documentation, a *.ico file is required not a *.gif file and the syntax is:
$CONSOLE->SetIcon("C:/My/Path/To/Custom.ico");
so I would try something like....
my $CONSOLE = Win32::Console->new;
$CONSOLE->SetIcon('C:/myIcon.ico');
or...
Win32::Console->SetIcon('C:/myIcon.ico');
These are untested but might provide you with some some progress! | [reply] [d/l] [select] |
|
Confirmation: start perl -MWin32::Console -e "my $C=Win32::Console->new(); $C->SetIcon('pp.ico'); $C->Title('Hello World'); sleep 10" worked for me. However, if I tried to run that without the start, the title would change but the icon would not. But that experiment also showed that the icon file can be relative (mine was in the current directory) rather than having to specify the whole path.
| [reply] [d/l] [select] |
|
| [reply] |
|
|
|
| [reply] |