hxdhan has asked for the wisdom of the Perl Monks concerning the following question:

Hi all, I want to insert image to Tk::Text which align right. when insert text justify right,I can use
$t->tagConfigure('right', -justify => 'right'); $t->insert('end',"test.\n",'right');
but
$t->imageCreate ('end',-image => $image ,'right');
function imageCreate cat not create by this. any suggestion?

Replies are listed 'Best First'.
Re: insert image to Tk::Text justify question
by zentara (Cardinal) on Nov 03, 2011 at 10:21 UTC
    If you read perldoc Tk::Text, in the section called EMBEDDED IMAGES, it says that only -align, -padx, and -pady are supported for images. The align won't set to 'right', so you will have to use the -padx setting.

    I'm not really a human, but I play one on earth.
    Old Perl Programmer Haiku ................... flash japh
Re: insert image to Tk::Text justify question
by keszler (Priest) on Nov 03, 2011 at 10:16 UTC

    The syntax for the Tk::Text imageCreate method is $text->imageCreate(index, ?option, value, ...?). The options are:

    -align => where -image => image -name => ImageName -padx => pixels -pady => pixels
    In your $t->imageCreate ('end',-image => $image ,'right');, the term 'right' does not belong.

    Further, the documentation states

    The embedded image's position on the screen will be updated as the text is modified or scrolled. Each embedded image occupies one character's worth of index space in the text widget
    If you need to force a specific location for the image you'll need to either strictly control the text in the Text widget and the size of that widget, or switch to using a Canvas.