Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

How to set background Color on bitmap when creating with DefineBitmap?

by cmv (Chaplain)
on Jul 14, 2010 at 16:36 UTC ( #849564=perlquestion: print w/ replies, xml ) Need Help??
cmv has asked for the wisdom of the Perl Monks concerning the following question:

Monks-

This should be simple, but I can't seem to get it...

I want to create a bitmap with a particular background color. Here's how I create the bitmap:

my $arrowDnBits = pack("b8" x 5, "........", ".111111.", "..1111..", "...11...", "........"); $top->DefineBitmap('arrowDn' => 8, 5, $arrowDnBits);

Where do I specify -background=>'red' in the above code?

DefineBitmap doesn't return anything, so I can't access it that way and it doesn't allow any options on the command line either.

How do I do this?

Thanks

-Craig

Update:

Found some additional (hopefully helpful) information from the activestate manuals as follows:

When a bitmap image is created, Tk also creates a new command whose name is the same as the image. This command may be used to invoke various operations on the image. It has the following general form:

imageName option ?arg arg ...?

Option and the args determine the exact behavior of the command. The following commands are possible for bitmap images:

imageName cget option

Returns the current value of the configuration option given by option. Option may have any of the values accepted by the image create bitmap command.

Unfortunately, none of these seem to work:

$top->configure(-bitmap=>'arrowDn', -background=>'red'); $top->image(-bitmap=>'arrowDn', -background=>'red'); $top->arrowDn(-background=>'red');

Comment on How to set background Color on bitmap when creating with DefineBitmap?
Select or Download Code
Re: How to set background Color on bitmap when creating with DefineBitmap?
by Anonymous Monk on Jul 14, 2010 at 20:55 UTC
      Here's a quick example:
      use strict; use warnings; use Tk; my $top = MainWindow->new(); my $arrowDnBits = pack("b8" x 5, "........", ".111111.", "..1111..", "...11...", "........" ); $top->DefineBitmap('arrowDn' => 8, 5, $arrowDnBits); $top->Button(-bitmap=>'arrowDn')->pack(-side=>'left'); MainLoop();
      Note: It is possible to set -background=>'red' when you create the button (which will get the button code to go and set the bitmap background for you), but that is not what I want. I'm trying to figure out how to set the bitmap -background directly, or possibly another bitmap option like -data.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://849564]
Approved by ww
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others imbibing at the Monastery: (7)
As of 2014-12-26 04:16 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (165 votes), past polls