title: How to set a Tkinter widget to a monospaced, platform independent font?
body: <p>It's said <a href="http://www.tkdocs.com/tutorial/fonts.html" rel="noreferrer">here</a> in the section  <em>Standard Fonts</em>:</p>
  
  <blockquote>
    <p>Particularly for more-or-less standard user interface elements, each
    platform defines specific fonts that should be used. Tk encapsulates
    many of these into a standard set of fonts that are always available,
    and of course the standard widgets use these fonts. This helps
    abstract away platform differences.</p>
  </blockquote>
  
  <p>And then in the predefined fonts list there is:</p>
  
  <blockquote>
    <p><strong><code>TkFixedFont</code></strong> <code>A standard fixed-width font.</code></p>
  </blockquote>
  
  <p>This also corresponds with what I could find here on the standard ways of choosing a monospaced, platform independent font in <code>Tkinter</code> like for example stated in <a href="https://stackoverflow.com/a/42332342/4465708">this answer</a>.</p>
  
  <p>Alas, when I try to do this on my own, like with the simple code below:</p>
  
  <pre><code>import tkinter as tk
  from tkinter import ttk
  
  root = tk.Tk()
  frame = ttk.Frame(root)
  style = ttk.Style()
  style.configure("Fixed.TButton", font=("TkFixedFont", 16))
  
  button = ttk.Button(text="Some monospaced text, hopefully", style="Fixed.TButton")
  frame.grid()
  button.grid(sticky="news")
  button.configure(text="I don't quite like this font.")
  </code></pre>
  
  <p>what I get is this:</p>
  
  <p><a href="https://i.stack.imgur.com/M8wQp.png" rel="noreferrer"><img src="https://i.stack.imgur.com/M8wQp.png" alt="TkFixedFont, size 16"></a></p>
  
  <p>That doesn't look like monospaced to me, so I check what exactly <code>Tkinter</code> translates <code>TkFixedFont</code> into on my platform with:</p>
  
  <pre><code>from tkinter import font
  font.nametofont("TkFixedFont").actual()
  </code></pre>
  
  <p>and the answer is:</p>
  
  <pre><code>{'family': 'DejaVu Sans Mono', 'size': 9, 'weight': 'normal', 'slant': 'roman', 'underline': 0, 'overstrike': 0}
  </code></pre>
  
  <p>So how does <code>DejaVu Sans Mono</code> look like?</p>
  
  <p><a href="https://i.stack.imgur.com/840Pz.png" rel="noreferrer"><img src="https://i.stack.imgur.com/840Pz.png" alt="DejaVu Sans Mono, size 16"></a></p>
  
  <p>The <em>Tkdocs.com tutorial</em> quoted above has also a section on <em>Named Fonts</em> and there it says:</p>
  
  <blockquote>
    <p>the names <strong><code>Courier</code></strong>, <code>Times</code>, and <code>Helvetica</code> are guaranteed to be supported
    (and mapped to an appropriate <strong>monospaced</strong>, serif, or sans-serif font)</p>
  </blockquote>
  
  <p>So I try with:</p>
  
  <pre><code>style.configure("Courier.TButton", font=("Courier", 16))
  button.configure(style="Courier.TButton")
  </code></pre>
  
  <p>and now finally I get a monospaced result:</p>
  
  <p><a href="https://i.stack.imgur.com/utKwB.png" rel="noreferrer"><img src="https://i.stack.imgur.com/utKwB.png" alt="enter image description here"></a></p>
  
  <p>Admittedly, it's <code>Courier New</code> and not <code>DejaVu Sans Mono</code> that my platform chooses as the standard monospaced font, but that's at least something, right? But shouldn't <code>TkFixedFont</code> just work?</p>