Reputation: 2618
I am trying to make a tkinter
Menu
widget with the font
of Courier New
. Unfortunately the font attribute
doesn't seem to be working. I am using Python 3.4.1
. Below is the code:
from tkinter import *
class Arshi(Frame):
def __init__(self, master):
Frame.__init__(self, master)
self.pack(fill=BOTH)
self.topbar()
def topbar(self):
self.menufont = ("Courier New", 9)
self.menu = Menu(self, font=self.menufont)
self.master.config(menu=self.menu)
root = Tk()
root.title("Arshi")
window = Arshi(root)
window.mainloop()
Upvotes: 2
Views: 2009
Reputation: 713
Tkinter is a Python binding to Tk widgets. Tk's menu widget is designed to have a non-programmable font. That is the approach other popular widget toolkits have taken under GUI development, namely:
-- A system's applications should have standardized menus no matter which toolkit was used to create it.
-- All applications menu-fonts are configurable by the individual user under a single system-wide configuration option (look for your system's user setting for the font settings for menus).
-- All menus will look the same, regardless of whether you use Tk or a competitors widget.
-- If another menu does look different, then it's not really a menu widget.
For example, within Ubuntu, an applications menu will be thrown to the top-left of the screen, separate from the main application window. OS-X has a similar approach. Windows, Mac and Linux Desktops all allow their individual users to adjust their menu fonts to their personal preference, but not to the programmer's personal preference.
It is possible to use another widget class to mimic the appearance of a menu, and the programmer can customize the font to their own personal liking that way. For example, you can use the menubutton widget and adjust it's font option, and place those within a frame. It would then serve the purpose of a non-standard menu.
Upvotes: 4