in reply to Set Icon

In a couple of Tk apps running on Windows 10 I have this....

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);

Replies are listed 'Best First'.
Re^2: Set Icon
by PilotinControl (Pilgrim) on Dec 22, 2020 at 18:48 UTC

    Thanks BOD! That worked perfectly for the TK app. Would this work for the Win32::Console app too?

      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

        Hello Don,
        I am working on 2 different applications. The Tk problem has been solved however the Win32 issue is still there. the $console->SetIcon as described in the Win32::Console write up isn't working as it should and I am sure I am missing something as everything else is working as described such as: Cursor positions, console sizes etc. Thanks for the advice!

        @BOD
        What you provided was a great help and worked! I'm sure someone on here has Win32-Console experience that can help.