[KWWidgets] suggestion for icon method

Steve Pieper pieper at bwh.harvard.edu
Sat Jul 21 11:23:46 EDT 2007


Hi Sabastien -

In the interest of full disclosure I should mention that the other 
reason I wanted this method is because it wraps; everything else I saw 
required C++.  So I had to add the 2-3 lines of code somewhere and I'd 
still think vtkKWIcon is probably the right place for it in the long term.

In general though I think being able to use VTK to dynamically read and 
process icon images from all languages makes sense for kwwidgets, in 
addition to the compile-time resource framework (which also sounds handy).

Thanks,
Steve

Sebastien BARRE wrote:
> At 7/20/2007 07:38 PM, Steve Pieper wrote:
>> Hi -
>>
>> Today I had a situation where I wanted to use a vtkImageData to set 
>> the image for an vtkKWPushButton, but I couldn't find any easy way to 
>> do it.  All of the vtkKWIcon::SetImage methods take lower-level 
>> arguments.  So I added the following routine to one of my classes as a 
>> helper.  Once I have the image in the icon, I use 
>> vtkKWPushButton::SetImageToIcon to load it into the button.
> 
> I see what you mean.
> 
> In the past, the rational for not adding this new SetImage method is 
> that it does not bring enough (it only saves you 2 or 3 lines of code 
> for something that is typically not big at all compared to the rest of 
> the UI code), and is not orthogonal.
> 
> But the problem is that the current methods are actually all bad :) At 
> the end of the day what we needed is a resource framework, where you can 
> refer to bitmaps and images to assign to buttons or labels as a simple 
> resource name (which is what SetImageToPredefinedIcon is the closest to) 
> . The resource framework would be a class to load bitmaps in memory, 
> create collections of them, eventually assign them to namespace, etc.
> http://www.kwwidgets.org/Wiki/KWWidgets/Resource_Manager
> 
> As you pointed out accurately, this is all too low level. Bear in mind 
> that in the past all buttons had some different methods (or none) to 
> assign images to them, it was a mess. We tried to unify it with a set of 
> methods that you see now, while trying not to add *tons* of them. There 
> are already *4* methods to assign an image to a button, that's a lot, 
> and each time several classes have to be synchronized with the same API 
> because they do not (cannot) share the same superclass (say labels and 
> buttons). By keeping the number of methods low, this would make much 
> easier to transition to the resource framework.
> 
> I know this is not in our/your TODO, but last week for example Wendy 
> asked how to set her custom checkbutton/radiobutton to an image, and I 
> could only direct her to painfully create a Tk photo with 
> vtkKWTkUtilities, then assign it to the button using 
> SetConfigurationOption("-image"...). This is way too low level sadly, 
> and that where a resource framework would be neat.
> 



More information about the KWWidgets mailing list