diff options
author | Andrew Svetlov <andrew.svetlov@gmail.com> | 2012-04-03 06:39:47 (GMT) |
---|---|---|
committer | Andrew Svetlov <andrew.svetlov@gmail.com> | 2012-04-03 06:39:47 (GMT) |
commit | 5af3e1afb07a5d5409a149fe6640778b8adb6050 (patch) | |
tree | 02f3afe8aa0239c3e58e0ef13a58fcb378bbc23d | |
parent | e50d6abea4022a1940e1ad7c2769e561bc90e18e (diff) | |
download | cpython-5af3e1afb07a5d5409a149fe6640778b8adb6050.zip cpython-5af3e1afb07a5d5409a149fe6640778b8adb6050.tar.gz cpython-5af3e1afb07a5d5409a149fe6640778b8adb6050.tar.bz2 |
reformat code to follow PEP8
-rw-r--r-- | Lib/tkinter/font.py | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/Lib/tkinter/font.py b/Lib/tkinter/font.py index 5425b06..0103195 100644 --- a/Lib/tkinter/font.py +++ b/Lib/tkinter/font.py @@ -10,19 +10,21 @@ __version__ = "0.9" import tkinter + # weight/slant NORMAL = "normal" ROMAN = "roman" BOLD = "bold" ITALIC = "italic" + def nametofont(name): """Given the name of a tk named font, returns a Font representation. """ return Font(name=name, exists=True) -class Font: +class Font: """Represents a named font. Constructor options are: @@ -63,7 +65,8 @@ class Font: options[args[i][1:]] = args[i+1] return options - def __init__(self, root=None, font=None, name=None, exists=False, **options): + def __init__(self, root=None, font=None, name=None, exists=False, + **options): if not root: root = tkinter._default_root if font: @@ -138,8 +141,7 @@ class Font: *self._set(options)) else: return self._mkdict( - self._split(self._call("font", "config", self.name)) - ) + self._split(self._call("font", "config", self.name))) configure = config @@ -155,8 +157,7 @@ class Font: if options: return int( - self._call("font", "metrics", self.name, self._get(options)) - ) + self._call("font", "metrics", self.name, self._get(options))) else: res = self._split(self._call("font", "metrics", self.name)) options = {} @@ -164,18 +165,21 @@ class Font: options[res[i][1:]] = int(res[i+1]) return options + def families(root=None): "Get font families (as a tuple)" if not 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 return root.tk.splitlist(root.tk.call("font", "names")) + # -------------------------------------------------------------------- # test stuff |