MCPcopy Index your code
hub / github.com/RustPython/RustPython / Font

Class Font

Lib/tkinter/font.py:26–181  ·  view source on GitHub ↗

Represents a named font. Constructor options are: font -- font specifier (name, system font, or (family, size, style)-tuple) name -- name to use for this font configuration (defaults to a unique name) exists -- does a named font by this name already exist? Creates a new name

Source from the content-addressed store, hash-verified

24
25
26class Font:
27 """Represents a named font.
28
29 Constructor options are:
30
31 font -- font specifier (name, system font, or (family, size, style)-tuple)
32 name -- name to use for this font configuration (defaults to a unique name)
33 exists -- does a named font by this name already exist?
34 Creates a new named font if False, points to the existing font if True.
35 Raises _tkinter.TclError if the assertion is false.
36
37 the following are ignored if font is specified:
38
39 family -- font 'family', e.g. Courier, Times, Helvetica
40 size -- font size in points
41 weight -- font thickness: NORMAL, BOLD
42 slant -- font slant: ROMAN, ITALIC
43 underline -- font underlining: false (0), true (1)
44 overstrike -- font strikeout: false (0), true (1)
45
46 """
47
48 counter = itertools.count(1)
49
50 def _set(self, kw):
51 options = []
52 for k, v in kw.items():
53 options.append("-"+k)
54 options.append(str(v))
55 return tuple(options)
56
57 def _get(self, args):
58 options = []
59 for k in args:
60 options.append("-"+k)
61 return tuple(options)
62
63 def _mkdict(self, args):
64 options = {}
65 for i in range(0, len(args), 2):
66 options[args[i][1:]] = args[i+1]
67 return options
68
69 def __init__(self, root=None, font=None, name=None, exists=False,
70 **options):
71 if root is None:
72 root = tkinter._get_default_root('use font')
73 tk = getattr(root, 'tk', root)
74 if font:
75 # get actual settings corresponding to the given font
76 font = tk.splitlist(tk.call("font", "actual", font))
77 else:
78 font = self._set(options)
79 if not name:
80 name = "font" + str(next(self.counter))
81 self.name = name
82
83 if exists:

Callers 3

nametofontFunction · 0.85
copyMethod · 0.85
font.pyFile · 0.85

Calls 1

countMethod · 0.45

Tested by

no test coverage detected