Commit 5af3e1af authored by Andrew Svetlov's avatar Andrew Svetlov

reformat code to follow PEP8

parent e50d6abe
...@@ -10,19 +10,21 @@ __version__ = "0.9" ...@@ -10,19 +10,21 @@ __version__ = "0.9"
import tkinter import tkinter
# weight/slant # weight/slant
NORMAL = "normal" NORMAL = "normal"
ROMAN = "roman" ROMAN = "roman"
BOLD = "bold" BOLD = "bold"
ITALIC = "italic" ITALIC = "italic"
def nametofont(name): def nametofont(name):
"""Given the name of a tk named font, returns a Font representation. """Given the name of a tk named font, returns a Font representation.
""" """
return Font(name=name, exists=True) return Font(name=name, exists=True)
class Font:
class Font:
"""Represents a named font. """Represents a named font.
Constructor options are: Constructor options are:
...@@ -63,7 +65,8 @@ class Font: ...@@ -63,7 +65,8 @@ class Font:
options[args[i][1:]] = args[i+1] options[args[i][1:]] = args[i+1]
return options 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: if not root:
root = tkinter._default_root root = tkinter._default_root
if font: if font:
...@@ -138,8 +141,7 @@ class Font: ...@@ -138,8 +141,7 @@ class Font:
*self._set(options)) *self._set(options))
else: else:
return self._mkdict( return self._mkdict(
self._split(self._call("font", "config", self.name)) self._split(self._call("font", "config", self.name)))
)
configure = config configure = config
...@@ -155,8 +157,7 @@ class Font: ...@@ -155,8 +157,7 @@ class Font:
if options: if options:
return int( return int(
self._call("font", "metrics", self.name, self._get(options)) self._call("font", "metrics", self.name, self._get(options)))
)
else: else:
res = self._split(self._call("font", "metrics", self.name)) res = self._split(self._call("font", "metrics", self.name))
options = {} options = {}
...@@ -164,18 +165,21 @@ class Font: ...@@ -164,18 +165,21 @@ class Font:
options[res[i][1:]] = int(res[i+1]) options[res[i][1:]] = int(res[i+1])
return options return options
def families(root=None): def families(root=None):
"Get font families (as a tuple)" "Get font families (as a tuple)"
if not root: if not root:
root = tkinter._default_root root = tkinter._default_root
return root.tk.splitlist(root.tk.call("font", "families")) return root.tk.splitlist(root.tk.call("font", "families"))
def names(root=None): def names(root=None):
"Get names of defined fonts (as a tuple)" "Get names of defined fonts (as a tuple)"
if not root: if not root:
root = tkinter._default_root root = tkinter._default_root
return root.tk.splitlist(root.tk.call("font", "names")) return root.tk.splitlist(root.tk.call("font", "names"))
# -------------------------------------------------------------------- # --------------------------------------------------------------------
# test stuff # test stuff
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment