[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

text tag configuration in rubytk

Len Lawrence

7/23/2008 8:01:00 PM

In the following code snippet I am trying to configure a tagged field
in a text widget but cannot figure out the syntax for the command.
The rubytk_en site seems to be down permanently so I have to ask
here. None of the other online documentation goes deep enough to
cover this topic.

month = Calendar::Month[k-1]
text = sprintf( " %3s %02d : %s\n", month, d, @@diary[j][i]
[2] )
$w.insert( 'end', text )
entry += 1
colour = Coding[Codex[code]][2]
$w.addtag( 'zib', "#{entry.to_s}.14", 'end' )

What I wish to do is translate the Tcl command

$w tag configure "zib" -foreground $colour

to rubytk. Any pointers?

I found the addtag method by trial and error but that approach did not
work for configure; i.e. there is no configuretag method.

Len
1 Answer

Len Lawrence

7/23/2008 9:36:00 PM

0

On Wed, 23 Jul 2008 20:00:44 +0000, Len Lawrence wrote:

> In the following code snippet I am trying to configure a tagged field in
> a text widget but cannot figure out the syntax for the command. The
> rubytk_en site seems to be down permanently so I have to ask here. None
> of the other online documentation goes deep enough to cover this topic.
>
> month = Calendar::Month[k-1]
> text = sprintf( " %3s %02d : %s\n", month, d, @@diary[j][i]
> [2] )
> $w.insert( 'end', text )
> entry += 1
> colour = Coding[Codex[code]][2]
> $w.addtag( 'zib', "#{entry.to_s}.14", 'end' )
>
> What I wish to do is translate the Tcl command
>
> $w tag configure "zib" -foreground $colour
>
> to rubytk. Any pointers?
>
> I found the addtag method by trial and error but that approach did not
> work for configure; i.e. there is no configuretag method.
>

Some more trial and error gave this, which works:

text = .....
$w.insert( 'end', text )
entry += 1
endpoint = sprintf( "%d.%d", entry, text.length )
colour = .....
$w.addtag( (t = "zib#{entry}"), "#{entry.to_s}.14", endpoint )
$w.tag_configure( t, 'foreground' => colour )

Len