How to use "new" method of TkImage

Thanks,I know how to create a photoimage, but I don't know how to use

Image.new;can it create a new image?According to the Rdoc, should be
"new(keys=nil)".Thanks again.

===== Original Message From ts <decoux@moulon.inra.fr> =====

···

  TkImage.new{type "phoimage"
                        file "xxxx.gif"
                        }

Apparently you want a PhotoImage, try

   TkPhotoImage.new { file "xxxx.gif" }

Guy Decoux

Thanks,I know how to create a photoimage, but I don't know how to use

Image.new;can it create a new image?According to the Rdoc, should be
"new(keys=nil)".Thanks again.

The best is to do like ruby, i.e. to create a subclass of TkImage to
define @type and then call super. For example, TkPhotoImage do

   class TkPhotoImage < TkImage
      def initialize(*args)
         @type = 'photo'
         super
      end
      # etc
   end

There is only one problem : in tcl/tk it exist *only* 2 types of Image
defined by tk :
   * 'photo' defined by TkPhotoImage
   * 'bitmap' defined by TkBitmapImage

This mean that if you want to use an Image, you must fatally use
TkImagePhoto or TkBitmapImage. TkImage is useless for you except if you
use an tcl/tk extensions which define its own image type.

Guy Decoux

Thank you very much.Now I know why I cannot find any example of how to use
TkImage.

Maggie

···

----- Original Message -----
From: “ts” decoux@moulon.inra.fr
To: “ruby-talk ML” ruby-talk@ruby-lang.org
Cc: ruby-talk@ruby-lang.org; ruby-talk@ruby-lang.org
Sent: Sunday, July 21, 2002 9:27 AM
Subject: Re: How to use “new” method of TkImage

Thanks,I know how to create a photoimage, but I don’t know how to use
Image.new;can it create a new image?According to the Rdoc, should be
“new(keys=nil)”.Thanks again.

The best is to do like ruby, i.e. to create a subclass of TkImage to
define @type and then call super. For example, TkPhotoImage do

class TkPhotoImage < TkImage
def initialize(*args)
@type = ‘photo’
super
end
# etc
end

There is only one problem : in tcl/tk it exist only 2 types of Image
defined by tk :

  • ‘photo’ defined by TkPhotoImage
  • ‘bitmap’ defined by TkBitmapImage

This mean that if you want to use an Image, you must fatally use
TkImagePhoto or TkBitmapImage. TkImage is useless for you except if you
use an tcl/tk extensions which define its own image type.

Guy Decoux