Tk buttons with images?

Hello Ive been playing around with ruby Tk to build a UI for a few new
music ruby apps I was wondering if anyone knew how to get a image to
display for a button? Ive looked around but didn’t find any real world
examples

Thanks Gabriel

From: GabrielG1976 [email protected]
Subject: Tk buttons with images ?
Date: Fri, 11 Dec 2009 08:40:08 +0900
Message-ID:
[email protected]

music ruby apps I was wondering if anyone knew how to get a image to
display for a button? Ive looked around but didn’t find any real world

Please create a TkPhotoImage object and ‘image’ option of button
widgets.
For example,

img = TkPhotoImage.new(:file=>your_image_file_name)
btn = TkButton.new(base, :image=>img).pack

See the Ruby/Tk WidgetDemo (ext/tk/sample/demos-en/widget on a Ruby
source). It includes examples of label widgets with a image.
TkButton class is a subclass of TkLabel.
So, same ways are available for button widgets.

Standard Tcl/Tk can support only GIF and PPM/PGM formats.
If you want to use other formats (BMP, JPEG, PNG, and so on),
you must use TkImg extention (ActiveTcl package includes TkImg
extension).

When “require ‘tkextlib/tkimg’” returns true,
your Ruby/Tk (Tcl/Tk) has TkImg extension.
Otherwise, you must install TkImg extension for your Tcl/Tk
libraries which used by Ruby/Tk.