Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
C
cpython
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
Batuhan Osman TASKAYA
cpython
Commits
20bbf54f
Kaydet (Commit)
20bbf54f
authored
Nis 05, 2012
tarafından
Andrew Svetlov
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Issue #3033: Add displayof parameter to tkinter font.
Patch by Guilherme Polo.
üst
9a13b432
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
29 additions
and
17 deletions
+29
-17
font.py
Lib/tkinter/font.py
+27
-17
NEWS
Misc/NEWS
+2
-0
No files found.
Lib/tkinter/font.py
Dosyayı görüntüle @
20bbf54f
...
...
@@ -2,9 +2,6 @@
#
# written by Fredrik Lundh, February 1998
#
# FIXME: should add 'displayof' option where relevant (actual, families,
# measure, and metrics)
#
__version__
=
"0.9"
...
...
@@ -124,14 +121,17 @@ class Font:
"Return a distinct copy of the current font"
return
Font
(
self
.
_root
,
**
self
.
actual
())
def
actual
(
self
,
option
=
None
):
def
actual
(
self
,
option
=
None
,
displayof
=
None
):
"Return actual font attributes"
args
=
()
if
displayof
:
args
=
(
'-displayof'
,
displayof
)
if
option
:
return
self
.
_call
(
"font"
,
"actual"
,
self
.
name
,
"-"
+
option
)
args
=
args
+
(
'-'
+
option
,
)
return
self
.
_call
(
"font"
,
"actual"
,
self
.
name
,
*
args
)
else
:
return
self
.
_mkdict
(
self
.
_split
(
self
.
_call
(
"font"
,
"actual"
,
self
.
name
))
)
self
.
_split
(
self
.
_call
(
"font"
,
"actual"
,
self
.
name
,
*
args
)))
def
cget
(
self
,
option
):
"Get font attribute"
...
...
@@ -148,32 +148,42 @@ class Font:
configure
=
config
def
measure
(
self
,
text
):
def
measure
(
self
,
text
,
displayof
=
None
):
"Return text width"
return
int
(
self
.
_call
(
"font"
,
"measure"
,
self
.
name
,
text
))
args
=
(
text
,)
if
displayof
:
args
=
(
'-displayof'
,
displayof
,
text
)
return
int
(
self
.
_call
(
"font"
,
"measure"
,
self
.
name
,
*
args
))
def
metrics
(
self
,
*
options
):
def
metrics
(
self
,
*
options
,
**
kw
):
"""Return font metrics.
For best performance, create a dummy widget
using this font before calling this method."""
args
=
()
displayof
=
kw
.
pop
(
'displayof'
,
None
)
if
displayof
:
args
=
(
'-displayof'
,
displayof
)
if
options
:
args
=
args
+
self
.
_get
(
options
)
return
int
(
self
.
_call
(
"font"
,
"metrics"
,
self
.
name
,
self
.
_get
(
options
)
))
self
.
_call
(
"font"
,
"metrics"
,
self
.
name
,
*
args
))
else
:
res
=
self
.
_split
(
self
.
_call
(
"font"
,
"metrics"
,
self
.
name
))
res
=
self
.
_split
(
self
.
_call
(
"font"
,
"metrics"
,
self
.
name
,
*
args
))
options
=
{}
for
i
in
range
(
0
,
len
(
res
),
2
):
options
[
res
[
i
][
1
:]]
=
int
(
res
[
i
+
1
])
return
options
def
families
(
root
=
None
):
def
families
(
root
=
None
,
displayof
=
None
):
"Get font families (as a tuple)"
if
not
root
:
root
=
tkinter
.
_default_root
return
root
.
tk
.
splitlist
(
root
.
tk
.
call
(
"font"
,
"families"
))
args
=
()
if
displayof
:
args
=
(
'-displayof'
,
displayof
)
return
root
.
tk
.
splitlist
(
root
.
tk
.
call
(
"font"
,
"families"
,
*
args
))
def
names
(
root
=
None
):
...
...
@@ -205,10 +215,10 @@ if __name__ == "__main__":
print
(
f
.
measure
(
"hello"
),
f
.
metrics
(
"linespace"
))
print
(
f
.
metrics
())
print
(
f
.
metrics
(
displayof
=
root
))
f
=
Font
(
font
=
(
"Courier"
,
20
,
"bold"
))
print
(
f
.
measure
(
"hello"
),
f
.
metrics
(
"linespace"
))
print
(
f
.
measure
(
"hello"
),
f
.
metrics
(
"linespace"
,
displayof
=
root
))
w
=
tkinter
.
Label
(
root
,
text
=
"Hello, world"
,
font
=
f
)
w
.
pack
()
...
...
Misc/NEWS
Dosyayı görüntüle @
20bbf54f
...
...
@@ -19,6 +19,8 @@ Core and Builtins
Library
-------
- Issue #3033: Add displayof parameter to tkinter font. Patch by Guilherme Polo.
- Issue #14482: Raise a ValueError, not a NameError, when trying to create
a multiprocessing Client or Listener with an AF_UNIX type address under
Windows. Patch by Popa Claudiu.
...
...
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