Re: How to access a bitmap object after defining it with DefineBitmap?
Craig Votava <[email protected]> Fri, 16 Jul 2010 09:19:10 -0500
| Newsgroups | gmane.comp.lang.perl.tk |
|---|---|
| Message-ID | <[email protected]> |
Hi Jack-
Thanks for the response, I see how changing the way I define the
bitmap will get me access to what I'm looking for.
Does this mean that there is a "hole" in Ptk, with respect to
DefineBitmap? I imagine that after using DefineBitmap, there is an
object available somewhere in memory, but there doesn't seem to be a
way of referencing it. The activestate documentation (http://tcl.activestate.com/man/tcl8.4/TkCmd/bitmap.htm#M12
) states:
> 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 ...?
This leads me to believe that I have access to a new Tk command that
was generated by using DefineBitmap. Is there a way to access this new
Tk command from pTk?
I dug around in my ptk email archive and came up with the following,
but I can't seem to figure out how to complete the format command that
Nick (RIP) talks about. Any thoughts would be appreciated.
On Jul 10, 1997, at 12:52 PM, Nick Ing-Simmons wrote:
> Brent B Powers wrote:
>>
>> Is there a way to create a bitmap without having it in a file? Docs
>> say ... in any format acceptable to Tk_CreateBitmap..., but I've not
>> found what those might be.
>>
>> What I'm actually looking for is
>>
> In Tk402.001 you can say:
>
> $widget->DefineBitmap("name",$width,$height,$data);
> ...
> ->configure(-bitmap => "name",...)
>
> perl's pack is good for building $data.
>
> (I cannot find my example...)
>
> I put this in for Graham, but I cannot find (quickly)
> and example in his directory either.
Thanks
-Craig
On Jul 15, 2010, at 7:43 PM, Jack wrote:
> My apologies for the top-post.
>
> If you consider changing your method of defining a bitmap then you can
> access and change the object. Here is a sample:
>
> ###############################
> use strict;
> use warnings;
>
> use Tk;
> use Tk::Bitmap;
>
> my $top = MainWindow->new();
> my $anchorbits = qq(
> #define anchor.xbm_width 16
> #define anchor.xbm_height 16
> static char anchor.xbm_bits[] = {
> 0x00, 0x00, 0xe0, 0x07, 0xe0, 0x07, 0x80, 0x05, 0x80, 0x05, 0x80,
> 0x05,
> 0x80, 0x03, 0x80, 0x01, 0x9e, 0x79, 0x8e, 0x71, 0x8e, 0x71, 0x8a,
> 0x51,
> 0x90, 0x09, 0xe0, 0x07, 0x80, 0x01, 0x00, 0x00};
> );
>
> my $bitmap = $top->Bitmap('anchor',-data=>$anchorbits);
> my $button = $top->Button(-image=>'anchor')->pack();
>
> #Turn background of bitmap to a red after 5 seconds..
> $top->after(5000,sub {
> $bitmap->configure(-background=>'red');});
>
> MainLoop();
> __END__
> ###############################
>
> Jack..
>
> -----Original Message-----
> From: [email protected] [mailto:[email protected]
> ]
> On Behalf Of Craig Votava
> Sent: July-15-10 8:20 AM
> To: PerlTk List
> Subject: How to access a bitmap object after defining it with
> DefineBitmap?
>
> Folks-
>
> Given the attached program, how can I access the 'arrowDn' bitmap
> object that got created by DefineBitmap? I'd like to be able to
> manipulate both the -background value and the -data value.
>
> This question is also online at: http://www.perlmonks.org/?node_id=849564
>
> Thanks
> -Craig
>
> 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();
>
> MainLoop();
> --++**==--++**==--++**==--++**==--++**==--++**==--++**==
> ptk mailing list
> [email protected]
> https://mailman.stanford.edu/mailman/listinfo/ptk
>
>
> No virus found in this incoming message.
> Checked by AVG - www.avg.com
> Version: 9.0.830 / Virus Database: 271.1.1/3008 - Release Date:
> 07/15/10
> 12:35:00
>
--++**==--++**==--++**==--++**==--++**==--++**==--++**==
ptk mailing list
[email protected]
https://mailman.stanford.edu/mailman/listinfo/ptk