Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
5af3e1af
Commit
5af3e1af
authored
Apr 03, 2012
by
Andrew Svetlov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
reformat code to follow PEP8
parent
e50d6abe
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
10 additions
and
6 deletions
+10
-6
Lib/tkinter/font.py
Lib/tkinter/font.py
+10
-6
No files found.
Lib/tkinter/font.py
View file @
5af3e1af
...
...
@@ -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
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment