diff options
Diffstat (limited to 'Lib/tkinter/font.py')
-rw-r--r-- | Lib/tkinter/font.py | 19 |
1 files changed, 10 insertions, 9 deletions
diff --git a/Lib/tkinter/font.py b/Lib/tkinter/font.py index 4b4dc67..1ec760e 100644 --- a/Lib/tkinter/font.py +++ b/Lib/tkinter/font.py @@ -8,7 +8,7 @@ __version__ = "0.9" -import Tkinter +import tkinter # weight/slant NORMAL = "normal" @@ -65,7 +65,7 @@ class Font: def __init__(self, root=None, font=None, name=None, exists=False, **options): if not root: - root = Tkinter._default_root + root = tkinter._default_root if font: # get actual settings corresponding to the given font font = root.tk.splitlist(root.tk.call("font", "actual", font)) @@ -79,7 +79,8 @@ class Font: self.delete_font = False # confirm font exists if self.name not in root.tk.call("font", "names"): - raise Tkinter._tkinter.TclError("named font %s does not already exist" % (self.name,)) + raise tkinter._tkinter.TclError( + "named font %s does not already exist" % (self.name,)) # if font config info supplied, apply it if font: root.tk.call("font", "configure", self.name, *font) @@ -166,13 +167,13 @@ class Font: def families(root=None): "Get font families (as a tuple)" if not root: - root = Tkinter._default_root + root = tkinter._default_root return root.tk.splitlist(root.tk.call("font", "families")) def names(root=None): "Get names of defined fonts (as a tuple)" if not root: - root = Tkinter._default_root + root = tkinter._default_root return root.tk.splitlist(root.tk.call("font", "names")) # -------------------------------------------------------------------- @@ -180,7 +181,7 @@ def names(root=None): if __name__ == "__main__": - root = Tkinter.Tk() + root = tkinter.Tk() # create a font f = Font(family="times", size=30, weight=NORMAL) @@ -202,10 +203,10 @@ if __name__ == "__main__": f = Font(font=("Courier", 20, "bold")) print(f.measure("hello"), f.metrics("linespace")) - w = Tkinter.Label(root, text="Hello, world", font=f) + w = tkinter.Label(root, text="Hello, world", font=f) w.pack() - w = Tkinter.Button(root, text="Quit!", command=root.destroy) + w = tkinter.Button(root, text="Quit!", command=root.destroy) w.pack() fb = Font(font=w["font"]).copy() @@ -213,4 +214,4 @@ if __name__ == "__main__": w.config(font=fb) - Tkinter.mainloop() + tkinter.mainloop() |