I'm replying only because nobody else seems willing to and not because I have the answer you're seeking. The short answer seems to be: no, but it might be platform dependent. The semi-official RubyTk documentation <http://www.jbrowse.com/text/rubytk_en.html> that I consulted gives the following example:
<example>
Tk::Wm#iconbitmap(bitmap=None)
Sets the bitmap displayed in the icon to bitmap.
If nil is passed, the icon's bitmap setting is erased. If the argument is omitted, the current setting is returned.
require "tk"
Tk.root.iconify
p Tk.root.iconbitmap "question"
p Tk.root.iconbitmap
Tk.mainloop
=> ""
"question"
</example>
Perhaps this code can change the window icon on platforms running X-Window/Motif, but I can't say from experience.
Running it on my platform, OS X with Aqua, produces no visible effect. But how could it? From OS X's point of view the Ruby program is a Unix command line session, and it displays the appropriate icon for such a session in the dock. If I minimize a Tk window, I get a bitmap thumbnail of the running window in the dock (again normal for OS X).
On OS X, I could get a custom icon by making the Ruby program a component of an application package (bundle) containing an icon resource, an info.plist file, and a launcher script written in AppleScript. On MS Windows, it's probably all very different. I wouldn't have a clue on how get a custom program icon there.
Regards, Morton
···
On Aug 21, 2006, at 9:18 PM, Dave Mihalik wrote:
Does anyone know if it is even possible to change the window icon using
Ruby and Tk?
Standard Tcl/Tk has image handlers for PPM, PGM and GIF.
(Please see Tcl/Tk's "photo" comman manual.)
To support other image formats (e.g. JPEG), Img package is required.
When Img package is installed for your Tcl/Tk (which linked to Ruby/Tk),
you can use Img package by "require 'tkextlib/tkimg'".
···
From: Zoltán Hajdú <lists@ruby-forum.com>
Subject: Re: How do I set the icon for a window using Ruby Tk?
Date: Sat, 04 Jan 2014 20:27:16 +0100
--
Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
Department of Artificial Intelligence, Kyushu Institute of Technology