Linux ip-148-66-134-25.ip.secureserver.net 3.10.0-1160.119.1.el7.tuxcare.els11.x86_64 #1 SMP Sun Nov 3 09:06:59 UTC 2024 x86_64
Apache
: 148.66.134.25 | : 3.144.101.75
66 Domain
8.0.30
amvm
www.github.com/MadExploits
Terminal
AUTO ROOT
Adminer
Backdoor Destroyer
Linux Exploit
Lock Shell
Lock File
Create User
CREATE RDP
PHP Mailer
BACKCONNECT
UNLOCK SHELL
HASH IDENTIFIER
CPANEL RESET
BLACK DEFEND!
README
+ Create Folder
+ Create File
/
usr /
share /
doc /
python-docs-2.7.5 /
html /
library /
[ HOME SHELL ]
Name
Size
Permission
Action
2to3.html
49.27
KB
-rw-r--r--
__builtin__.html
10.26
KB
-rw-r--r--
__future__.html
13.79
KB
-rw-r--r--
__main__.html
7.05
KB
-rw-r--r--
_winreg.html
59.21
KB
-rw-r--r--
abc.html
23.9
KB
-rw-r--r--
aepack.html
13.16
KB
-rw-r--r--
aetools.html
14.91
KB
-rw-r--r--
aetypes.html
18.88
KB
-rw-r--r--
aifc.html
22.4
KB
-rw-r--r--
al.html
17.34
KB
-rw-r--r--
allos.html
33.72
KB
-rw-r--r--
anydbm.html
16.33
KB
-rw-r--r--
archiving.html
9.26
KB
-rw-r--r--
argparse.html
237.62
KB
-rw-r--r--
array.html
29.29
KB
-rw-r--r--
ast.html
34.98
KB
-rw-r--r--
asynchat.html
31.43
KB
-rw-r--r--
asyncore.html
36.51
KB
-rw-r--r--
atexit.html
16.8
KB
-rw-r--r--
audioop.html
31.36
KB
-rw-r--r--
autogil.html
8.19
KB
-rw-r--r--
base64.html
19.67
KB
-rw-r--r--
basehttpserver.html
34.04
KB
-rw-r--r--
bastion.html
11.04
KB
-rw-r--r--
bdb.html
36.68
KB
-rw-r--r--
binascii.html
20.67
KB
-rw-r--r--
binhex.html
10.58
KB
-rw-r--r--
bisect.html
23.24
KB
-rw-r--r--
bsddb.html
26.43
KB
-rw-r--r--
bz2.html
26.08
KB
-rw-r--r--
calendar.html
37.79
KB
-rw-r--r--
carbon.html
48.94
KB
-rw-r--r--
cd.html
27.96
KB
-rw-r--r--
cgi.html
49.92
KB
-rw-r--r--
cgihttpserver.html
13.1
KB
-rw-r--r--
cgitb.html
11.41
KB
-rw-r--r--
chunk.html
14.66
KB
-rw-r--r--
cmath.html
25.63
KB
-rw-r--r--
cmd.html
26.09
KB
-rw-r--r--
code.html
24.58
KB
-rw-r--r--
codecs.html
100.64
KB
-rw-r--r--
codeop.html
14.84
KB
-rw-r--r--
collections.html
133.96
KB
-rw-r--r--
colorpicker.html
7.52
KB
-rw-r--r--
colorsys.html
11.04
KB
-rw-r--r--
commands.html
14.36
KB
-rw-r--r--
compileall.html
16.83
KB
-rw-r--r--
compiler.html
67.75
KB
-rw-r--r--
configparser.html
62.13
KB
-rw-r--r--
constants.html
12.83
KB
-rw-r--r--
contextlib.html
19.39
KB
-rw-r--r--
cookie.html
39.07
KB
-rw-r--r--
cookielib.html
83.82
KB
-rw-r--r--
copy.html
12.19
KB
-rw-r--r--
copy_reg.html
13.76
KB
-rw-r--r--
crypt.html
10.04
KB
-rw-r--r--
crypto.html
7.59
KB
-rw-r--r--
csv.html
67.37
KB
-rw-r--r--
ctypes.html
238.78
KB
-rw-r--r--
curses.ascii.html
22.29
KB
-rw-r--r--
curses.html
146.63
KB
-rw-r--r--
curses.panel.html
14.39
KB
-rw-r--r--
custominterp.html
7.62
KB
-rw-r--r--
datatypes.html
16.84
KB
-rw-r--r--
datetime.html
226.59
KB
-rw-r--r--
dbhash.html
15.48
KB
-rw-r--r--
dbm.html
12.07
KB
-rw-r--r--
debug.html
10.15
KB
-rw-r--r--
decimal.html
194.44
KB
-rw-r--r--
development.html
14.17
KB
-rw-r--r--
difflib.html
84.83
KB
-rw-r--r--
dircache.html
11.41
KB
-rw-r--r--
dis.html
69.95
KB
-rw-r--r--
distutils.html
8.05
KB
-rw-r--r--
dl.html
16.33
KB
-rw-r--r--
doctest.html
165.54
KB
-rw-r--r--
docxmlrpcserver.html
16.43
KB
-rw-r--r--
dumbdbm.html
14.02
KB
-rw-r--r--
dummy_thread.html
9.43
KB
-rw-r--r--
dummy_threading.html
8.37
KB
-rw-r--r--
easydialogs.html
30.55
KB
-rw-r--r--
email-examples.html
45.65
KB
-rw-r--r--
email.charset.html
26.8
KB
-rw-r--r--
email.encoders.html
11.86
KB
-rw-r--r--
email.errors.html
15.77
KB
-rw-r--r--
email.generator.html
20.77
KB
-rw-r--r--
email.header.html
26.92
KB
-rw-r--r--
email.html
44.24
KB
-rw-r--r--
email.iterators.html
11.52
KB
-rw-r--r--
email.message.html
63.16
KB
-rw-r--r--
email.mime.html
27.93
KB
-rw-r--r--
email.parser.html
30.45
KB
-rw-r--r--
email.util.html
24.46
KB
-rw-r--r--
errno.html
37.99
KB
-rw-r--r--
exceptions.html
56.13
KB
-rw-r--r--
fcntl.html
22.67
KB
-rw-r--r--
filecmp.html
22.3
KB
-rw-r--r--
fileformats.html
9.14
KB
-rw-r--r--
fileinput.html
24.28
KB
-rw-r--r--
filesys.html
10.2
KB
-rw-r--r--
fl.html
49.92
KB
-rw-r--r--
fm.html
11.91
KB
-rw-r--r--
fnmatch.html
14.58
KB
-rw-r--r--
formatter.html
34.06
KB
-rw-r--r--
fpectl.html
16.01
KB
-rw-r--r--
fpformat.html
10.59
KB
-rw-r--r--
fractions.html
22.61
KB
-rw-r--r--
framework.html
33.34
KB
-rw-r--r--
frameworks.html
7.14
KB
-rw-r--r--
ftplib.html
43.99
KB
-rw-r--r--
functions.html
183.14
KB
-rw-r--r--
functools.html
27.17
KB
-rw-r--r--
future_builtins.html
13.04
KB
-rw-r--r--
gc.html
25.75
KB
-rw-r--r--
gdbm.html
15.96
KB
-rw-r--r--
gensuitemodule.html
11.51
KB
-rw-r--r--
getopt.html
23.66
KB
-rw-r--r--
getpass.html
10.65
KB
-rw-r--r--
gettext.html
78.76
KB
-rw-r--r--
gl.html
22.09
KB
-rw-r--r--
glob.html
13.26
KB
-rw-r--r--
grp.html
10.49
KB
-rw-r--r--
gzip.html
18.99
KB
-rw-r--r--
hashlib.html
18.2
KB
-rw-r--r--
heapq.html
31.61
KB
-rw-r--r--
hmac.html
10.46
KB
-rw-r--r--
hotshot.html
18.65
KB
-rw-r--r--
htmllib.html
25.32
KB
-rw-r--r--
htmlparser.html
39.11
KB
-rw-r--r--
httplib.html
62.95
KB
-rw-r--r--
i18n.html
9.52
KB
-rw-r--r--
ic.html
17.17
KB
-rw-r--r--
idle.html
20.9
KB
-rw-r--r--
imageop.html
14.76
KB
-rw-r--r--
imaplib.html
51.99
KB
-rw-r--r--
imgfile.html
11.71
KB
-rw-r--r--
imghdr.html
11.3
KB
-rw-r--r--
imp.html
34.34
KB
-rw-r--r--
importlib.html
8.26
KB
-rw-r--r--
imputil.html
31.81
KB
-rw-r--r--
index.html
72.78
KB
-rw-r--r--
inspect.html
50.71
KB
-rw-r--r--
internet.html
24.87
KB
-rw-r--r--
intro.html
8.93
KB
-rw-r--r--
io.html
98.13
KB
-rw-r--r--
ipc.html
13.41
KB
-rw-r--r--
itertools.html
115.91
KB
-rw-r--r--
jpeg.html
12.74
KB
-rw-r--r--
json.html
67.04
KB
-rw-r--r--
keyword.html
7.68
KB
-rw-r--r--
language.html
11.03
KB
-rw-r--r--
linecache.html
10.59
KB
-rw-r--r--
locale.html
55.14
KB
-rw-r--r--
logging.config.html
63.36
KB
-rw-r--r--
logging.handlers.html
69.64
KB
-rw-r--r--
logging.html
95.64
KB
-rw-r--r--
mac.html
21.79
KB
-rw-r--r--
macos.html
14.76
KB
-rw-r--r--
macosa.html
12.96
KB
-rw-r--r--
macostools.html
15.52
KB
-rw-r--r--
macpath.html
7.76
KB
-rw-r--r--
mailbox.html
156.75
KB
-rw-r--r--
mailcap.html
13.21
KB
-rw-r--r--
markup.html
18.77
KB
-rw-r--r--
marshal.html
17.98
KB
-rw-r--r--
math.html
39.24
KB
-rw-r--r--
md5.html
13.97
KB
-rw-r--r--
mhlib.html
21.54
KB
-rw-r--r--
mimetools.html
19.25
KB
-rw-r--r--
mimetypes.html
28.39
KB
-rw-r--r--
mimewriter.html
15.02
KB
-rw-r--r--
mimify.html
13.36
KB
-rw-r--r--
miniaeframe.html
12.2
KB
-rw-r--r--
misc.html
6.87
KB
-rw-r--r--
mm.html
9.03
KB
-rw-r--r--
mmap.html
28.36
KB
-rw-r--r--
modulefinder.html
15.31
KB
-rw-r--r--
modules.html
8.46
KB
-rw-r--r--
msilib.html
52.43
KB
-rw-r--r--
msvcrt.html
19.37
KB
-rw-r--r--
multifile.html
24.3
KB
-rw-r--r--
multiprocessing.html
365.71
KB
-rw-r--r--
mutex.html
11.23
KB
-rw-r--r--
netdata.html
16.98
KB
-rw-r--r--
netrc.html
12.3
KB
-rw-r--r--
new.html
12.12
KB
-rw-r--r--
nis.html
10.64
KB
-rw-r--r--
nntplib.html
41.92
KB
-rw-r--r--
numbers.html
37.75
KB
-rw-r--r--
numeric.html
13.55
KB
-rw-r--r--
operator.html
82
KB
-rw-r--r--
optparse.html
222.56
KB
-rw-r--r--
os.html
214.25
KB
-rw-r--r--
os.path.html
38.34
KB
-rw-r--r--
ossaudiodev.html
41.5
KB
-rw-r--r--
othergui.html
9.08
KB
-rw-r--r--
parser.html
39.36
KB
-rw-r--r--
pdb.html
33.96
KB
-rw-r--r--
persistence.html
14.87
KB
-rw-r--r--
pickle.html
102.27
KB
-rw-r--r--
pickletools.html
10.63
KB
-rw-r--r--
pipes.html
18.01
KB
-rw-r--r--
pkgutil.html
25.11
KB
-rw-r--r--
platform.html
28.37
KB
-rw-r--r--
plistlib.html
17.03
KB
-rw-r--r--
popen2.html
25.43
KB
-rw-r--r--
poplib.html
22.32
KB
-rw-r--r--
posix.html
14.41
KB
-rw-r--r--
posixfile.html
19.76
KB
-rw-r--r--
pprint.html
29.92
KB
-rw-r--r--
profile.html
63.56
KB
-rw-r--r--
pty.html
9.48
KB
-rw-r--r--
pwd.html
11.43
KB
-rw-r--r--
py_compile.html
11.12
KB
-rw-r--r--
pyclbr.html
14.71
KB
-rw-r--r--
pydoc.html
11.48
KB
-rw-r--r--
pyexpat.html
71.53
KB
-rw-r--r--
python.html
12.27
KB
-rw-r--r--
queue.html
24.22
KB
-rw-r--r--
quopri.html
11.9
KB
-rw-r--r--
random.html
37.83
KB
-rw-r--r--
re.html
134.74
KB
-rw-r--r--
readline.html
28.24
KB
-rw-r--r--
repr.html
20.43
KB
-rw-r--r--
resource.html
26.48
KB
-rw-r--r--
restricted.html
11.65
KB
-rw-r--r--
rexec.html
37.41
KB
-rw-r--r--
rfc822.html
42.22
KB
-rw-r--r--
rlcompleter.html
13.51
KB
-rw-r--r--
robotparser.html
12.27
KB
-rw-r--r--
runpy.html
19.34
KB
-rw-r--r--
sched.html
18.54
KB
-rw-r--r--
scrolledtext.html
9.32
KB
-rw-r--r--
select.html
39.67
KB
-rw-r--r--
sets.html
36.92
KB
-rw-r--r--
sgi.html
9.71
KB
-rw-r--r--
sgmllib.html
30.77
KB
-rw-r--r--
sha.html
12.09
KB
-rw-r--r--
shelve.html
27.02
KB
-rw-r--r--
shlex.html
32.1
KB
-rw-r--r--
shutil.html
40.22
KB
-rw-r--r--
signal.html
31.14
KB
-rw-r--r--
simplehttpserver.html
18.41
KB
-rw-r--r--
simplexmlrpcserver.html
31.39
KB
-rw-r--r--
site.html
23.64
KB
-rw-r--r--
smtpd.html
12.46
KB
-rw-r--r--
smtplib.html
42.13
KB
-rw-r--r--
sndhdr.html
10.02
KB
-rw-r--r--
socket.html
106.34
KB
-rw-r--r--
socketserver.html
59.83
KB
-rw-r--r--
someos.html
15.11
KB
-rw-r--r--
spwd.html
10.33
KB
-rw-r--r--
sqlite3.html
139.5
KB
-rw-r--r--
ssl.html
65.62
KB
-rw-r--r--
stat.html
32.31
KB
-rw-r--r--
statvfs.html
10.6
KB
-rw-r--r--
stdtypes.html
260.4
KB
-rw-r--r--
string.html
106.65
KB
-rw-r--r--
stringio.html
18.81
KB
-rw-r--r--
stringprep.html
16.13
KB
-rw-r--r--
strings.html
14.93
KB
-rw-r--r--
struct.html
40.88
KB
-rw-r--r--
subprocess.html
84.91
KB
-rw-r--r--
sun.html
6.84
KB
-rw-r--r--
sunau.html
27.1
KB
-rw-r--r--
sunaudio.html
17.79
KB
-rw-r--r--
symbol.html
7.66
KB
-rw-r--r--
symtable.html
22.94
KB
-rw-r--r--
sys.html
98.7
KB
-rw-r--r--
sysconfig.html
23.84
KB
-rw-r--r--
syslog.html
17.92
KB
-rw-r--r--
tabnanny.html
10.63
KB
-rw-r--r--
tarfile.html
78.68
KB
-rw-r--r--
telnetlib.html
25.48
KB
-rw-r--r--
tempfile.html
29.42
KB
-rw-r--r--
termios.html
16.01
KB
-rw-r--r--
test.html
52.62
KB
-rw-r--r--
textwrap.html
27.25
KB
-rw-r--r--
thread.html
20.47
KB
-rw-r--r--
threading.html
76.69
KB
-rw-r--r--
time.html
56.93
KB
-rw-r--r--
timeit.html
36.27
KB
-rw-r--r--
tix.html
46.96
KB
-rw-r--r--
tk.html
23.64
KB
-rw-r--r--
tkinter.html
67.67
KB
-rw-r--r--
token.html
19.62
KB
-rw-r--r--
tokenize.html
18.45
KB
-rw-r--r--
trace.html
25.54
KB
-rw-r--r--
traceback.html
33.44
KB
-rw-r--r--
ttk.html
101.75
KB
-rw-r--r--
tty.html
9.06
KB
-rw-r--r--
turtle.html
211.74
KB
-rw-r--r--
types.html
27.59
KB
-rw-r--r--
undoc.html
23.16
KB
-rw-r--r--
unicodedata.html
18.55
KB
-rw-r--r--
unittest.html
202.85
KB
-rw-r--r--
unix.html
10.55
KB
-rw-r--r--
urllib.html
58.68
KB
-rw-r--r--
urllib2.html
100.58
KB
-rw-r--r--
urlparse.html
40.41
KB
-rw-r--r--
user.html
11.83
KB
-rw-r--r--
userdict.html
29.73
KB
-rw-r--r--
uu.html
11.03
KB
-rw-r--r--
uuid.html
28.19
KB
-rw-r--r--
warnings.html
46.6
KB
-rw-r--r--
wave.html
22.22
KB
-rw-r--r--
weakref.html
36.52
KB
-rw-r--r--
webbrowser.html
23.07
KB
-rw-r--r--
whichdb.html
8.85
KB
-rw-r--r--
windows.html
9.33
KB
-rw-r--r--
winsound.html
18.75
KB
-rw-r--r--
wsgiref.html
81.04
KB
-rw-r--r--
xdrlib.html
29.94
KB
-rw-r--r--
xml.dom.html
89.04
KB
-rw-r--r--
xml.dom.minidom.html
40.42
KB
-rw-r--r--
xml.dom.pulldom.html
12.71
KB
-rw-r--r--
xml.etree.elementtree.html
93.22
KB
-rw-r--r--
xml.html
16.49
KB
-rw-r--r--
xml.sax.handler.html
38.63
KB
-rw-r--r--
xml.sax.html
20.22
KB
-rw-r--r--
xml.sax.reader.html
39.09
KB
-rw-r--r--
xml.sax.utils.html
14.26
KB
-rw-r--r--
xmlrpclib.html
60.79
KB
-rw-r--r--
zipfile.html
53.14
KB
-rw-r--r--
zipimport.html
20.42
KB
-rw-r--r--
zlib.html
25.46
KB
-rw-r--r--
Delete
Unzip
Zip
${this.title}
Close
Code Editor : ttk.html
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>24.2. ttk — Tk themed widgets — Python 2.7.5 documentation</title> <link rel="stylesheet" href="../_static/default.css" type="text/css" /> <link rel="stylesheet" href="../_static/pygments.css" type="text/css" /> <script type="text/javascript"> var DOCUMENTATION_OPTIONS = { URL_ROOT: '../', VERSION: '2.7.5', COLLAPSE_INDEX: false, FILE_SUFFIX: '.html', HAS_SOURCE: true }; </script> <script type="text/javascript" src="../_static/jquery.js"></script> <script type="text/javascript" src="../_static/underscore.js"></script> <script type="text/javascript" src="../_static/doctools.js"></script> <script type="text/javascript" src="../_static/sidebar.js"></script> <link rel="search" type="application/opensearchdescription+xml" title="Search within Python 2.7.5 documentation" href="../_static/opensearch.xml"/> <link rel="author" title="About these documents" href="../about.html" /> <link rel="copyright" title="Copyright" href="../copyright.html" /> <link rel="top" title="Python 2.7.5 documentation" href="../index.html" /> <link rel="up" title="24. Graphical User Interfaces with Tk" href="tk.html" /> <link rel="next" title="24.3. Tix — Extension widgets for Tk" href="tix.html" /> <link rel="prev" title="24.1. Tkinter — Python interface to Tcl/Tk" href="tkinter.html" /> <link rel="shortcut icon" type="image/png" href="../_static/py.png" /> <script type="text/javascript" src="../_static/copybutton.js"></script> </head> <body> <div class="related"> <h3>Navigation</h3> <ul> <li class="right" style="margin-right: 10px"> <a href="../genindex.html" title="General Index" accesskey="I">index</a></li> <li class="right" > <a href="../py-modindex.html" title="Python Module Index" >modules</a> |</li> <li class="right" > <a href="tix.html" title="24.3. Tix — Extension widgets for Tk" accesskey="N">next</a> |</li> <li class="right" > <a href="tkinter.html" title="24.1. Tkinter — Python interface to Tcl/Tk" accesskey="P">previous</a> |</li> <li><img src="../_static/py.png" alt="" style="vertical-align: middle; margin-top: -1px"/></li> <li><a href="http://www.python.org/">Python</a> »</li> <li> <a href="../index.html">Python 2.7.5 documentation</a> » </li> <li><a href="index.html" >The Python Standard Library</a> »</li> <li><a href="tk.html" accesskey="U">24. Graphical User Interfaces with Tk</a> »</li> </ul> </div> <div class="document"> <div class="documentwrapper"> <div class="bodywrapper"> <div class="body"> <div class="section" id="module-ttk"> <span id="ttk-tk-themed-widgets"></span><h1>24.2. <a class="reference internal" href="#module-ttk" title="ttk: Tk themed widget set"><tt class="xref py py-mod docutils literal"><span class="pre">ttk</span></tt></a> — Tk themed widgets<a class="headerlink" href="#module-ttk" title="Permalink to this headline">¶</a></h1> <p id="index-0">The <a class="reference internal" href="#module-ttk" title="ttk: Tk themed widget set"><tt class="xref py py-mod docutils literal"><span class="pre">ttk</span></tt></a> module provides access to the Tk themed widget set, which has been introduced in Tk 8.5. If Python is not compiled against Tk 8.5 code may still use this module as long as Tile is installed. However, some features provided by the new Tk, like anti-aliased font rendering under X11, window transparency (on X11 you will need a composition window manager) will be missing.</p> <p>The basic idea of <a class="reference internal" href="#module-ttk" title="ttk: Tk themed widget set"><tt class="xref py py-mod docutils literal"><span class="pre">ttk</span></tt></a> is to separate, to the extent possible, the code implementing a widget’s behavior from the code implementing its appearance.</p> <div class="admonition-see-also admonition seealso"> <p class="first admonition-title">See also</p> <dl class="last docutils"> <dt><a class="reference external" href="http://www.tcl.tk/cgi-bin/tct/tip/48">Tk Widget Styling Support</a></dt> <dd>The document which brought up theming support for Tk</dd> </dl> </div> <div class="section" id="using-ttk"> <h2>24.2.1. Using Ttk<a class="headerlink" href="#using-ttk" title="Permalink to this headline">¶</a></h2> <p>To start using Ttk, import its module:</p> <div class="highlight-python"><div class="highlight"><pre><span class="kn">import</span> <span class="nn">ttk</span> </pre></div> </div> <p>But code like this:</p> <div class="highlight-python"><div class="highlight"><pre><span class="kn">from</span> <span class="nn">Tkinter</span> <span class="kn">import</span> <span class="o">*</span> </pre></div> </div> <p>may optionally want to use this:</p> <div class="highlight-python"><div class="highlight"><pre><span class="kn">from</span> <span class="nn">Tkinter</span> <span class="kn">import</span> <span class="o">*</span> <span class="kn">from</span> <span class="nn">ttk</span> <span class="kn">import</span> <span class="o">*</span> </pre></div> </div> <p>And then several <a class="reference internal" href="#module-ttk" title="ttk: Tk themed widget set"><tt class="xref py py-mod docutils literal"><span class="pre">ttk</span></tt></a> widgets (<tt class="xref py py-class docutils literal"><span class="pre">Button</span></tt>, <tt class="xref py py-class docutils literal"><span class="pre">Checkbutton</span></tt>, <tt class="xref py py-class docutils literal"><span class="pre">Entry</span></tt>, <tt class="xref py py-class docutils literal"><span class="pre">Frame</span></tt>, <tt class="xref py py-class docutils literal"><span class="pre">Label</span></tt>, <tt class="xref py py-class docutils literal"><span class="pre">LabelFrame</span></tt>, <tt class="xref py py-class docutils literal"><span class="pre">Menubutton</span></tt>, <tt class="xref py py-class docutils literal"><span class="pre">PanedWindow</span></tt>, <tt class="xref py py-class docutils literal"><span class="pre">Radiobutton</span></tt>, <tt class="xref py py-class docutils literal"><span class="pre">Scale</span></tt> and <tt class="xref py py-class docutils literal"><span class="pre">Scrollbar</span></tt>) will automatically substitute for the Tk widgets.</p> <p>This has the direct benefit of using the new widgets, giving better look & feel across platforms, but be aware that they are not totally compatible. The main difference is that widget options such as “fg”, “bg” and others related to widget styling are no longer present in Ttk widgets. Use <a class="reference internal" href="#ttk.Style" title="ttk.Style"><tt class="xref py py-class docutils literal"><span class="pre">ttk.Style</span></tt></a> to achieve the same (or better) styling.</p> <div class="admonition-see-also admonition seealso"> <p class="first admonition-title">See also</p> <dl class="last docutils"> <dt><a class="reference external" href="http://tktable.sourceforge.net/tile/doc/converting.txt">Converting existing applications to use the Tile widgets</a></dt> <dd>A text which talks in Tcl terms about differences typically found when converting applications to use the new widgets.</dd> </dl> </div> </div> <div class="section" id="ttk-widgets"> <h2>24.2.2. Ttk Widgets<a class="headerlink" href="#ttk-widgets" title="Permalink to this headline">¶</a></h2> <p>Ttk comes with 17 widgets, 11 of which already exist in Tkinter: <tt class="xref py py-class docutils literal"><span class="pre">Button</span></tt>, <tt class="xref py py-class docutils literal"><span class="pre">Checkbutton</span></tt>, <tt class="xref py py-class docutils literal"><span class="pre">Entry</span></tt>, <tt class="xref py py-class docutils literal"><span class="pre">Frame</span></tt>, <tt class="xref py py-class docutils literal"><span class="pre">Label</span></tt>, <tt class="xref py py-class docutils literal"><span class="pre">LabelFrame</span></tt>, <tt class="xref py py-class docutils literal"><span class="pre">Menubutton</span></tt>, <tt class="xref py py-class docutils literal"><span class="pre">PanedWindow</span></tt>, <tt class="xref py py-class docutils literal"><span class="pre">Radiobutton</span></tt>, <tt class="xref py py-class docutils literal"><span class="pre">Scale</span></tt> and <tt class="xref py py-class docutils literal"><span class="pre">Scrollbar</span></tt>. The 6 new widget classes are: <a class="reference internal" href="#ttk.Combobox" title="ttk.Combobox"><tt class="xref py py-class docutils literal"><span class="pre">Combobox</span></tt></a>, <a class="reference internal" href="#ttk.Notebook" title="ttk.Notebook"><tt class="xref py py-class docutils literal"><span class="pre">Notebook</span></tt></a>, <a class="reference internal" href="#ttk.Progressbar" title="ttk.Progressbar"><tt class="xref py py-class docutils literal"><span class="pre">Progressbar</span></tt></a>, <tt class="xref py py-class docutils literal"><span class="pre">Separator</span></tt>, <tt class="xref py py-class docutils literal"><span class="pre">Sizegrip</span></tt> and <a class="reference internal" href="#ttk.Treeview" title="ttk.Treeview"><tt class="xref py py-class docutils literal"><span class="pre">Treeview</span></tt></a>. All of these classes are subclasses of <a class="reference internal" href="#ttk.Widget" title="ttk.Widget"><tt class="xref py py-class docutils literal"><span class="pre">Widget</span></tt></a>.</p> <p>As said previously, you will notice changes in look-and-feel as well in the styling code. To demonstrate the latter, a very simple example is shown below.</p> <p>Tk code:</p> <div class="highlight-python"><div class="highlight"><pre><span class="n">l1</span> <span class="o">=</span> <span class="n">Tkinter</span><span class="o">.</span><span class="n">Label</span><span class="p">(</span><span class="n">text</span><span class="o">=</span><span class="s">"Test"</span><span class="p">,</span> <span class="n">fg</span><span class="o">=</span><span class="s">"black"</span><span class="p">,</span> <span class="n">bg</span><span class="o">=</span><span class="s">"white"</span><span class="p">)</span> <span class="n">l2</span> <span class="o">=</span> <span class="n">Tkinter</span><span class="o">.</span><span class="n">Label</span><span class="p">(</span><span class="n">text</span><span class="o">=</span><span class="s">"Test"</span><span class="p">,</span> <span class="n">fg</span><span class="o">=</span><span class="s">"black"</span><span class="p">,</span> <span class="n">bg</span><span class="o">=</span><span class="s">"white"</span><span class="p">)</span> </pre></div> </div> <p>Corresponding Ttk code:</p> <div class="highlight-python"><div class="highlight"><pre><span class="n">style</span> <span class="o">=</span> <span class="n">ttk</span><span class="o">.</span><span class="n">Style</span><span class="p">()</span> <span class="n">style</span><span class="o">.</span><span class="n">configure</span><span class="p">(</span><span class="s">"BW.TLabel"</span><span class="p">,</span> <span class="n">foreground</span><span class="o">=</span><span class="s">"black"</span><span class="p">,</span> <span class="n">background</span><span class="o">=</span><span class="s">"white"</span><span class="p">)</span> <span class="n">l1</span> <span class="o">=</span> <span class="n">ttk</span><span class="o">.</span><span class="n">Label</span><span class="p">(</span><span class="n">text</span><span class="o">=</span><span class="s">"Test"</span><span class="p">,</span> <span class="n">style</span><span class="o">=</span><span class="s">"BW.TLabel"</span><span class="p">)</span> <span class="n">l2</span> <span class="o">=</span> <span class="n">ttk</span><span class="o">.</span><span class="n">Label</span><span class="p">(</span><span class="n">text</span><span class="o">=</span><span class="s">"Test"</span><span class="p">,</span> <span class="n">style</span><span class="o">=</span><span class="s">"BW.TLabel"</span><span class="p">)</span> </pre></div> </div> <p>For more information about <a class="reference internal" href="#ttkstyling">TtkStyling</a> read the <a class="reference internal" href="#ttk.Style" title="ttk.Style"><tt class="xref py py-class docutils literal"><span class="pre">Style</span></tt></a> class documentation.</p> </div> <div class="section" id="widget"> <h2>24.2.3. Widget<a class="headerlink" href="#widget" title="Permalink to this headline">¶</a></h2> <p><a class="reference internal" href="#ttk.Widget" title="ttk.Widget"><tt class="xref py py-class docutils literal"><span class="pre">ttk.Widget</span></tt></a> defines standard options and methods supported by Tk themed widgets and is not supposed to be directly instantiated.</p> <div class="section" id="standard-options"> <h3>24.2.3.1. Standard Options<a class="headerlink" href="#standard-options" title="Permalink to this headline">¶</a></h3> <p>All the <a class="reference internal" href="#module-ttk" title="ttk: Tk themed widget set"><tt class="xref py py-mod docutils literal"><span class="pre">ttk</span></tt></a> widgets accept the following options:</p> <blockquote> <div><table border="1" class="docutils"> <colgroup> <col width="15%" /> <col width="85%" /> </colgroup> <thead valign="bottom"> <tr class="row-odd"><th class="head">Option</th> <th class="head">Description</th> </tr> </thead> <tbody valign="top"> <tr class="row-even"><td>class</td> <td>Specifies the window class. The class is used when querying the option database for the window’s other options, to determine the default bindtags for the window, and to select the widget’s default layout and style. This is a read-only option which may only be specified when the window is created.</td> </tr> <tr class="row-odd"><td>cursor</td> <td>Specifies the mouse cursor to be used for the widget. If set to the empty string (the default), the cursor is inherited from the parent widget.</td> </tr> <tr class="row-even"><td>takefocus</td> <td>Determines whether the window accepts the focus during keyboard traversal. 0, 1 or an empty string is returned. If 0, the window should be skipped entirely during keyboard traversal. If 1, the window should receive the input focus as long as it is viewable. An empty string means that the traversal scripts make the decision about whether or not to focus on the window.</td> </tr> <tr class="row-odd"><td>style</td> <td>May be used to specify a custom widget style.</td> </tr> </tbody> </table> </div></blockquote> </div> <div class="section" id="scrollable-widget-options"> <h3>24.2.3.2. Scrollable Widget Options<a class="headerlink" href="#scrollable-widget-options" title="Permalink to this headline">¶</a></h3> <p>The following options are supported by widgets that are controlled by a scrollbar.</p> <blockquote> <div><table border="1" class="docutils"> <colgroup> <col width="22%" /> <col width="78%" /> </colgroup> <thead valign="bottom"> <tr class="row-odd"><th class="head">option</th> <th class="head">description</th> </tr> </thead> <tbody valign="top"> <tr class="row-even"><td>xscrollcommand</td> <td><p class="first">Used to communicate with horizontal scrollbars.</p> <p>When the view in the widget’s window changes, the widget will generate a Tcl command based on the scrollcommand.</p> <p class="last">Usually this option consists of the <tt class="xref py py-meth docutils literal"><span class="pre">Scrollbar.set()</span></tt> method of some scrollbar. This will cause the scrollbar to be updated whenever the view in the window changes.</p> </td> </tr> <tr class="row-odd"><td>yscrollcommand</td> <td>Used to communicate with vertical scrollbars. For more information, see above.</td> </tr> </tbody> </table> </div></blockquote> </div> <div class="section" id="label-options"> <h3>24.2.3.3. Label Options<a class="headerlink" href="#label-options" title="Permalink to this headline">¶</a></h3> <p>The following options are supported by labels, buttons and other button-like widgets.</p> <blockquote> <div><table border="1" class="docutils"> <colgroup> <col width="19%" /> <col width="81%" /> </colgroup> <thead valign="bottom"> <tr class="row-odd"><th class="head">option</th> <th class="head">description</th> </tr> </thead> <tbody valign="top"> <tr class="row-even"><td>text</td> <td>Specifies a text string to be displayed inside the widget.</td> </tr> <tr class="row-odd"><td>textvariable</td> <td>Specifies a name whose value will be used in place of the text option resource.</td> </tr> <tr class="row-even"><td>underline</td> <td>If set, specifies the index (0-based) of a character to underline in the text string. The underline character is used for mnemonic activation.</td> </tr> <tr class="row-odd"><td>image</td> <td>Specifies an image to display. This is a list of 1 or more elements. The first element is the default image name. The rest of the list is a sequence of statespec/value pairs as defined by <a class="reference internal" href="#ttk.Style.map" title="ttk.Style.map"><tt class="xref py py-meth docutils literal"><span class="pre">Style.map()</span></tt></a>, specifying different images to use when the widget is in a particular state or a combination of states. All images in the list should have the same size.</td> </tr> <tr class="row-even"><td>compound</td> <td><p class="first">Specifies how to display the image relative to the text, in the case both text and image options are present. Valid values are:</p> <ul class="last simple"> <li>text: display text only</li> <li>image: display image only</li> <li>top, bottom, left, right: display image above, below, left of, or right of the text, respectively.</li> <li>none: the default. display the image if present, otherwise the text.</li> </ul> </td> </tr> <tr class="row-odd"><td>width</td> <td>If greater than zero, specifies how much space, in character widths, to allocate for the text label; if less than zero, specifies a minimum width. If zero or unspecified, the natural width of the text label is used.</td> </tr> </tbody> </table> </div></blockquote> </div> <div class="section" id="compatibility-options"> <h3>24.2.3.4. Compatibility Options<a class="headerlink" href="#compatibility-options" title="Permalink to this headline">¶</a></h3> <blockquote> <div><table border="1" class="docutils"> <colgroup> <col width="11%" /> <col width="89%" /> </colgroup> <thead valign="bottom"> <tr class="row-odd"><th class="head">option</th> <th class="head">description</th> </tr> </thead> <tbody valign="top"> <tr class="row-even"><td>state</td> <td>May be set to “normal” or “disabled” to control the “disabled” state bit. This is a write-only option: setting it changes the widget state, but the <a class="reference internal" href="#ttk.Widget.state" title="ttk.Widget.state"><tt class="xref py py-meth docutils literal"><span class="pre">Widget.state()</span></tt></a> method does not affect this option.</td> </tr> </tbody> </table> </div></blockquote> </div> <div class="section" id="widget-states"> <h3>24.2.3.5. Widget States<a class="headerlink" href="#widget-states" title="Permalink to this headline">¶</a></h3> <p>The widget state is a bitmap of independent state flags.</p> <blockquote> <div><table border="1" class="docutils"> <colgroup> <col width="16%" /> <col width="84%" /> </colgroup> <thead valign="bottom"> <tr class="row-odd"><th class="head">flag</th> <th class="head">description</th> </tr> </thead> <tbody valign="top"> <tr class="row-even"><td>active</td> <td>The mouse cursor is over the widget and pressing a mouse button will cause some action to occur.</td> </tr> <tr class="row-odd"><td>disabled</td> <td>Widget is disabled under program control.</td> </tr> <tr class="row-even"><td>focus</td> <td>Widget has keyboard focus.</td> </tr> <tr class="row-odd"><td>pressed</td> <td>Widget is being pressed.</td> </tr> <tr class="row-even"><td>selected</td> <td>“On”, “true”, or “current” for things like Checkbuttons and radiobuttons.</td> </tr> <tr class="row-odd"><td>background</td> <td>Windows and Mac have a notion of an “active” or foreground window. The <em>background</em> state is set for widgets in a background window, and cleared for those in the foreground window.</td> </tr> <tr class="row-even"><td>readonly</td> <td>Widget should not allow user modification.</td> </tr> <tr class="row-odd"><td>alternate</td> <td>A widget-specific alternate display format.</td> </tr> <tr class="row-even"><td>invalid</td> <td>The widget’s value is invalid.</td> </tr> </tbody> </table> </div></blockquote> <p>A state specification is a sequence of state names, optionally prefixed with an exclamation point indicating that the bit is off.</p> </div> <div class="section" id="ttk-widget"> <h3>24.2.3.6. ttk.Widget<a class="headerlink" href="#ttk-widget" title="Permalink to this headline">¶</a></h3> <p>Besides the methods described below, the <a class="reference internal" href="#ttk.Widget" title="ttk.Widget"><tt class="xref py py-class docutils literal"><span class="pre">ttk.Widget</span></tt></a> class supports the <tt class="xref py py-meth docutils literal"><span class="pre">Tkinter.Widget.cget()</span></tt> and <tt class="xref py py-meth docutils literal"><span class="pre">Tkinter.Widget.configure()</span></tt> methods.</p> <dl class="class"> <dt id="ttk.Widget"> <em class="property">class </em><tt class="descclassname">ttk.</tt><tt class="descname">Widget</tt><a class="headerlink" href="#ttk.Widget" title="Permalink to this definition">¶</a></dt> <dd><dl class="method"> <dt id="ttk.Widget.identify"> <tt class="descname">identify</tt><big>(</big><em>x</em>, <em>y</em><big>)</big><a class="headerlink" href="#ttk.Widget.identify" title="Permalink to this definition">¶</a></dt> <dd><p>Returns the name of the element at position <em>x</em> <em>y</em>, or the empty string if the point does not lie within any element.</p> <p><em>x</em> and <em>y</em> are pixel coordinates relative to the widget.</p> </dd></dl> <dl class="method"> <dt id="ttk.Widget.instate"> <tt class="descname">instate</tt><big>(</big><em>statespec</em>, <em>callback=None</em>, <em>*args</em>, <em>**kw</em><big>)</big><a class="headerlink" href="#ttk.Widget.instate" title="Permalink to this definition">¶</a></dt> <dd><p>Test the widget’s state. If a callback is not specified, returns True if the widget state matches <em>statespec</em> and False otherwise. If callback is specified then it is called with <em>args</em> if widget state matches <em>statespec</em>.</p> </dd></dl> <dl class="method"> <dt id="ttk.Widget.state"> <tt class="descname">state</tt><big>(</big><span class="optional">[</span><em>statespec=None</em><span class="optional">]</span><big>)</big><a class="headerlink" href="#ttk.Widget.state" title="Permalink to this definition">¶</a></dt> <dd><p>Modify or read widget state. If <em>statespec</em> is specified, sets the widget state accordingly and returns a new <em>statespec</em> indicating which flags were changed. If <em>statespec</em> is not specified, returns the currently-enabled state flags.</p> </dd></dl> <p><em>statespec</em> will usually be a list or a tuple.</p> </dd></dl> </div> </div> <div class="section" id="combobox"> <h2>24.2.4. Combobox<a class="headerlink" href="#combobox" title="Permalink to this headline">¶</a></h2> <p>The <a class="reference internal" href="#ttk.Combobox" title="ttk.Combobox"><tt class="xref py py-class docutils literal"><span class="pre">ttk.Combobox</span></tt></a> widget combines a text field with a pop-down list of values. This widget is a subclass of <tt class="xref py py-class docutils literal"><span class="pre">Entry</span></tt>.</p> <p>Besides the methods inherited from <a class="reference internal" href="#ttk.Widget" title="ttk.Widget"><tt class="xref py py-class docutils literal"><span class="pre">Widget</span></tt></a> (<tt class="xref py py-meth docutils literal"><span class="pre">Widget.cget()</span></tt>, <tt class="xref py py-meth docutils literal"><span class="pre">Widget.configure()</span></tt>, <a class="reference internal" href="#ttk.Widget.identify" title="ttk.Widget.identify"><tt class="xref py py-meth docutils literal"><span class="pre">Widget.identify()</span></tt></a>, <a class="reference internal" href="#ttk.Widget.instate" title="ttk.Widget.instate"><tt class="xref py py-meth docutils literal"><span class="pre">Widget.instate()</span></tt></a> and <a class="reference internal" href="#ttk.Widget.state" title="ttk.Widget.state"><tt class="xref py py-meth docutils literal"><span class="pre">Widget.state()</span></tt></a>) and those inherited from <tt class="xref py py-class docutils literal"><span class="pre">Entry</span></tt> (<tt class="xref py py-meth docutils literal"><span class="pre">Entry.bbox()</span></tt>, <tt class="xref py py-meth docutils literal"><span class="pre">Entry.delete()</span></tt>, <tt class="xref py py-meth docutils literal"><span class="pre">Entry.icursor()</span></tt>, <tt class="xref py py-meth docutils literal"><span class="pre">Entry.index()</span></tt>, <tt class="xref py py-meth docutils literal"><span class="pre">Entry.inset()</span></tt>, <tt class="xref py py-meth docutils literal"><span class="pre">Entry.selection()</span></tt>, <tt class="xref py py-meth docutils literal"><span class="pre">Entry.xview()</span></tt>), this class has some other methods, described at <a class="reference internal" href="#ttk.Combobox" title="ttk.Combobox"><tt class="xref py py-class docutils literal"><span class="pre">ttk.Combobox</span></tt></a>.</p> <div class="section" id="options"> <h3>24.2.4.1. Options<a class="headerlink" href="#options" title="Permalink to this headline">¶</a></h3> <p>This widget accepts the following options:</p> <blockquote> <div><table border="1" class="docutils"> <colgroup> <col width="23%" /> <col width="77%" /> </colgroup> <thead valign="bottom"> <tr class="row-odd"><th class="head">option</th> <th class="head">description</th> </tr> </thead> <tbody valign="top"> <tr class="row-even"><td>exportselection</td> <td>Boolean value. If set, the widget selection is linked to the Window Manager selection (which can be returned by invoking <tt class="xref py py-meth docutils literal"><span class="pre">Misc.selection_get()</span></tt>, for example).</td> </tr> <tr class="row-odd"><td>justify</td> <td>Specifies how the text is aligned within the widget. One of “left”, “center”, or “right”.</td> </tr> <tr class="row-even"><td>height</td> <td>Specifies the height of the pop-down listbox, in rows.</td> </tr> <tr class="row-odd"><td>postcommand</td> <td>A script (possibly registered with <tt class="xref py py-meth docutils literal"><span class="pre">Misc.register()</span></tt>) that is called immediately before displaying the values. It may specify which values to display.</td> </tr> <tr class="row-even"><td>state</td> <td>One of “normal”, “readonly”, or “disabled”. In the “readonly” state, the value may not be edited directly, and the user can only select one of the values from the dropdown list. In the “normal” state, the text field is directly editable. In the “disabled” state, no interaction is possible.</td> </tr> <tr class="row-odd"><td>textvariable</td> <td>Specifies a name whose value is linked to the widget value. Whenever the value associated with that name changes, the widget value is updated, and vice versa. See <tt class="xref py py-class docutils literal"><span class="pre">Tkinter.StringVar</span></tt>.</td> </tr> <tr class="row-even"><td>values</td> <td>Specifies the list of values to display in the drop-down listbox.</td> </tr> <tr class="row-odd"><td>width</td> <td>Specifies an integer value indicating the desired width of the entry window, in average-size characters of the widget’s font.</td> </tr> </tbody> </table> </div></blockquote> </div> <div class="section" id="virtual-events"> <h3>24.2.4.2. Virtual events<a class="headerlink" href="#virtual-events" title="Permalink to this headline">¶</a></h3> <p>The combobox widget generates a <strong><<ComboboxSelected>></strong> virtual event when the user selects an element from the list of values.</p> </div> <div class="section" id="ttk-combobox"> <h3>24.2.4.3. ttk.Combobox<a class="headerlink" href="#ttk-combobox" title="Permalink to this headline">¶</a></h3> <dl class="class"> <dt id="ttk.Combobox"> <em class="property">class </em><tt class="descclassname">ttk.</tt><tt class="descname">Combobox</tt><a class="headerlink" href="#ttk.Combobox" title="Permalink to this definition">¶</a></dt> <dd><dl class="method"> <dt id="ttk.Combobox.current"> <tt class="descname">current</tt><big>(</big><span class="optional">[</span><em>newindex=None</em><span class="optional">]</span><big>)</big><a class="headerlink" href="#ttk.Combobox.current" title="Permalink to this definition">¶</a></dt> <dd><p>If <em>newindex</em> is specified, sets the combobox value to the element position <em>newindex</em>. Otherwise, returns the index of the current value or -1 if the current value is not in the values list.</p> </dd></dl> <dl class="method"> <dt id="ttk.Combobox.get"> <tt class="descname">get</tt><big>(</big><big>)</big><a class="headerlink" href="#ttk.Combobox.get" title="Permalink to this definition">¶</a></dt> <dd><p>Returns the current value of the combobox.</p> </dd></dl> <dl class="method"> <dt id="ttk.Combobox.set"> <tt class="descname">set</tt><big>(</big><em>value</em><big>)</big><a class="headerlink" href="#ttk.Combobox.set" title="Permalink to this definition">¶</a></dt> <dd><p>Sets the value of the combobox to <em>value</em>.</p> </dd></dl> </dd></dl> </div> </div> <div class="section" id="notebook"> <h2>24.2.5. Notebook<a class="headerlink" href="#notebook" title="Permalink to this headline">¶</a></h2> <p>The Ttk Notebook widget manages a collection of windows and displays a single one at a time. Each child window is associated with a tab, which the user may select to change the currently-displayed window.</p> <div class="section" id="id1"> <h3>24.2.5.1. Options<a class="headerlink" href="#id1" title="Permalink to this headline">¶</a></h3> <p>This widget accepts the following specific options:</p> <blockquote> <div><table border="1" class="docutils"> <colgroup> <col width="12%" /> <col width="88%" /> </colgroup> <thead valign="bottom"> <tr class="row-odd"><th class="head">option</th> <th class="head">description</th> </tr> </thead> <tbody valign="top"> <tr class="row-even"><td>height</td> <td>If present and greater than zero, specifies the desired height of the pane area (not including internal padding or tabs). Otherwise, the maximum height of all panes is used.</td> </tr> <tr class="row-odd"><td>padding</td> <td>Specifies the amount of extra space to add around the outside of the notebook. The padding is a list of up to four length specifications: left top right bottom. If fewer than four elements are specified, bottom defaults to top, right defaults to left, and top defaults to left.</td> </tr> <tr class="row-even"><td>width</td> <td>If present and greater than zero, specifies the desired width of the pane area (not including internal padding). Otherwise, the maximum width of all panes is used.</td> </tr> </tbody> </table> </div></blockquote> </div> <div class="section" id="tab-options"> <h3>24.2.5.2. Tab Options<a class="headerlink" href="#tab-options" title="Permalink to this headline">¶</a></h3> <p>There are also specific options for tabs:</p> <blockquote> <div><table border="1" class="docutils"> <colgroup> <col width="15%" /> <col width="85%" /> </colgroup> <thead valign="bottom"> <tr class="row-odd"><th class="head">option</th> <th class="head">description</th> </tr> </thead> <tbody valign="top"> <tr class="row-even"><td>state</td> <td>Either “normal”, “disabled” or “hidden”. If “disabled”, then the tab is not selectable. If “hidden”, then the tab is not shown.</td> </tr> <tr class="row-odd"><td>sticky</td> <td>Specifies how the child window is positioned within the pane area. Value is a string containing zero or more of the characters “n”, “s”, “e” or “w”. Each letter refers to a side (north, south, east or west) that the child window will stick to, as per the <tt class="xref py py-meth docutils literal"><span class="pre">grid()</span></tt> geometry manager.</td> </tr> <tr class="row-even"><td>padding</td> <td>Specifies the amount of extra space to add between the notebook and this pane. Syntax is the same as for the option padding used by this widget.</td> </tr> <tr class="row-odd"><td>text</td> <td>Specifies a text to be displayed in the tab.</td> </tr> <tr class="row-even"><td>image</td> <td>Specifies an image to display in the tab. See the option image described in <a class="reference internal" href="#ttk.Widget" title="ttk.Widget"><tt class="xref py py-class docutils literal"><span class="pre">Widget</span></tt></a>.</td> </tr> <tr class="row-odd"><td>compound</td> <td>Specifies how to display the image relative to the text, in the case both text and image options are present. See <a class="reference internal" href="#label-options">Label Options</a> for legal values.</td> </tr> <tr class="row-even"><td>underline</td> <td>Specifies the index (0-based) of a character to underline in the text string. The underlined character is used for mnemonic activation if <a class="reference internal" href="#ttk.Notebook.enable_traversal" title="ttk.Notebook.enable_traversal"><tt class="xref py py-meth docutils literal"><span class="pre">Notebook.enable_traversal()</span></tt></a> is called.</td> </tr> </tbody> </table> </div></blockquote> </div> <div class="section" id="tab-identifiers"> <h3>24.2.5.3. Tab Identifiers<a class="headerlink" href="#tab-identifiers" title="Permalink to this headline">¶</a></h3> <p>The <em>tab_id</em> present in several methods of <a class="reference internal" href="#ttk.Notebook" title="ttk.Notebook"><tt class="xref py py-class docutils literal"><span class="pre">ttk.Notebook</span></tt></a> may take any of the following forms:</p> <ul class="simple"> <li>An integer between zero and the number of tabs.</li> <li>The name of a child window.</li> <li>A positional specification of the form “@x,y”, which identifies the tab.</li> <li>The literal string “current”, which identifies the currently-selected tab.</li> <li>The literal string “end”, which returns the number of tabs (only valid for <a class="reference internal" href="#ttk.Notebook.index" title="ttk.Notebook.index"><tt class="xref py py-meth docutils literal"><span class="pre">Notebook.index()</span></tt></a>).</li> </ul> </div> <div class="section" id="id2"> <h3>24.2.5.4. Virtual Events<a class="headerlink" href="#id2" title="Permalink to this headline">¶</a></h3> <p>This widget generates a <strong><<NotebookTabChanged>></strong> virtual event after a new tab is selected.</p> </div> <div class="section" id="ttk-notebook"> <h3>24.2.5.5. ttk.Notebook<a class="headerlink" href="#ttk-notebook" title="Permalink to this headline">¶</a></h3> <dl class="class"> <dt id="ttk.Notebook"> <em class="property">class </em><tt class="descclassname">ttk.</tt><tt class="descname">Notebook</tt><a class="headerlink" href="#ttk.Notebook" title="Permalink to this definition">¶</a></dt> <dd><dl class="method"> <dt id="ttk.Notebook.add"> <tt class="descname">add</tt><big>(</big><em>child</em>, <em>**kw</em><big>)</big><a class="headerlink" href="#ttk.Notebook.add" title="Permalink to this definition">¶</a></dt> <dd><p>Adds a new tab to the notebook.</p> <p>If window is currently managed by the notebook but hidden, it is restored to its previous position.</p> <p>See <a class="reference internal" href="#tab-options">Tab Options</a> for the list of available options.</p> </dd></dl> <dl class="method"> <dt id="ttk.Notebook.forget"> <tt class="descname">forget</tt><big>(</big><em>tab_id</em><big>)</big><a class="headerlink" href="#ttk.Notebook.forget" title="Permalink to this definition">¶</a></dt> <dd><p>Removes the tab specified by <em>tab_id</em>, unmaps and unmanages the associated window.</p> </dd></dl> <dl class="method"> <dt id="ttk.Notebook.hide"> <tt class="descname">hide</tt><big>(</big><em>tab_id</em><big>)</big><a class="headerlink" href="#ttk.Notebook.hide" title="Permalink to this definition">¶</a></dt> <dd><p>Hides the tab specified by <em>tab_id</em>.</p> <p>The tab will not be displayed, but the associated window remains managed by the notebook and its configuration remembered. Hidden tabs may be restored with the <a class="reference internal" href="#ttk.Notebook.add" title="ttk.Notebook.add"><tt class="xref py py-meth docutils literal"><span class="pre">add()</span></tt></a> command.</p> </dd></dl> <dl class="method"> <dt id="ttk.Notebook.identify"> <tt class="descname">identify</tt><big>(</big><em>x</em>, <em>y</em><big>)</big><a class="headerlink" href="#ttk.Notebook.identify" title="Permalink to this definition">¶</a></dt> <dd><p>Returns the name of the tab element at position <em>x</em>, <em>y</em>, or the empty string if none.</p> </dd></dl> <dl class="method"> <dt id="ttk.Notebook.index"> <tt class="descname">index</tt><big>(</big><em>tab_id</em><big>)</big><a class="headerlink" href="#ttk.Notebook.index" title="Permalink to this definition">¶</a></dt> <dd><p>Returns the numeric index of the tab specified by <em>tab_id</em>, or the total number of tabs if <em>tab_id</em> is the string “end”.</p> </dd></dl> <dl class="method"> <dt id="ttk.Notebook.insert"> <tt class="descname">insert</tt><big>(</big><em>pos</em>, <em>child</em>, <em>**kw</em><big>)</big><a class="headerlink" href="#ttk.Notebook.insert" title="Permalink to this definition">¶</a></dt> <dd><p>Inserts a pane at the specified position.</p> <p><em>pos</em> is either the string “end”, an integer index, or the name of a managed child. If <em>child</em> is already managed by the notebook, moves it to the specified position.</p> <p>See <a class="reference internal" href="#tab-options">Tab Options</a> for the list of available options.</p> </dd></dl> <dl class="method"> <dt id="ttk.Notebook.select"> <tt class="descname">select</tt><big>(</big><span class="optional">[</span><em>tab_id</em><span class="optional">]</span><big>)</big><a class="headerlink" href="#ttk.Notebook.select" title="Permalink to this definition">¶</a></dt> <dd><p>Selects the specified <em>tab_id</em>.</p> <p>The associated child window will be displayed, and the previously-selected window (if different) is unmapped. If <em>tab_id</em> is omitted, returns the widget name of the currently selected pane.</p> </dd></dl> <dl class="method"> <dt id="ttk.Notebook.tab"> <tt class="descname">tab</tt><big>(</big><em>tab_id</em>, <em>option=None</em>, <em>**kw</em><big>)</big><a class="headerlink" href="#ttk.Notebook.tab" title="Permalink to this definition">¶</a></dt> <dd><p>Query or modify the options of the specific <em>tab_id</em>.</p> <p>If <em>kw</em> is not given, returns a dictionary of the tab option values. If <em>option</em> is specified, returns the value of that <em>option</em>. Otherwise, sets the options to the corresponding values.</p> </dd></dl> <dl class="method"> <dt id="ttk.Notebook.tabs"> <tt class="descname">tabs</tt><big>(</big><big>)</big><a class="headerlink" href="#ttk.Notebook.tabs" title="Permalink to this definition">¶</a></dt> <dd><p>Returns a list of windows managed by the notebook.</p> </dd></dl> <dl class="method"> <dt id="ttk.Notebook.enable_traversal"> <tt class="descname">enable_traversal</tt><big>(</big><big>)</big><a class="headerlink" href="#ttk.Notebook.enable_traversal" title="Permalink to this definition">¶</a></dt> <dd><p>Enable keyboard traversal for a toplevel window containing this notebook.</p> <p>This will extend the bindings for the toplevel window containing the notebook as follows:</p> <ul class="simple"> <li>Control-Tab: selects the tab following the currently selected one.</li> <li>Shift-Control-Tab: selects the tab preceding the currently selected one.</li> <li>Alt-K: where K is the mnemonic (underlined) character of any tab, will select that tab.</li> </ul> <p>Multiple notebooks in a single toplevel may be enabled for traversal, including nested notebooks. However, notebook traversal only works properly if all panes have the notebook they are in as master.</p> </dd></dl> </dd></dl> </div> </div> <div class="section" id="progressbar"> <h2>24.2.6. Progressbar<a class="headerlink" href="#progressbar" title="Permalink to this headline">¶</a></h2> <p>The <a class="reference internal" href="#ttk.Progressbar" title="ttk.Progressbar"><tt class="xref py py-class docutils literal"><span class="pre">ttk.Progressbar</span></tt></a> widget shows the status of a long-running operation. It can operate in two modes: determinate mode shows the amount completed relative to the total amount of work to be done, and indeterminate mode provides an animated display to let the user know that something is happening.</p> <div class="section" id="id3"> <h3>24.2.6.1. Options<a class="headerlink" href="#id3" title="Permalink to this headline">¶</a></h3> <p>This widget accepts the following specific options:</p> <blockquote> <div><table border="1" class="docutils"> <colgroup> <col width="14%" /> <col width="86%" /> </colgroup> <thead valign="bottom"> <tr class="row-odd"><th class="head">option</th> <th class="head">description</th> </tr> </thead> <tbody valign="top"> <tr class="row-even"><td>orient</td> <td>One of “horizontal” or “vertical”. Specifies the orientation of the progress bar.</td> </tr> <tr class="row-odd"><td>length</td> <td>Specifies the length of the long axis of the progress bar (width if horizontal, height if vertical).</td> </tr> <tr class="row-even"><td>mode</td> <td>One of “determinate” or “indeterminate”.</td> </tr> <tr class="row-odd"><td>maximum</td> <td>A number specifying the maximum value. Defaults to 100.</td> </tr> <tr class="row-even"><td>value</td> <td>The current value of the progress bar. In “determinate” mode, this represents the amount of work completed. In “indeterminate” mode, it is interpreted as modulo <em>maximum</em>; that is, the progress bar completes one “cycle” when its value increases by <em>maximum</em>.</td> </tr> <tr class="row-odd"><td>variable</td> <td>A name which is linked to the option value. If specified, the value of the progress bar is automatically set to the value of this name whenever the latter is modified.</td> </tr> <tr class="row-even"><td>phase</td> <td>Read-only option. The widget periodically increments the value of this option whenever its value is greater than 0 and, in determinate mode, less than maximum. This option may be used by the current theme to provide additional animation effects.</td> </tr> </tbody> </table> </div></blockquote> </div> <div class="section" id="ttk-progressbar"> <h3>24.2.6.2. ttk.Progressbar<a class="headerlink" href="#ttk-progressbar" title="Permalink to this headline">¶</a></h3> <dl class="class"> <dt id="ttk.Progressbar"> <em class="property">class </em><tt class="descclassname">ttk.</tt><tt class="descname">Progressbar</tt><a class="headerlink" href="#ttk.Progressbar" title="Permalink to this definition">¶</a></dt> <dd><dl class="method"> <dt id="ttk.Progressbar.start"> <tt class="descname">start</tt><big>(</big><span class="optional">[</span><em>interval</em><span class="optional">]</span><big>)</big><a class="headerlink" href="#ttk.Progressbar.start" title="Permalink to this definition">¶</a></dt> <dd><p>Begin autoincrement mode: schedules a recurring timer event that calls <a class="reference internal" href="#ttk.Progressbar.step" title="ttk.Progressbar.step"><tt class="xref py py-meth docutils literal"><span class="pre">Progressbar.step()</span></tt></a> every <em>interval</em> milliseconds. If omitted, <em>interval</em> defaults to 50 milliseconds.</p> </dd></dl> <dl class="method"> <dt id="ttk.Progressbar.step"> <tt class="descname">step</tt><big>(</big><span class="optional">[</span><em>amount</em><span class="optional">]</span><big>)</big><a class="headerlink" href="#ttk.Progressbar.step" title="Permalink to this definition">¶</a></dt> <dd><p>Increments the progress bar’s value by <em>amount</em>.</p> <p><em>amount</em> defaults to 1.0 if omitted.</p> </dd></dl> <dl class="method"> <dt id="ttk.Progressbar.stop"> <tt class="descname">stop</tt><big>(</big><big>)</big><a class="headerlink" href="#ttk.Progressbar.stop" title="Permalink to this definition">¶</a></dt> <dd><p>Stop autoincrement mode: cancels any recurring timer event initiated by <a class="reference internal" href="#ttk.Progressbar.start" title="ttk.Progressbar.start"><tt class="xref py py-meth docutils literal"><span class="pre">Progressbar.start()</span></tt></a> for this progress bar.</p> </dd></dl> </dd></dl> </div> </div> <div class="section" id="separator"> <h2>24.2.7. Separator<a class="headerlink" href="#separator" title="Permalink to this headline">¶</a></h2> <p>The <tt class="xref py py-class docutils literal"><span class="pre">ttk.Separator</span></tt> widget displays a horizontal or vertical separator bar.</p> <p>It has no other methods besides the ones inherited from <a class="reference internal" href="#ttk.Widget" title="ttk.Widget"><tt class="xref py py-class docutils literal"><span class="pre">ttk.Widget</span></tt></a>.</p> <div class="section" id="id4"> <h3>24.2.7.1. Options<a class="headerlink" href="#id4" title="Permalink to this headline">¶</a></h3> <p>This widget accepts the following specific option:</p> <blockquote> <div><table border="1" class="docutils"> <colgroup> <col width="11%" /> <col width="89%" /> </colgroup> <thead valign="bottom"> <tr class="row-odd"><th class="head">option</th> <th class="head">description</th> </tr> </thead> <tbody valign="top"> <tr class="row-even"><td>orient</td> <td>One of “horizontal” or “vertical”. Specifies the orientation of the separator.</td> </tr> </tbody> </table> </div></blockquote> </div> </div> <div class="section" id="sizegrip"> <h2>24.2.8. Sizegrip<a class="headerlink" href="#sizegrip" title="Permalink to this headline">¶</a></h2> <p>The <tt class="xref py py-class docutils literal"><span class="pre">ttk.Sizegrip</span></tt> widget (also known as a grow box) allows the user to resize the containing toplevel window by pressing and dragging the grip.</p> <p>This widget has neither specific options nor specific methods, besides the ones inherited from <a class="reference internal" href="#ttk.Widget" title="ttk.Widget"><tt class="xref py py-class docutils literal"><span class="pre">ttk.Widget</span></tt></a>.</p> <div class="section" id="platform-specific-notes"> <h3>24.2.8.1. Platform-specific notes<a class="headerlink" href="#platform-specific-notes" title="Permalink to this headline">¶</a></h3> <ul class="simple"> <li>On Mac OS X, toplevel windows automatically include a built-in size grip by default. Adding a <tt class="xref py py-class docutils literal"><span class="pre">Sizegrip</span></tt> is harmless, since the built-in grip will just mask the widget.</li> </ul> </div> <div class="section" id="bugs"> <h3>24.2.8.2. Bugs<a class="headerlink" href="#bugs" title="Permalink to this headline">¶</a></h3> <ul class="simple"> <li>If the containing toplevel’s position was specified relative to the right or bottom of the screen (e.g. ....), the <tt class="xref py py-class docutils literal"><span class="pre">Sizegrip</span></tt> widget will not resize the window.</li> <li>This widget supports only “southeast” resizing.</li> </ul> </div> </div> <div class="section" id="treeview"> <h2>24.2.9. Treeview<a class="headerlink" href="#treeview" title="Permalink to this headline">¶</a></h2> <p>The <a class="reference internal" href="#ttk.Treeview" title="ttk.Treeview"><tt class="xref py py-class docutils literal"><span class="pre">ttk.Treeview</span></tt></a> widget displays a hierarchical collection of items. Each item has a textual label, an optional image, and an optional list of data values. The data values are displayed in successive columns after the tree label.</p> <p>The order in which data values are displayed may be controlled by setting the widget option <tt class="docutils literal"><span class="pre">displaycolumns</span></tt>. The tree widget can also display column headings. Columns may be accessed by number or symbolic names listed in the widget option columns. See <a class="reference internal" href="#column-identifiers">Column Identifiers</a>.</p> <p>Each item is identified by an unique name. The widget will generate item IDs if they are not supplied by the caller. There is a distinguished root item, named <tt class="docutils literal"><span class="pre">{}</span></tt>. The root item itself is not displayed; its children appear at the top level of the hierarchy.</p> <p>Each item also has a list of tags, which can be used to associate event bindings with individual items and control the appearance of the item.</p> <p>The Treeview widget supports horizontal and vertical scrolling, according to the options described in <a class="reference internal" href="#scrollable-widget-options">Scrollable Widget Options</a> and the methods <a class="reference internal" href="#ttk.Treeview.xview" title="ttk.Treeview.xview"><tt class="xref py py-meth docutils literal"><span class="pre">Treeview.xview()</span></tt></a> and <a class="reference internal" href="#ttk.Treeview.yview" title="ttk.Treeview.yview"><tt class="xref py py-meth docutils literal"><span class="pre">Treeview.yview()</span></tt></a>.</p> <div class="section" id="id5"> <h3>24.2.9.1. Options<a class="headerlink" href="#id5" title="Permalink to this headline">¶</a></h3> <p>This widget accepts the following specific options:</p> <blockquote> <div><table border="1" class="docutils"> <colgroup> <col width="22%" /> <col width="78%" /> </colgroup> <thead valign="bottom"> <tr class="row-odd"><th class="head">option</th> <th class="head">description</th> </tr> </thead> <tbody valign="top"> <tr class="row-even"><td>columns</td> <td>A list of column identifiers, specifying the number of columns and their names.</td> </tr> <tr class="row-odd"><td>displaycolumns</td> <td>A list of column identifiers (either symbolic or integer indices) specifying which data columns are displayed and the order in which they appear, or the string “#all”.</td> </tr> <tr class="row-even"><td>height</td> <td>Specifies the number of rows which should be visible. Note: the requested width is determined from the sum of the column widths.</td> </tr> <tr class="row-odd"><td>padding</td> <td>Specifies the internal padding for the widget. The padding is a list of up to four length specifications.</td> </tr> <tr class="row-even"><td>selectmode</td> <td><p class="first">Controls how the built-in class bindings manage the selection. One of “extended”, “browse” or “none”. If set to “extended” (the default), multiple items may be selected. If “browse”, only a single item will be selected at a time. If “none”, the selection will not be changed.</p> <p class="last">Note that the application code and tag bindings can set the selection however they wish, regardless of the value of this option.</p> </td> </tr> <tr class="row-odd"><td>show</td> <td><p class="first">A list containing zero or more of the following values, specifying which elements of the tree to display.</p> <ul class="simple"> <li>tree: display tree labels in column #0.</li> <li>headings: display the heading row.</li> </ul> <p>The default is “tree headings”, i.e., show all elements.</p> <p class="last"><strong>Note</strong>: Column #0 always refers to the tree column, even if show=”tree” is not specified.</p> </td> </tr> </tbody> </table> </div></blockquote> </div> <div class="section" id="item-options"> <h3>24.2.9.2. Item Options<a class="headerlink" href="#item-options" title="Permalink to this headline">¶</a></h3> <p>The following item options may be specified for items in the insert and item widget commands.</p> <blockquote> <div><table border="1" class="docutils"> <colgroup> <col width="11%" /> <col width="89%" /> </colgroup> <thead valign="bottom"> <tr class="row-odd"><th class="head">option</th> <th class="head">description</th> </tr> </thead> <tbody valign="top"> <tr class="row-even"><td>text</td> <td>The textual label to display for the item.</td> </tr> <tr class="row-odd"><td>image</td> <td>A Tk Image, displayed to the left of the label.</td> </tr> <tr class="row-even"><td>values</td> <td><p class="first">The list of values associated with the item.</p> <p class="last">Each item should have the same number of values as the widget option columns. If there are fewer values than columns, the remaining values are assumed empty. If there are more values than columns, the extra values are ignored.</p> </td> </tr> <tr class="row-odd"><td>open</td> <td>True/False value indicating whether the item’s children should be displayed or hidden.</td> </tr> <tr class="row-even"><td>tags</td> <td>A list of tags associated with this item.</td> </tr> </tbody> </table> </div></blockquote> </div> <div class="section" id="tag-options"> <h3>24.2.9.3. Tag Options<a class="headerlink" href="#tag-options" title="Permalink to this headline">¶</a></h3> <p>The following options may be specified on tags:</p> <blockquote> <div><table border="1" class="docutils"> <colgroup> <col width="17%" /> <col width="83%" /> </colgroup> <thead valign="bottom"> <tr class="row-odd"><th class="head">option</th> <th class="head">description</th> </tr> </thead> <tbody valign="top"> <tr class="row-even"><td>foreground</td> <td>Specifies the text foreground color.</td> </tr> <tr class="row-odd"><td>background</td> <td>Specifies the cell or item background color.</td> </tr> <tr class="row-even"><td>font</td> <td>Specifies the font to use when drawing text.</td> </tr> <tr class="row-odd"><td>image</td> <td>Specifies the item image, in case the item’s image option is empty.</td> </tr> </tbody> </table> </div></blockquote> </div> <div class="section" id="column-identifiers"> <h3>24.2.9.4. Column Identifiers<a class="headerlink" href="#column-identifiers" title="Permalink to this headline">¶</a></h3> <p>Column identifiers take any of the following forms:</p> <ul class="simple"> <li>A symbolic name from the list of columns option.</li> <li>An integer n, specifying the nth data column.</li> <li>A string of the form #n, where n is an integer, specifying the nth display column.</li> </ul> <p>Notes:</p> <ul class="simple"> <li>Item’s option values may be displayed in a different order than the order in which they are stored.</li> <li>Column #0 always refers to the tree column, even if show=”tree” is not specified.</li> </ul> <p>A data column number is an index into an item’s option values list; a display column number is the column number in the tree where the values are displayed. Tree labels are displayed in column #0. If option displaycolumns is not set, then data column n is displayed in column #n+1. Again, <strong>column #0 always refers to the tree column</strong>.</p> </div> <div class="section" id="id6"> <h3>24.2.9.5. Virtual Events<a class="headerlink" href="#id6" title="Permalink to this headline">¶</a></h3> <p>The Treeview widget generates the following virtual events.</p> <blockquote> <div><table border="1" class="docutils"> <colgroup> <col width="29%" /> <col width="71%" /> </colgroup> <thead valign="bottom"> <tr class="row-odd"><th class="head">event</th> <th class="head">description</th> </tr> </thead> <tbody valign="top"> <tr class="row-even"><td><<TreeviewSelect>></td> <td>Generated whenever the selection changes.</td> </tr> <tr class="row-odd"><td><<TreeviewOpen>></td> <td>Generated just before settings the focus item to open=True.</td> </tr> <tr class="row-even"><td><<TreeviewClose>></td> <td>Generated just after setting the focus item to open=False.</td> </tr> </tbody> </table> </div></blockquote> <p>The <a class="reference internal" href="#ttk.Treeview.focus" title="ttk.Treeview.focus"><tt class="xref py py-meth docutils literal"><span class="pre">Treeview.focus()</span></tt></a> and <a class="reference internal" href="#ttk.Treeview.selection" title="ttk.Treeview.selection"><tt class="xref py py-meth docutils literal"><span class="pre">Treeview.selection()</span></tt></a> methods can be used to determine the affected item or items.</p> </div> <div class="section" id="ttk-treeview"> <h3>24.2.9.6. ttk.Treeview<a class="headerlink" href="#ttk-treeview" title="Permalink to this headline">¶</a></h3> <dl class="class"> <dt id="ttk.Treeview"> <em class="property">class </em><tt class="descclassname">ttk.</tt><tt class="descname">Treeview</tt><a class="headerlink" href="#ttk.Treeview" title="Permalink to this definition">¶</a></dt> <dd><dl class="method"> <dt id="ttk.Treeview.bbox"> <tt class="descname">bbox</tt><big>(</big><em>item</em>, <em>column=None</em><big>)</big><a class="headerlink" href="#ttk.Treeview.bbox" title="Permalink to this definition">¶</a></dt> <dd><p>Returns the bounding box (relative to the treeview widget’s window) of the specified <em>item</em> in the form (x, y, width, height).</p> <p>If <em>column</em> is specified, returns the bounding box of that cell. If the <em>item</em> is not visible (i.e., if it is a descendant of a closed item or is scrolled offscreen), returns an empty string.</p> </dd></dl> <dl class="method"> <dt id="ttk.Treeview.get_children"> <tt class="descname">get_children</tt><big>(</big><span class="optional">[</span><em>item</em><span class="optional">]</span><big>)</big><a class="headerlink" href="#ttk.Treeview.get_children" title="Permalink to this definition">¶</a></dt> <dd><p>Returns the list of children belonging to <em>item</em>.</p> <p>If <em>item</em> is not specified, returns root children.</p> </dd></dl> <dl class="method"> <dt id="ttk.Treeview.set_children"> <tt class="descname">set_children</tt><big>(</big><em>item</em>, <em>*newchildren</em><big>)</big><a class="headerlink" href="#ttk.Treeview.set_children" title="Permalink to this definition">¶</a></dt> <dd><p>Replaces <em>item</em>‘s child with <em>newchildren</em>.</p> <p>Children present in <em>item</em> that are not present in <em>newchildren</em> are detached from the tree. No items in <em>newchildren</em> may be an ancestor of <em>item</em>. Note that not specifying <em>newchildren</em> results in detaching <em>item</em>‘s children.</p> </dd></dl> <dl class="method"> <dt id="ttk.Treeview.column"> <tt class="descname">column</tt><big>(</big><em>column</em>, <em>option=None</em>, <em>**kw</em><big>)</big><a class="headerlink" href="#ttk.Treeview.column" title="Permalink to this definition">¶</a></dt> <dd><p>Query or modify the options for the specified <em>column</em>.</p> <p>If <em>kw</em> is not given, returns a dict of the column option values. If <em>option</em> is specified then the value for that <em>option</em> is returned. Otherwise, sets the options to the corresponding values.</p> <p>The valid options/values are:</p> <ul> <li><dl class="first docutils"> <dt>id</dt> <dd><p class="first last">Returns the column name. This is a read-only option.</p> </dd> </dl> </li> <li><dl class="first docutils"> <dt>anchor: One of the standard Tk anchor values.</dt> <dd><p class="first last">Specifies how the text in this column should be aligned with respect to the cell.</p> </dd> </dl> </li> <li><dl class="first docutils"> <dt>minwidth: width</dt> <dd><p class="first last">The minimum width of the column in pixels. The treeview widget will not make the column any smaller than specified by this option when the widget is resized or the user drags a column.</p> </dd> </dl> </li> <li><dl class="first docutils"> <dt>stretch: True/False</dt> <dd><p class="first last">Specifies whether the column’s width should be adjusted when the widget is resized.</p> </dd> </dl> </li> <li><dl class="first docutils"> <dt>width: width</dt> <dd><p class="first last">The width of the column in pixels.</p> </dd> </dl> </li> </ul> <p>To configure the tree column, call this with column = “#0”</p> </dd></dl> <dl class="method"> <dt id="ttk.Treeview.delete"> <tt class="descname">delete</tt><big>(</big><em>*items</em><big>)</big><a class="headerlink" href="#ttk.Treeview.delete" title="Permalink to this definition">¶</a></dt> <dd><p>Delete all specified <em>items</em> and all their descendants.</p> <p>The root item may not be deleted.</p> </dd></dl> <dl class="method"> <dt id="ttk.Treeview.detach"> <tt class="descname">detach</tt><big>(</big><em>*items</em><big>)</big><a class="headerlink" href="#ttk.Treeview.detach" title="Permalink to this definition">¶</a></dt> <dd><p>Unlinks all of the specified <em>items</em> from the tree.</p> <p>The items and all of their descendants are still present, and may be reinserted at another point in the tree, but will not be displayed.</p> <p>The root item may not be detached.</p> </dd></dl> <dl class="method"> <dt id="ttk.Treeview.exists"> <tt class="descname">exists</tt><big>(</big><em>item</em><big>)</big><a class="headerlink" href="#ttk.Treeview.exists" title="Permalink to this definition">¶</a></dt> <dd><p>Returns True if the specified <em>item</em> is present in the tree.</p> </dd></dl> <dl class="method"> <dt id="ttk.Treeview.focus"> <tt class="descname">focus</tt><big>(</big><span class="optional">[</span><em>item=None</em><span class="optional">]</span><big>)</big><a class="headerlink" href="#ttk.Treeview.focus" title="Permalink to this definition">¶</a></dt> <dd><p>If <em>item</em> is specified, sets the focus item to <em>item</em>. Otherwise, returns the current focus item, or ‘’ if there is none.</p> </dd></dl> <dl class="method"> <dt id="ttk.Treeview.heading"> <tt class="descname">heading</tt><big>(</big><em>column</em>, <em>option=None</em>, <em>**kw</em><big>)</big><a class="headerlink" href="#ttk.Treeview.heading" title="Permalink to this definition">¶</a></dt> <dd><p>Query or modify the heading options for the specified <em>column</em>.</p> <p>If <em>kw</em> is not given, returns a dict of the heading option values. If <em>option</em> is specified then the value for that <em>option</em> is returned. Otherwise, sets the options to the corresponding values.</p> <p>The valid options/values are:</p> <ul> <li><dl class="first docutils"> <dt>text: text</dt> <dd><p class="first last">The text to display in the column heading.</p> </dd> </dl> </li> <li><dl class="first docutils"> <dt>image: imageName</dt> <dd><p class="first last">Specifies an image to display to the right of the column heading.</p> </dd> </dl> </li> <li><dl class="first docutils"> <dt>anchor: anchor</dt> <dd><p class="first last">Specifies how the heading text should be aligned. One of the standard Tk anchor values.</p> </dd> </dl> </li> <li><dl class="first docutils"> <dt>command: callback</dt> <dd><p class="first last">A callback to be invoked when the heading label is pressed.</p> </dd> </dl> </li> </ul> <p>To configure the tree column heading, call this with column = “#0”.</p> </dd></dl> <dl class="method"> <dt id="ttk.Treeview.identify"> <tt class="descname">identify</tt><big>(</big><em>component</em>, <em>x</em>, <em>y</em><big>)</big><a class="headerlink" href="#ttk.Treeview.identify" title="Permalink to this definition">¶</a></dt> <dd><p>Returns a description of the specified <em>component</em> under the point given by <em>x</em> and <em>y</em>, or the empty string if no such <em>component</em> is present at that position.</p> </dd></dl> <dl class="method"> <dt id="ttk.Treeview.identify_row"> <tt class="descname">identify_row</tt><big>(</big><em>y</em><big>)</big><a class="headerlink" href="#ttk.Treeview.identify_row" title="Permalink to this definition">¶</a></dt> <dd><p>Returns the item ID of the item at position <em>y</em>.</p> </dd></dl> <dl class="method"> <dt id="ttk.Treeview.identify_column"> <tt class="descname">identify_column</tt><big>(</big><em>x</em><big>)</big><a class="headerlink" href="#ttk.Treeview.identify_column" title="Permalink to this definition">¶</a></dt> <dd><p>Returns the data column identifier of the cell at position <em>x</em>.</p> <p>The tree column has ID #0.</p> </dd></dl> <dl class="method"> <dt id="ttk.Treeview.identify_region"> <tt class="descname">identify_region</tt><big>(</big><em>x</em>, <em>y</em><big>)</big><a class="headerlink" href="#ttk.Treeview.identify_region" title="Permalink to this definition">¶</a></dt> <dd><p>Returns one of:</p> <table border="1" class="docutils"> <colgroup> <col width="22%" /> <col width="78%" /> </colgroup> <thead valign="bottom"> <tr class="row-odd"><th class="head">region</th> <th class="head">meaning</th> </tr> </thead> <tbody valign="top"> <tr class="row-even"><td>heading</td> <td>Tree heading area.</td> </tr> <tr class="row-odd"><td>separator</td> <td>Space between two columns headings.</td> </tr> <tr class="row-even"><td>tree</td> <td>The tree area.</td> </tr> <tr class="row-odd"><td>cell</td> <td>A data cell.</td> </tr> </tbody> </table> <p>Availability: Tk 8.6.</p> </dd></dl> <dl class="method"> <dt id="ttk.Treeview.identify_element"> <tt class="descname">identify_element</tt><big>(</big><em>x</em>, <em>y</em><big>)</big><a class="headerlink" href="#ttk.Treeview.identify_element" title="Permalink to this definition">¶</a></dt> <dd><p>Returns the element at position <em>x</em>, <em>y</em>.</p> <p>Availability: Tk 8.6.</p> </dd></dl> <dl class="method"> <dt id="ttk.Treeview.index"> <tt class="descname">index</tt><big>(</big><em>item</em><big>)</big><a class="headerlink" href="#ttk.Treeview.index" title="Permalink to this definition">¶</a></dt> <dd><p>Returns the integer index of <em>item</em> within its parent’s list of children.</p> </dd></dl> <dl class="method"> <dt id="ttk.Treeview.insert"> <tt class="descname">insert</tt><big>(</big><em>parent</em>, <em>index</em>, <em>iid=None</em>, <em>**kw</em><big>)</big><a class="headerlink" href="#ttk.Treeview.insert" title="Permalink to this definition">¶</a></dt> <dd><p>Creates a new item and returns the item identifier of the newly created item.</p> <p><em>parent</em> is the item ID of the parent item, or the empty string to create a new top-level item. <em>index</em> is an integer, or the value “end”, specifying where in the list of parent’s children to insert the new item. If <em>index</em> is less than or equal to zero, the new node is inserted at the beginning; if <em>index</em> is greater than or equal to the current number of children, it is inserted at the end. If <em>iid</em> is specified, it is used as the item identifier; <em>iid</em> must not already exist in the tree. Otherwise, a new unique identifier is generated.</p> <p>See <a class="reference internal" href="#item-options">Item Options</a> for the list of available points.</p> </dd></dl> <dl class="method"> <dt id="ttk.Treeview.item"> <tt class="descname">item</tt><big>(</big><em>item</em><span class="optional">[</span>, <em>option</em><span class="optional">[</span>, <em>**kw</em><span class="optional">]</span><span class="optional">]</span><big>)</big><a class="headerlink" href="#ttk.Treeview.item" title="Permalink to this definition">¶</a></dt> <dd><p>Query or modify the options for the specified <em>item</em>.</p> <p>If no options are given, a dict with options/values for the item is returned. If <em>option</em> is specified then the value for that option is returned. Otherwise, sets the options to the corresponding values as given by <em>kw</em>.</p> </dd></dl> <dl class="method"> <dt id="ttk.Treeview.move"> <tt class="descname">move</tt><big>(</big><em>item</em>, <em>parent</em>, <em>index</em><big>)</big><a class="headerlink" href="#ttk.Treeview.move" title="Permalink to this definition">¶</a></dt> <dd><p>Moves <em>item</em> to position <em>index</em> in <em>parent</em>‘s list of children.</p> <p>It is illegal to move an item under one of its descendants. If <em>index</em> is less than or equal to zero, <em>item</em> is moved to the beginning; if greater than or equal to the number of children, it is moved to the end. If <em>item</em> was detached it is reattached.</p> </dd></dl> <dl class="method"> <dt id="ttk.Treeview.next"> <tt class="descname">next</tt><big>(</big><em>item</em><big>)</big><a class="headerlink" href="#ttk.Treeview.next" title="Permalink to this definition">¶</a></dt> <dd><p>Returns the identifier of <em>item</em>‘s next sibling, or ‘’ if <em>item</em> is the last child of its parent.</p> </dd></dl> <dl class="method"> <dt id="ttk.Treeview.parent"> <tt class="descname">parent</tt><big>(</big><em>item</em><big>)</big><a class="headerlink" href="#ttk.Treeview.parent" title="Permalink to this definition">¶</a></dt> <dd><p>Returns the ID of the parent of <em>item</em>, or ‘’ if <em>item</em> is at the top level of the hierarchy.</p> </dd></dl> <dl class="method"> <dt id="ttk.Treeview.prev"> <tt class="descname">prev</tt><big>(</big><em>item</em><big>)</big><a class="headerlink" href="#ttk.Treeview.prev" title="Permalink to this definition">¶</a></dt> <dd><p>Returns the identifier of <em>item</em>‘s previous sibling, or ‘’ if <em>item</em> is the first child of its parent.</p> </dd></dl> <dl class="method"> <dt id="ttk.Treeview.reattach"> <tt class="descname">reattach</tt><big>(</big><em>item</em>, <em>parent</em>, <em>index</em><big>)</big><a class="headerlink" href="#ttk.Treeview.reattach" title="Permalink to this definition">¶</a></dt> <dd><p>An alias for <a class="reference internal" href="#ttk.Treeview.move" title="ttk.Treeview.move"><tt class="xref py py-meth docutils literal"><span class="pre">Treeview.move()</span></tt></a>.</p> </dd></dl> <dl class="method"> <dt id="ttk.Treeview.see"> <tt class="descname">see</tt><big>(</big><em>item</em><big>)</big><a class="headerlink" href="#ttk.Treeview.see" title="Permalink to this definition">¶</a></dt> <dd><p>Ensure that <em>item</em> is visible.</p> <p>Sets all of <em>item</em>‘s ancestors open option to True, and scrolls the widget if necessary so that <em>item</em> is within the visible portion of the tree.</p> </dd></dl> <dl class="method"> <dt id="ttk.Treeview.selection"> <tt class="descname">selection</tt><big>(</big><span class="optional">[</span><em>selop=None</em><span class="optional">[</span>, <em>items=None</em><span class="optional">]</span><span class="optional">]</span><big>)</big><a class="headerlink" href="#ttk.Treeview.selection" title="Permalink to this definition">¶</a></dt> <dd><p>If <em>selop</em> is not specified, returns selected items. Otherwise, it will act according to the following selection methods.</p> </dd></dl> <dl class="method"> <dt id="ttk.Treeview.selection_set"> <tt class="descname">selection_set</tt><big>(</big><em>items</em><big>)</big><a class="headerlink" href="#ttk.Treeview.selection_set" title="Permalink to this definition">¶</a></dt> <dd><p><em>items</em> becomes the new selection.</p> </dd></dl> <dl class="method"> <dt id="ttk.Treeview.selection_add"> <tt class="descname">selection_add</tt><big>(</big><em>items</em><big>)</big><a class="headerlink" href="#ttk.Treeview.selection_add" title="Permalink to this definition">¶</a></dt> <dd><p>Add <em>items</em> to the selection.</p> </dd></dl> <dl class="method"> <dt id="ttk.Treeview.selection_remove"> <tt class="descname">selection_remove</tt><big>(</big><em>items</em><big>)</big><a class="headerlink" href="#ttk.Treeview.selection_remove" title="Permalink to this definition">¶</a></dt> <dd><p>Remove <em>items</em> from the selection.</p> </dd></dl> <dl class="method"> <dt id="ttk.Treeview.selection_toggle"> <tt class="descname">selection_toggle</tt><big>(</big><em>items</em><big>)</big><a class="headerlink" href="#ttk.Treeview.selection_toggle" title="Permalink to this definition">¶</a></dt> <dd><p>Toggle the selection state of each item in <em>items</em>.</p> </dd></dl> <dl class="method"> <dt id="ttk.Treeview.set"> <tt class="descname">set</tt><big>(</big><em>item</em>, <em>column=None</em>, <em>value=None</em><big>)</big><a class="headerlink" href="#ttk.Treeview.set" title="Permalink to this definition">¶</a></dt> <dd><p>With one argument, returns a dictionary of column/value pairs for the specified <em>item</em>. With two arguments, returns the current value of the specified <em>column</em>. With three arguments, sets the value of given <em>column</em> in given <em>item</em> to the specified <em>value</em>.</p> </dd></dl> <dl class="method"> <dt id="ttk.Treeview.tag_bind"> <tt class="descname">tag_bind</tt><big>(</big><em>tagname</em>, <em>sequence=None</em>, <em>callback=None</em><big>)</big><a class="headerlink" href="#ttk.Treeview.tag_bind" title="Permalink to this definition">¶</a></dt> <dd><p>Bind a callback for the given event <em>sequence</em> to the tag <em>tagname</em>. When an event is delivered to an item, the callbacks for each of the item’s tags option are called.</p> </dd></dl> <dl class="method"> <dt id="ttk.Treeview.tag_configure"> <tt class="descname">tag_configure</tt><big>(</big><em>tagname</em>, <em>option=None</em>, <em>**kw</em><big>)</big><a class="headerlink" href="#ttk.Treeview.tag_configure" title="Permalink to this definition">¶</a></dt> <dd><p>Query or modify the options for the specified <em>tagname</em>.</p> <p>If <em>kw</em> is not given, returns a dict of the option settings for <em>tagname</em>. If <em>option</em> is specified, returns the value for that <em>option</em> for the specified <em>tagname</em>. Otherwise, sets the options to the corresponding values for the given <em>tagname</em>.</p> </dd></dl> <dl class="method"> <dt id="ttk.Treeview.tag_has"> <tt class="descname">tag_has</tt><big>(</big><em>tagname</em><span class="optional">[</span>, <em>item</em><span class="optional">]</span><big>)</big><a class="headerlink" href="#ttk.Treeview.tag_has" title="Permalink to this definition">¶</a></dt> <dd><p>If <em>item</em> is specified, returns 1 or 0 depending on whether the specified <em>item</em> has the given <em>tagname</em>. Otherwise, returns a list of all items that have the specified tag.</p> <p>Availability: Tk 8.6</p> </dd></dl> <dl class="method"> <dt id="ttk.Treeview.xview"> <tt class="descname">xview</tt><big>(</big><em>*args</em><big>)</big><a class="headerlink" href="#ttk.Treeview.xview" title="Permalink to this definition">¶</a></dt> <dd><p>Query or modify horizontal position of the treeview.</p> </dd></dl> <dl class="method"> <dt id="ttk.Treeview.yview"> <tt class="descname">yview</tt><big>(</big><em>*args</em><big>)</big><a class="headerlink" href="#ttk.Treeview.yview" title="Permalink to this definition">¶</a></dt> <dd><p>Query or modify vertical position of the treeview.</p> </dd></dl> </dd></dl> </div> </div> <div class="section" id="ttk-styling"> <span id="ttkstyling"></span><h2>24.2.10. Ttk Styling<a class="headerlink" href="#ttk-styling" title="Permalink to this headline">¶</a></h2> <p>Each widget in <a class="reference internal" href="#module-ttk" title="ttk: Tk themed widget set"><tt class="xref py py-mod docutils literal"><span class="pre">ttk</span></tt></a> is assigned a style, which specifies the set of elements making up the widget and how they are arranged, along with dynamic and default settings for element options. By default the style name is the same as the widget’s class name, but it may be overridden by the widget’s style option. If the class name of a widget is unknown, use the method <tt class="xref py py-meth docutils literal"><span class="pre">Misc.winfo_class()</span></tt> (somewidget.winfo_class()).</p> <div class="admonition-see-also admonition seealso"> <p class="first admonition-title">See also</p> <dl class="last docutils"> <dt><a class="reference external" href="http://tktable.sourceforge.net/tile/tile-tcl2004.pdf">Tcl‘2004 conference presentation</a></dt> <dd>This document explains how the theme engine works</dd> </dl> </div> <dl class="class"> <dt id="ttk.Style"> <em class="property">class </em><tt class="descclassname">ttk.</tt><tt class="descname">Style</tt><a class="headerlink" href="#ttk.Style" title="Permalink to this definition">¶</a></dt> <dd><p>This class is used to manipulate the style database.</p> <dl class="method"> <dt id="ttk.Style.configure"> <tt class="descname">configure</tt><big>(</big><em>style</em>, <em>query_opt=None</em>, <em>**kw</em><big>)</big><a class="headerlink" href="#ttk.Style.configure" title="Permalink to this definition">¶</a></dt> <dd><p>Query or set the default value of the specified option(s) in <em>style</em>.</p> <p>Each key in <em>kw</em> is an option and each value is a string identifying the value for that option.</p> <p>For example, to change every default button to be a flat button with some padding and a different background color do:</p> <div class="highlight-python"><div class="highlight"><pre><span class="kn">import</span> <span class="nn">ttk</span> <span class="kn">import</span> <span class="nn">Tkinter</span> <span class="n">root</span> <span class="o">=</span> <span class="n">Tkinter</span><span class="o">.</span><span class="n">Tk</span><span class="p">()</span> <span class="n">ttk</span><span class="o">.</span><span class="n">Style</span><span class="p">()</span><span class="o">.</span><span class="n">configure</span><span class="p">(</span><span class="s">"TButton"</span><span class="p">,</span> <span class="n">padding</span><span class="o">=</span><span class="mi">6</span><span class="p">,</span> <span class="n">relief</span><span class="o">=</span><span class="s">"flat"</span><span class="p">,</span> <span class="n">background</span><span class="o">=</span><span class="s">"#ccc"</span><span class="p">)</span> <span class="n">btn</span> <span class="o">=</span> <span class="n">ttk</span><span class="o">.</span><span class="n">Button</span><span class="p">(</span><span class="n">text</span><span class="o">=</span><span class="s">"Sample"</span><span class="p">)</span> <span class="n">btn</span><span class="o">.</span><span class="n">pack</span><span class="p">()</span> <span class="n">root</span><span class="o">.</span><span class="n">mainloop</span><span class="p">()</span> </pre></div> </div> </dd></dl> <dl class="method"> <dt id="ttk.Style.map"> <tt class="descname">map</tt><big>(</big><em>style</em>, <em>query_opt=None</em>, <em>**kw</em><big>)</big><a class="headerlink" href="#ttk.Style.map" title="Permalink to this definition">¶</a></dt> <dd><p>Query or sets dynamic values of the specified option(s) in <em>style</em>.</p> <p>Each key in <em>kw</em> is an option and each value should be a list or a tuple (usually) containing statespecs grouped in tuples, lists, or something else of your preference. A statespec is a compound of one or more states and then a value.</p> <p>An example:</p> <div class="highlight-python"><div class="highlight"><pre><span class="kn">import</span> <span class="nn">Tkinter</span> <span class="kn">import</span> <span class="nn">ttk</span> <span class="n">root</span> <span class="o">=</span> <span class="n">Tkinter</span><span class="o">.</span><span class="n">Tk</span><span class="p">()</span> <span class="n">style</span> <span class="o">=</span> <span class="n">ttk</span><span class="o">.</span><span class="n">Style</span><span class="p">()</span> <span class="n">style</span><span class="o">.</span><span class="n">map</span><span class="p">(</span><span class="s">"C.TButton"</span><span class="p">,</span> <span class="n">foreground</span><span class="o">=</span><span class="p">[(</span><span class="s">'pressed'</span><span class="p">,</span> <span class="s">'red'</span><span class="p">),</span> <span class="p">(</span><span class="s">'active'</span><span class="p">,</span> <span class="s">'blue'</span><span class="p">)],</span> <span class="n">background</span><span class="o">=</span><span class="p">[(</span><span class="s">'pressed'</span><span class="p">,</span> <span class="s">'!disabled'</span><span class="p">,</span> <span class="s">'black'</span><span class="p">),</span> <span class="p">(</span><span class="s">'active'</span><span class="p">,</span> <span class="s">'white'</span><span class="p">)]</span> <span class="p">)</span> <span class="n">colored_btn</span> <span class="o">=</span> <span class="n">ttk</span><span class="o">.</span><span class="n">Button</span><span class="p">(</span><span class="n">text</span><span class="o">=</span><span class="s">"Test"</span><span class="p">,</span> <span class="n">style</span><span class="o">=</span><span class="s">"C.TButton"</span><span class="p">)</span><span class="o">.</span><span class="n">pack</span><span class="p">()</span> <span class="n">root</span><span class="o">.</span><span class="n">mainloop</span><span class="p">()</span> </pre></div> </div> <p>Note that the order of the (states, value) sequences for an option matters. In the previous example, if you change the order to <tt class="docutils literal"><span class="pre">[('active',</span> <span class="pre">'blue'),</span> <span class="pre">('pressed',</span> <span class="pre">'red')]</span></tt> in the foreground option, for example, you would get a blue foreground when the widget is in the active or pressed states.</p> </dd></dl> <dl class="method"> <dt id="ttk.Style.lookup"> <tt class="descname">lookup</tt><big>(</big><em>style</em>, <em>option</em>, <em>state=None</em>, <em>default=None</em><big>)</big><a class="headerlink" href="#ttk.Style.lookup" title="Permalink to this definition">¶</a></dt> <dd><p>Returns the value specified for <em>option</em> in <em>style</em>.</p> <p>If <em>state</em> is specified, it is expected to be a sequence of one or more states. If the <em>default</em> argument is set, it is used as a fallback value in case no specification for option is found.</p> <p>To check what font a Button uses by default, do:</p> <div class="highlight-python"><div class="highlight"><pre><span class="kn">import</span> <span class="nn">ttk</span> <span class="k">print</span> <span class="n">ttk</span><span class="o">.</span><span class="n">Style</span><span class="p">()</span><span class="o">.</span><span class="n">lookup</span><span class="p">(</span><span class="s">"TButton"</span><span class="p">,</span> <span class="s">"font"</span><span class="p">)</span> </pre></div> </div> </dd></dl> <dl class="method"> <dt id="ttk.Style.layout"> <tt class="descname">layout</tt><big>(</big><em>style</em>, <em>layoutspec=None</em><big>)</big><a class="headerlink" href="#ttk.Style.layout" title="Permalink to this definition">¶</a></dt> <dd><p>Define the widget layout for given <em>style</em>. If <em>layoutspec</em> is omitted, return the layout specification for given style.</p> <p><em>layoutspec</em>, if specified, is expected to be a list or some other sequence type (excluding strings), where each item should be a tuple and the first item is the layout name and the second item should have the format described in <a class="reference internal" href="#layouts">Layouts</a>.</p> <p>To understand the format, see the following example (it is not intended to do anything useful):</p> <div class="highlight-python"><div class="highlight"><pre><span class="kn">import</span> <span class="nn">ttk</span> <span class="kn">import</span> <span class="nn">Tkinter</span> <span class="n">root</span> <span class="o">=</span> <span class="n">Tkinter</span><span class="o">.</span><span class="n">Tk</span><span class="p">()</span> <span class="n">style</span> <span class="o">=</span> <span class="n">ttk</span><span class="o">.</span><span class="n">Style</span><span class="p">()</span> <span class="n">style</span><span class="o">.</span><span class="n">layout</span><span class="p">(</span><span class="s">"TMenubutton"</span><span class="p">,</span> <span class="p">[</span> <span class="p">(</span><span class="s">"Menubutton.background"</span><span class="p">,</span> <span class="bp">None</span><span class="p">),</span> <span class="p">(</span><span class="s">"Menubutton.button"</span><span class="p">,</span> <span class="p">{</span><span class="s">"children"</span><span class="p">:</span> <span class="p">[(</span><span class="s">"Menubutton.focus"</span><span class="p">,</span> <span class="p">{</span><span class="s">"children"</span><span class="p">:</span> <span class="p">[(</span><span class="s">"Menubutton.padding"</span><span class="p">,</span> <span class="p">{</span><span class="s">"children"</span><span class="p">:</span> <span class="p">[(</span><span class="s">"Menubutton.label"</span><span class="p">,</span> <span class="p">{</span><span class="s">"side"</span><span class="p">:</span> <span class="s">"left"</span><span class="p">,</span> <span class="s">"expand"</span><span class="p">:</span> <span class="mi">1</span><span class="p">})]</span> <span class="p">})]</span> <span class="p">})]</span> <span class="p">}),</span> <span class="p">])</span> <span class="n">mbtn</span> <span class="o">=</span> <span class="n">ttk</span><span class="o">.</span><span class="n">Menubutton</span><span class="p">(</span><span class="n">text</span><span class="o">=</span><span class="s">'Text'</span><span class="p">)</span> <span class="n">mbtn</span><span class="o">.</span><span class="n">pack</span><span class="p">()</span> <span class="n">root</span><span class="o">.</span><span class="n">mainloop</span><span class="p">()</span> </pre></div> </div> </dd></dl> <dl class="method"> <dt id="ttk.Style.element_create"> <tt class="descname">element_create</tt><big>(</big><em>elementname</em>, <em>etype</em>, <em>*args</em>, <em>**kw</em><big>)</big><a class="headerlink" href="#ttk.Style.element_create" title="Permalink to this definition">¶</a></dt> <dd><p>Create a new element in the current theme, of the given <em>etype</em> which is expected to be either “image”, “from” or “vsapi”. The latter is only available in Tk 8.6a for Windows XP and Vista and is not described here.</p> <p>If “image” is used, <em>args</em> should contain the default image name followed by statespec/value pairs (this is the imagespec), and <em>kw</em> may have the following options:</p> <blockquote> <div><ul> <li><dl class="first docutils"> <dt>border=padding</dt> <dd><p class="first last">padding is a list of up to four integers, specifying the left, top, right, and bottom borders, respectively.</p> </dd> </dl> </li> <li><dl class="first docutils"> <dt>height=height</dt> <dd><p class="first last">Specifies a minimum height for the element. If less than zero, the base image’s height is used as a default.</p> </dd> </dl> </li> <li><dl class="first docutils"> <dt>padding=padding</dt> <dd><p class="first last">Specifies the element’s interior padding. Defaults to border’s value if not specified.</p> </dd> </dl> </li> <li><dl class="first docutils"> <dt>sticky=spec</dt> <dd><p class="first last">Specifies how the image is placed within the final parcel. spec contains zero or more characters “n”, “s”, “w”, or “e”.</p> </dd> </dl> </li> <li><dl class="first docutils"> <dt>width=width</dt> <dd><p class="first last">Specifies a minimum width for the element. If less than zero, the base image’s width is used as a default.</p> </dd> </dl> </li> </ul> </div></blockquote> <p>If “from” is used as the value of <em>etype</em>, <a class="reference internal" href="#ttk.Style.element_create" title="ttk.Style.element_create"><tt class="xref py py-meth docutils literal"><span class="pre">element_create()</span></tt></a> will clone an existing element. <em>args</em> is expected to contain a themename, from which the element will be cloned, and optionally an element to clone from. If this element to clone from is not specified, an empty element will be used. <em>kw</em> is discarded.</p> </dd></dl> <dl class="method"> <dt id="ttk.Style.element_names"> <tt class="descname">element_names</tt><big>(</big><big>)</big><a class="headerlink" href="#ttk.Style.element_names" title="Permalink to this definition">¶</a></dt> <dd><p>Returns the list of elements defined in the current theme.</p> </dd></dl> <dl class="method"> <dt id="ttk.Style.element_options"> <tt class="descname">element_options</tt><big>(</big><em>elementname</em><big>)</big><a class="headerlink" href="#ttk.Style.element_options" title="Permalink to this definition">¶</a></dt> <dd><p>Returns the list of <em>elementname</em>‘s options.</p> </dd></dl> <dl class="method"> <dt id="ttk.Style.theme_create"> <tt class="descname">theme_create</tt><big>(</big><em>themename</em>, <em>parent=None</em>, <em>settings=None</em><big>)</big><a class="headerlink" href="#ttk.Style.theme_create" title="Permalink to this definition">¶</a></dt> <dd><p>Create a new theme.</p> <p>It is an error if <em>themename</em> already exists. If <em>parent</em> is specified, the new theme will inherit styles, elements and layouts from the parent theme. If <em>settings</em> are present they are expected to have the same syntax used for <a class="reference internal" href="#ttk.Style.theme_settings" title="ttk.Style.theme_settings"><tt class="xref py py-meth docutils literal"><span class="pre">theme_settings()</span></tt></a>.</p> </dd></dl> <dl class="method"> <dt id="ttk.Style.theme_settings"> <tt class="descname">theme_settings</tt><big>(</big><em>themename</em>, <em>settings</em><big>)</big><a class="headerlink" href="#ttk.Style.theme_settings" title="Permalink to this definition">¶</a></dt> <dd><p>Temporarily sets the current theme to <em>themename</em>, apply specified <em>settings</em> and then restore the previous theme.</p> <p>Each key in <em>settings</em> is a style and each value may contain the keys ‘configure’, ‘map’, ‘layout’ and ‘element create’ and they are expected to have the same format as specified by the methods <a class="reference internal" href="#ttk.Style.configure" title="ttk.Style.configure"><tt class="xref py py-meth docutils literal"><span class="pre">Style.configure()</span></tt></a>, <a class="reference internal" href="#ttk.Style.map" title="ttk.Style.map"><tt class="xref py py-meth docutils literal"><span class="pre">Style.map()</span></tt></a>, <a class="reference internal" href="#ttk.Style.layout" title="ttk.Style.layout"><tt class="xref py py-meth docutils literal"><span class="pre">Style.layout()</span></tt></a> and <a class="reference internal" href="#ttk.Style.element_create" title="ttk.Style.element_create"><tt class="xref py py-meth docutils literal"><span class="pre">Style.element_create()</span></tt></a> respectively.</p> <p>As an example, let’s change the Combobox for the default theme a bit:</p> <div class="highlight-python"><div class="highlight"><pre><span class="kn">import</span> <span class="nn">ttk</span> <span class="kn">import</span> <span class="nn">Tkinter</span> <span class="n">root</span> <span class="o">=</span> <span class="n">Tkinter</span><span class="o">.</span><span class="n">Tk</span><span class="p">()</span> <span class="n">style</span> <span class="o">=</span> <span class="n">ttk</span><span class="o">.</span><span class="n">Style</span><span class="p">()</span> <span class="n">style</span><span class="o">.</span><span class="n">theme_settings</span><span class="p">(</span><span class="s">"default"</span><span class="p">,</span> <span class="p">{</span> <span class="s">"TCombobox"</span><span class="p">:</span> <span class="p">{</span> <span class="s">"configure"</span><span class="p">:</span> <span class="p">{</span><span class="s">"padding"</span><span class="p">:</span> <span class="mi">5</span><span class="p">},</span> <span class="s">"map"</span><span class="p">:</span> <span class="p">{</span> <span class="s">"background"</span><span class="p">:</span> <span class="p">[(</span><span class="s">"active"</span><span class="p">,</span> <span class="s">"green2"</span><span class="p">),</span> <span class="p">(</span><span class="s">"!disabled"</span><span class="p">,</span> <span class="s">"green4"</span><span class="p">)],</span> <span class="s">"fieldbackground"</span><span class="p">:</span> <span class="p">[(</span><span class="s">"!disabled"</span><span class="p">,</span> <span class="s">"green3"</span><span class="p">)],</span> <span class="s">"foreground"</span><span class="p">:</span> <span class="p">[(</span><span class="s">"focus"</span><span class="p">,</span> <span class="s">"OliveDrab1"</span><span class="p">),</span> <span class="p">(</span><span class="s">"!disabled"</span><span class="p">,</span> <span class="s">"OliveDrab2"</span><span class="p">)]</span> <span class="p">}</span> <span class="p">}</span> <span class="p">})</span> <span class="n">combo</span> <span class="o">=</span> <span class="n">ttk</span><span class="o">.</span><span class="n">Combobox</span><span class="p">()</span><span class="o">.</span><span class="n">pack</span><span class="p">()</span> <span class="n">root</span><span class="o">.</span><span class="n">mainloop</span><span class="p">()</span> </pre></div> </div> </dd></dl> <dl class="method"> <dt id="ttk.Style.theme_names"> <tt class="descname">theme_names</tt><big>(</big><big>)</big><a class="headerlink" href="#ttk.Style.theme_names" title="Permalink to this definition">¶</a></dt> <dd><p>Returns a list of all known themes.</p> </dd></dl> <dl class="method"> <dt id="ttk.Style.theme_use"> <tt class="descname">theme_use</tt><big>(</big><span class="optional">[</span><em>themename</em><span class="optional">]</span><big>)</big><a class="headerlink" href="#ttk.Style.theme_use" title="Permalink to this definition">¶</a></dt> <dd><p>If <em>themename</em> is not given, returns the theme in use. Otherwise, sets the current theme to <em>themename</em>, refreshes all widgets and emits a <<ThemeChanged>> event.</p> </dd></dl> </dd></dl> <div class="section" id="layouts"> <h3>24.2.10.1. Layouts<a class="headerlink" href="#layouts" title="Permalink to this headline">¶</a></h3> <p>A layout can be just None, if it takes no options, or a dict of options specifying how to arrange the element. The layout mechanism uses a simplified version of the pack geometry manager: given an initial cavity, each element is allocated a parcel. Valid options/values are:</p> <blockquote> <div><ul> <li><dl class="first docutils"> <dt>side: whichside</dt> <dd><p class="first last">Specifies which side of the cavity to place the element; one of top, right, bottom or left. If omitted, the element occupies the entire cavity.</p> </dd> </dl> </li> <li><dl class="first docutils"> <dt>sticky: nswe</dt> <dd><p class="first last">Specifies where the element is placed inside its allocated parcel.</p> </dd> </dl> </li> <li><dl class="first docutils"> <dt>unit: 0 or 1</dt> <dd><p class="first last">If set to 1, causes the element and all of its descendants to be treated as a single element for the purposes of <a class="reference internal" href="#ttk.Widget.identify" title="ttk.Widget.identify"><tt class="xref py py-meth docutils literal"><span class="pre">Widget.identify()</span></tt></a> et al. It’s used for things like scrollbar thumbs with grips.</p> </dd> </dl> </li> <li><dl class="first docutils"> <dt>children: [sublayout... ]</dt> <dd><p class="first last">Specifies a list of elements to place inside the element. Each element is a tuple (or other sequence type) where the first item is the layout name, and the other is a <a class="reference internal" href="#layouts">Layout</a>.</p> </dd> </dl> </li> </ul> </div></blockquote> </div> </div> </div> </div> </div> </div> <div class="sphinxsidebar"> <div class="sphinxsidebarwrapper"> <h3><a href="../contents.html">Table Of Contents</a></h3> <ul> <li><a class="reference internal" href="#">24.2. <tt class="docutils literal"><span class="pre">ttk</span></tt> — Tk themed widgets</a><ul> <li><a class="reference internal" href="#using-ttk">24.2.1. Using Ttk</a></li> <li><a class="reference internal" href="#ttk-widgets">24.2.2. Ttk Widgets</a></li> <li><a class="reference internal" href="#widget">24.2.3. Widget</a><ul> <li><a class="reference internal" href="#standard-options">24.2.3.1. Standard Options</a></li> <li><a class="reference internal" href="#scrollable-widget-options">24.2.3.2. Scrollable Widget Options</a></li> <li><a class="reference internal" href="#label-options">24.2.3.3. Label Options</a></li> <li><a class="reference internal" href="#compatibility-options">24.2.3.4. Compatibility Options</a></li> <li><a class="reference internal" href="#widget-states">24.2.3.5. Widget States</a></li> <li><a class="reference internal" href="#ttk-widget">24.2.3.6. ttk.Widget</a></li> </ul> </li> <li><a class="reference internal" href="#combobox">24.2.4. Combobox</a><ul> <li><a class="reference internal" href="#options">24.2.4.1. Options</a></li> <li><a class="reference internal" href="#virtual-events">24.2.4.2. Virtual events</a></li> <li><a class="reference internal" href="#ttk-combobox">24.2.4.3. ttk.Combobox</a></li> </ul> </li> <li><a class="reference internal" href="#notebook">24.2.5. Notebook</a><ul> <li><a class="reference internal" href="#id1">24.2.5.1. Options</a></li> <li><a class="reference internal" href="#tab-options">24.2.5.2. Tab Options</a></li> <li><a class="reference internal" href="#tab-identifiers">24.2.5.3. Tab Identifiers</a></li> <li><a class="reference internal" href="#id2">24.2.5.4. Virtual Events</a></li> <li><a class="reference internal" href="#ttk-notebook">24.2.5.5. ttk.Notebook</a></li> </ul> </li> <li><a class="reference internal" href="#progressbar">24.2.6. Progressbar</a><ul> <li><a class="reference internal" href="#id3">24.2.6.1. Options</a></li> <li><a class="reference internal" href="#ttk-progressbar">24.2.6.2. ttk.Progressbar</a></li> </ul> </li> <li><a class="reference internal" href="#separator">24.2.7. Separator</a><ul> <li><a class="reference internal" href="#id4">24.2.7.1. Options</a></li> </ul> </li> <li><a class="reference internal" href="#sizegrip">24.2.8. Sizegrip</a><ul> <li><a class="reference internal" href="#platform-specific-notes">24.2.8.1. Platform-specific notes</a></li> <li><a class="reference internal" href="#bugs">24.2.8.2. Bugs</a></li> </ul> </li> <li><a class="reference internal" href="#treeview">24.2.9. Treeview</a><ul> <li><a class="reference internal" href="#id5">24.2.9.1. Options</a></li> <li><a class="reference internal" href="#item-options">24.2.9.2. Item Options</a></li> <li><a class="reference internal" href="#tag-options">24.2.9.3. Tag Options</a></li> <li><a class="reference internal" href="#column-identifiers">24.2.9.4. Column Identifiers</a></li> <li><a class="reference internal" href="#id6">24.2.9.5. Virtual Events</a></li> <li><a class="reference internal" href="#ttk-treeview">24.2.9.6. ttk.Treeview</a></li> </ul> </li> <li><a class="reference internal" href="#ttk-styling">24.2.10. Ttk Styling</a><ul> <li><a class="reference internal" href="#layouts">24.2.10.1. Layouts</a></li> </ul> </li> </ul> </li> </ul> <h4>Previous topic</h4> <p class="topless"><a href="tkinter.html" title="previous chapter">24.1. <tt class="docutils literal"><span class="pre">Tkinter</span></tt> — Python interface to Tcl/Tk</a></p> <h4>Next topic</h4> <p class="topless"><a href="tix.html" title="next chapter">24.3. <tt class="docutils literal"><span class="pre">Tix</span></tt> — Extension widgets for Tk</a></p> <h3>This Page</h3> <ul class="this-page-menu"> <li><a href="../bugs.html">Report a Bug</a></li> <li><a href="../_sources/library/ttk.txt" rel="nofollow">Show Source</a></li> </ul> <div id="searchbox" style="display: none"> <h3>Quick search</h3> <form class="search" action="../search.html" method="get"> <input type="text" name="q" /> <input type="submit" value="Go" /> <input type="hidden" name="check_keywords" value="yes" /> <input type="hidden" name="area" value="default" /> </form> <p class="searchtip" style="font-size: 90%"> Enter search terms or a module, class or function name. </p> </div> <script type="text/javascript">$('#searchbox').show(0);</script> </div> </div> <div class="clearer"></div> </div> <div class="related"> <h3>Navigation</h3> <ul> <li class="right" style="margin-right: 10px"> <a href="../genindex.html" title="General Index" >index</a></li> <li class="right" > <a href="../py-modindex.html" title="Python Module Index" >modules</a> |</li> <li class="right" > <a href="tix.html" title="24.3. Tix — Extension widgets for Tk" >next</a> |</li> <li class="right" > <a href="tkinter.html" title="24.1. Tkinter — Python interface to Tcl/Tk" >previous</a> |</li> <li><img src="../_static/py.png" alt="" style="vertical-align: middle; margin-top: -1px"/></li> <li><a href="http://www.python.org/">Python</a> »</li> <li> <a href="../index.html">Python 2.7.5 documentation</a> » </li> <li><a href="index.html" >The Python Standard Library</a> »</li> <li><a href="tk.html" >24. Graphical User Interfaces with Tk</a> »</li> </ul> </div> <div class="footer"> © <a href="../copyright.html">Copyright</a> 1990-2019, Python Software Foundation. <br /> The Python Software Foundation is a non-profit corporation. <a href="http://www.python.org/psf/donations/">Please donate.</a> <br /> Last updated on Jul 03, 2019. <a href="../bugs.html">Found a bug</a>? <br /> Created using <a href="http://sphinx.pocoo.org/">Sphinx</a> 1.1.3. </div> </body> </html>
Close