Version 12 of Add tk fontchooser Dialogue To tkcon prefrences menu

Updated 2014-08-04 10:26:58 by RLE

Hi.

I know many finds it hard to change tkcon console font the first time they use it if they are not told that tkcon has command line options. One of the options is the -font .

Today, I edited the script of tkcon.tcl to let it use the command tk fontchooser . The tk fontchooser helps you choose the font you like for the widget/window path you want.

So, this is what you should do:

  • Open and edit the file /usr/bin/tkcon using any text editor.
  • Inside the namespace ::tkcon , make a space around line 85, that's just before the line containing ## ::tkcon::Init - inits tkcon, to add the following procedure:
proc ::tkcon::fontchooserFontSelection {w font args} {

    $w configure -font [font actual $font]
}
  • Search and look now where it talks about adding menu items in the prefs menu . It's around line 1590. You should find a comment saying ## Prefs Menu.
  • Below it, there is the loop foreach m [list [menu $w.prefs] [menu $w.pop.prefs] . Inside this foreach loop add the following menu item code:
$m add command -label "Console Font" -command {
           tk fontchooser show
           tk fontchooser configure -font [ $::tkcon::PRIV(console) cget -font ] \
            -command [list ::tkcon::fontchooserFontSelection $::tkcon::PRIV(console)]
           }
  • Save the changes you've just made and restart tkcon. You should find a new menu item in the prefs menu named Console Font. Enjoy!

RLE (2014-08-04): A "diff -u" between the original and your modified tkcon file would also be useful to post. The diff has two advantages:

  1. it shows the changes relative to the original;
  2. it can be automatically applied by the patch command (so no "searching" on the part of users through the file to find the right spot).