# Icon questions

**URL:** <https://www.ruby-forum.com/t/icon-questions/187472>\
**Category:** wxRuby\
**Created:** [April 23, 2010, 6:10pm UTC](https://www.ruby-forum.com/t/icon-questions/187472 "2010-04-23T18:10:28Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![rogerscardua](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/7ba0ec/32.png) [@rogerscardua](https://www.ruby-forum.com/u/rogerscardua)\
**Post date:** [April 23, 2010, 6:10pm UTC](https://www.ruby-forum.com/t/icon-questions/187472/1 "2010-04-23T18:10:28Z")

</div>

I’m working on my first wxRuby project.

Because the example files are on a different drive, I copied the  
wxruby.png icon file to the same directory as my ruby program.

The titlebar icon and Taskbar icon (I’m on a WinXP machine) showed up  
fine.

When I substitute an alternate 32x32 .png image, it doesn’t:

```
# Give the frame an icon. Try an alternate to the default wxruby

```

icon  
icon\_file = File.join( File.dirname( **FILE** )+"/", “slate.png”)

# icon\_file = File.join( File.dirname( **FILE** )+"/", “wxruby.png”)

```
self.icon = Wx::Icon.new(icon_file)

```

When I open wxruby.png in Photoshop Elements, it seems a normal 32x32  
png file with transparency. If I save slate.png in the .ico format,  
WinXP does use it, but seems to shrink it to 24x24 or maybe 16x16 or  
something smaller in both the toolbar and Taskbar, but shows a very  
clear and crisp image in the Task Switcher (alt-Tab), which is clearly  
larger than the toolbar icon. (In other words, it looks like the Task  
Switcher is using it at 32x32.)

I know that icons in various sizes are needed, and the art folder in the  
examples has the wxRuby image in 64x64, 128x128 and 256x256 sizes in  
addition to the 32x32 .png. I’ve also read somewhere that WinXP expects  
a 16x16 for the toolbar.

When people say “use .png for the icon” so that it can be used  
cross-platform, there seems to be another layer of information I’m  
missing. Where can I find out more about what wxRuby or wxWidgets  
expects?

Thanks,

Roger S.  
rsperberg at gmail

---

<div class="post-metadata">

**Author:** ![rogerscardua](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/7ba0ec/32.png) [@rogerscardua](https://www.ruby-forum.com/u/rogerscardua)\
**Post date:** [April 23, 2010, 10:32pm UTC](https://www.ruby-forum.com/t/icon-questions/187472/2 "2010-04-23T22:32:11Z")

</div>

On 23/04/2010 17:10, Roger S. wrote:

> I know that icons in various sizes are needed, and the art folder in the  
> examples has the wxRuby image in 64x64, 128x128 and 256x256 sizes in  
> addition to the 32x32 .png. I’ve also read somewhere that WinXP expects  
> a 16x16 for the toolbar.
> 
> When people say “use .png for the icon” so that it can be used  
> cross-platform, there seems to be another layer of information I’m  
> missing. Where can I find out more about what wxRuby or wxWidgets  
> expects?

In the documentation, though it’s nowhere that someone new and asking  
the very sensible questions that you ask would find it. The same  
question puzzled me for a long time using wxWidgets, until I pretty much  
stumbled on (part of) the answer.

Frame inherits it #set\_icon (or #icon=) method from Wx::TopLevelWindow.  
TLW also has a method #set\_icons/#icons= which accepts an object of  
class Wx::IconBundle. IB can contain multiple icons at different sizes,  
for use in different places.

[http://wxruby.rubyforge.org/doc/toplevelwindow.html#TopLevelWindow\_seticons](http://wxruby.rubyforge.org/doc/toplevelwindow.html#TopLevelWindow_seticons)

The next question you might have on icons, since you’re trying out on OS  
X, is why set\_icon(s) doesn’t affect an app’s Dock icon. This is because  
wxWidget’s treats the OS X Dock as analogous to the system tray on  
Windows, so you use Wx::TaskBarIcon instead. Under Apple’s interface  
guideliens, the area next to the clock is reserved for system apps - not  
user apps.

So the answer to your question is “in several different places”. This ml  
is happy to help, and I’ve learnt a vast amount from responses to  
wxPython and wxWidgets questions. A search term with class and method  
names according to C++ / Python conventions can be fruitful, eg:

> **[Google Search](http://www.google.co.uk/search?q=wxframe+SetIcon+different+sizes)**

best  
alex
