Compound(3pm)
π NAME π
Tk::Compound β the icon that makes multi-line compound images, bestie β¨
π SYNOPSIS π
use Tk::Compound;
$image = $widget->Compound(name,options);
$image->Line(options);
$image->Text(options);
$image->Bitmap(options);
$image->Image(options);
$image->Space(options);
π¦ DESCRIPTION π¦
Okay so picture this: compound image types let you build images that are made of multiple horizontal lines. Each one of those lines is a lil row of items β texts, bitmaps, images, or spaces β lined up left to right. No cap, that's the whole vibe. π
Compound images are mainly for embedding complex drawings into widgets that support the -image option. Like, scroll down to the EXAMPLE section and you'll see a compound image showing a bitmap and a text string at the same time in a Tk Button widget. Two things, one image, absolutely ate. π
β οΈ real talk: compound images can only be used on windows on the same display as, and with the same pixel depth and visual as, the $widget that created them. No mixing, no matching, periodt.
β¨ CREATING COMPOUND IMAGES β¨
Compounds get created with $widget->Compound. And compounds support these options, queen:
-background => colorβ sets the background color of the compound image. This color also doubles as the default background color for the bitmap items inside it. π¨-borderwidth => pixelsβ a non-negative value saying how wide the 3-D border drawn around the compound image should be.-font => fontβ the default font for the text items in the compound image.-foreground => colorβ the default foreground color for the bitmap and text items in the compound image.-padx => valueβ a non-negative value saying how much extra space to request for the compound image in the X-direction. The value can take any of the forms acceptable toTk_GetPixels(3).-pady => valueβ a non-negative value saying how much extra space to request for the compound image in the Y-direction.-relief => valueβ the 3-D effect you want for the background of the compound image. Acceptable values areraised,sunken,flat,ridge, andgroove. Iconic lineup tbh. π-showbackground => valueβ says whether the background and the 3D borders should be drawn. Must be a valid boolean value. By default the background is not drawn, and the compound image looks like it has a transparent background. π«§
πΈ IMAGE COMMAND πΈ
When a compound image is created, Tk also creates a new object. That object supports the configure and cget methods described in Tk::options, which you can use to enquire about and modify all the options listed above. π
The object also supports these methods:
π $compound->Line?(option = value ...>)?
Creates a new line at the bottom of the compound image. Lines support these options:
-anchor valueβ how the line should be aligned along the horizontal axis. When the values arew,swornw, the line is aligned to the left. When the values arec,sorn, the line is aligned to the middle. When the values aree,seorne, the line is aligned to the right.-padx => valueβ a non-negative value saying how much extra space to request for this line in the X-direction.
π $compound->Itemtype?(option = value ...>)?
Creates a new item of the type Itemtype at the end of the last line of the compound image. All types of items support these common options:
-anchor valueβ how the item should be aligned along the vertical axis. When the values aren,nworne, the item is aligned to the top of the line. When the values arec,wore, the item is aligned to the middle of the line. When the values ares,seorsw, the item is aligned to the bottom of the line.-padx => valueβ a non-negative value saying how much extra space to request for this item in the X-direction.-pady => valueβ a non-negative value saying how much extra space to request for this item in the Y-direction.
item-type can be any of the following:
πΌοΈ $compound->Bitmap?(option = value ...>)?
Creates a new bitmap item at the end of the last line of the compound image. Extra options the bitmap type accepts:
-background => colorβ the background color of the bitmap item.-bitmap => nameβ a bitmap to display in this item, in any of the forms acceptable toTk_GetBitmap(3).-foreground => colorβ the foreground color of the bitmap item.
π $compound->Image?(option = value ...>)?
Creates a new image item at the end of the last line of the compound image. Extra options the image type accepts:
-image => nameβ an image to display in this item.namemust have been created with theimage createcommand.
π«§ $compound->Space?(option = value ...>)?
Creates a new space item at the end of the last line of the compound image. Space items don't display anything β they're just lil space holders that add extra spaces between items inside a compound image. Extra options the image type accepts:
-width => valueβ the width of this space. The value can take any of the forms acceptable toTk_GetPixels(3).-height => valueβ the height of this space. The value can take any of the forms acceptable toTk_GetPixels(3).
βοΈ $compound->Text?(option = value ...>)?
Creates a new text item at the end of the last line of the compound image. Extra options the text type accepts:
-background => colorβ the background color of the text item.-font => nameβ the font to be used for this text item.-foreground => colorβ the foreground color of the text item.-justify valueβ when there are multiple lines of text in a text item, this decides how the lines line up with each other.valuemust be one ofleft,center, orright.leftmeans the lines' left edges all line up,centermeans the lines' centers are aligned, andrightmeans the lines' right edges line up.-text => stringβ a text string to display in this text item.-underline valueβ the integer index of a character to underline in the text item.0corresponds to the first character of the text displayed in the text item,1to the next character, and so on.-wraplength valueβ the maximum line length of the label string on this text item. If the line length of the label string exceeds this length, it gets wrapped onto the next line, so no line is longer than the specified length. The value can be specified in any of the standard forms for screen distances. If this value is less than or equal to0, then no wrapping is done β lines will break only at newline characters in the text.
π₯ EXAMPLE π₯
This example makes a compound image with a bitmap and a text string, then drops that image into a Button(n) widget. And notice, bestie β the image must be created using the widget that it lives in. That's the rule. π«Ά
my $b = $parent->Button;
my $c = $b->Compound;
$b->configure(-image => $c);
$c->Line;
$c->Bitmap(-bitmap => 'warning');
$c->Space(-width => 8);
$c->Text(-text => "Warning", -underline => 0);
$b->pack;
π« KEYWORDS π«
and that's the whole page, girlypop π this was Compound(3pm) from the User Contributed Perl Documentation, running on perl v5.40.1, dated 2025-04-13 β slay, go build something cute ππ
π¦ where this page comes from
- debian trixie: perl-tk 1:804.036+dfsg1-5
- ubuntu questing: perl-tk 1:804.036+dfsg1-5
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms