By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
437,777 Members | 1,755 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 437,777 IT Pros & Developers. It's quick & easy.

TK change color of line in Text widget

P: 62
Hi!

Its possible, to change the color of characters line by line in a Text widgets?
See:
"characters of line1" #color of this line is red
"characters of line2" #color of this line is green
....


Thanks!
Oct 16 '08 #1
Share this Question
Share on Google+
3 Replies


P: 34
Use "foreground" option for text widget with 'configure' method..
Oct 18 '08 #2

nithinpes
Expert 100+
P: 410
Use "foreground" option for text widget with 'configure' method..
Using configure() method with '-foreground' option, you can set the text color for entire text box. I don't think that can be used to set color for each line of data in textbox.
Oct 18 '08 #3

nithinpes
Expert 100+
P: 410
Using configure() method with '-foreground' option, you can set the text color for entire text box. I don't think that can be used to set color for each line of data in textbox.
This can be done. Try the following approach:
Expand|Select|Wrap|Line Numbers
  1. $tx->tag(qw/configure color1 -foreground red/);
  2. $tx->tag(qw/configure color2 -foreground green/);
  3. $tx->tag(qw/configure color3 -foreground blue/);
  4. $tx->tag(qw/configure color4 -foreground black/);
  5.  
  6. $tx->insert('insert', "characters of line1\n", 'color1');
  7. $tx->insert('insert',"characters of line2\n", 'color2');
  8. $tx->insert('insert',"characters of line3\n", 'color3');
  9. $tx->insert('insert',"characters of line4\n", 'color4');
  10.  
Oct 18 '08 #4

Post your reply

Sign in to post your reply or Sign up for a free account.