Version 18 of Add tk fontchooser Dialogue To tkcon prefrences menu

Updated 2015-05-28 15:33:55 by Superlinux

This Article now is deprecated. Please go to this article. 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.

You can also watch this youtube that explains the steps below.

So, this is what you should do:

  • In Linux, Open and edit the file /usr/bin/tkcon using any text editor. If you're on Windows, then open the bin directory of your ActiveTcl and edit tkcon.tcl
  • 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).

Superlinux - 2014-08-08 16:40:23

OK! thanks. let's say you copied the original tkcon to the new name tkcon.original, then diff -u tkcon.original tkcon gives this result:

--- tkcon.original        2014-08-08 19:19:25.921739806 +0300
+++ tkcon        2014-08-04 12:11:33.123918860 +0300
@@ -82,6 +82,10 @@
     variable EXPECT 0
+proc ::tkcon::fontchooserFontSelection {w font args} {
+    $w configure -font [font actual $font]
 ## ::tkcon::Init - inits tkcon
 # Calls:        ::tkcon::InitUI
@@ -1606,6 +1610,11 @@
                 -underline 1 -variable ::tkcon::OPT(calcmode)
+        $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)] 
+           }
         if {!$PRIV(AQUA)} {
             $m add check -label "Show Menubar" \

ak - 2014-09-05 20:49:08

Jeff (author of Tkcon) tells me that the patch is not quite correct. He said that it should use the tkcon font command as that carries the value across console windows, and that he is using Tk fonts.