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
8e5e438d
Kaydet (Commit)
8e5e438d
authored
Şub 07, 2009
tarafından
Guilherme Polo
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Eliminated the need to use ttk.__loadtk__ and the problems related it.
üst
92c3b219
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
42 additions
and
36 deletions
+42
-36
ttk.py
Lib/lib-tk/ttk.py
+41
-29
test_tcl.py
Lib/test/test_tcl.py
+1
-7
No files found.
Lib/lib-tk/ttk.py
Dosyayı görüntüle @
8e5e438d
...
@@ -29,32 +29,41 @@ import Tkinter
...
@@ -29,32 +29,41 @@ import Tkinter
_flatten
=
Tkinter
.
_flatten
_flatten
=
Tkinter
.
_flatten
# Verify if Tk is new enough to not need
Tile checking
# Verify if Tk is new enough to not need
the Tile package
_REQUIRE_TILE
=
True
if
Tkinter
.
TkVersion
<
8.5
else
False
_REQUIRE_TILE
=
True
if
Tkinter
.
TkVersion
<
8.5
else
False
def
_loadttk
(
loadtk
):
def
_load_tile
(
master
):
# This extends the default Tkinter.Tk._loadtk method so we can be
if
_REQUIRE_TILE
:
# sure that ttk is available for use, or not.
import
os
def
_wrapper
(
self
):
tilelib
=
os
.
environ
.
get
(
'TILE_LIBRARY'
)
loadtk
(
self
)
if
tilelib
:
# append custom tile path to the the list of directories that
if
_REQUIRE_TILE
:
# Tcl uses when attempting to resolve packages with the package
import
os
# command
tilelib
=
os
.
environ
.
get
(
'TILE_LIBRARY'
)
master
.
tk
.
eval
(
if
tilelib
:
'global auto_path; '
# append custom tile path to the the list of directories that
'lappend auto_path {
%
s}'
%
tilelib
)
# Tcl uses when attempting to resolve packages with the package
# command
master
.
tk
.
eval
(
'package require tile'
)
# TclError may be raised here
self
.
tk
.
eval
(
'global auto_path; '
master
.
_tile_loaded
=
True
'lappend auto_path {
%
s}'
%
tilelib
)
self
.
tk
.
eval
(
'package require tile'
)
# TclError may be raised here
def
_setup_master
(
master
=
None
):
return
_wrapper
"""If master is not None, itself is returned. If master is None,
the default master is returned if there is one, otherwise a new
master is created and returned.
If it is not allowed to use the default root and master is None,
RuntimeError is raised."""
if
master
is
None
:
if
Tkinter
.
_support_default_root
:
master
=
Tkinter
.
_default_root
or
Tkinter
.
Tk
()
else
:
raise
RuntimeError
(
"No master specified and Tkinter is "
"configured to not support default root"
)
return
master
# Store the original Tkinter.Tk._loadtk before replacing it just in case
# someone wants to restore it.
__loadtk__
=
Tkinter
.
Tk
.
_loadtk
Tkinter
.
Tk
.
_loadtk
=
_loadttk
(
Tkinter
.
Tk
.
_loadtk
)
def
_format_optdict
(
optdict
,
script
=
False
,
ignore
=
None
):
def
_format_optdict
(
optdict
,
script
=
False
,
ignore
=
None
):
...
@@ -366,12 +375,11 @@ class Style(object):
...
@@ -366,12 +375,11 @@ class Style(object):
_name
=
"ttk::style"
_name
=
"ttk::style"
def
__init__
(
self
,
master
=
None
):
def
__init__
(
self
,
master
=
None
):
if
master
is
None
:
master
=
_setup_master
(
master
)
if
Tkinter
.
_support_default_root
:
master
=
Tkinter
.
_default_root
or
Tkinter
.
Tk
()
if
not
getattr
(
master
,
'_tile_loaded'
,
False
):
else
:
# Load tile now, if needed
raise
RuntimeError
(
"No master specified and Tkinter is "
_load_tile
(
master
)
"configured to not support default master"
)
self
.
master
=
master
self
.
master
=
master
self
.
tk
=
self
.
master
.
tk
self
.
tk
=
self
.
master
.
tk
...
@@ -548,6 +556,10 @@ class Widget(Tkinter.Widget):
...
@@ -548,6 +556,10 @@ class Widget(Tkinter.Widget):
active, disabled, focus, pressed, selected, background,
active, disabled, focus, pressed, selected, background,
readonly, alternate, invalid
readonly, alternate, invalid
"""
"""
master
=
_setup_master
(
master
)
if
not
getattr
(
master
,
'_tile_loaded'
,
False
):
# Load tile now, if needed
_load_tile
(
master
)
Tkinter
.
Widget
.
__init__
(
self
,
master
,
widgetname
,
kw
=
kw
)
Tkinter
.
Widget
.
__init__
(
self
,
master
,
widgetname
,
kw
=
kw
)
...
...
Lib/test/test_tcl.py
Dosyayı görüntüle @
8e5e438d
...
@@ -4,15 +4,9 @@ import unittest
...
@@ -4,15 +4,9 @@ import unittest
import
os
import
os
import
_tkinter
import
_tkinter
from
test
import
test_support
from
test
import
test_support
from
Tkinter
import
T
k
,
T
cl
from
Tkinter
import
Tcl
from
_tkinter
import
TclError
from
_tkinter
import
TclError
# Restore Tkinter.Tk._loadtk that may have been overridden by ttk.
# If this is not done then this test may fail for reasons related
# to ttk only (like failing to load the tile package).
from
ttk
import
__loadtk__
Tk
.
_loadtk
=
__loadtk__
class
TkinterTest
(
unittest
.
TestCase
):
class
TkinterTest
(
unittest
.
TestCase
):
...
...
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