<p style="margin-top:0px; margin-bottom:1.1em; color:rgb(54,46,43); font-family:'microsoft yahei'; font-size:14.44444465637207px; line-height:25.98958396911621px"> </p>
<p style="margin-top:0px; margin-bottom:1.1em; color:rgb(54,46,43); font-family:'microsoft yahei'; font-size:14.44444465637207px; line-height:25.98958396911621px"> tkinter是Python中可用于构建GUI的众多工具集之一。</p>
<h1 id="tkinter模块" style="margin:0.8em 0px; padding:0px; font-weight:100; color:rgb(54,46,43); font-family:'microsoft yahei'; line-height:25.98958396911621px"> <a name="t0" style="color:rgb(106,57,6)" target="_blank"></a>tkinter模块</h1>
<pre class="blockcode" name="code" style="white-space: nowrap; word-wrap: break-word; box-sizing: border-box; margin-top: 0px; margin-bottom: 1.1em; font-family: 'Source Code Pro', monospace; padding: 5px 5px 5px 60px; font-size: 14.44444465637207px; line-height: 1.45; word-break: break-all; color: rgb(51, 51, 51); background-color: rgba(128, 128, 128, 0.0470588); border: 1px solid rgba(128, 128, 128, 0.0745098); border-top-left-radius: 0px; border-top-right-radius: 0px; border-bottom-right-radius: 0px; border-bottom-left-radius: 0px; position: relative; overflow-y: hidden; overflow-x: auto;"><code class="hljs coffeescript has-numbering" style="display: block; padding: 0px; background-color: transparent; color: inherit; box-sizing: border-box; font-family: 'Source Code Pro', monospace;font-size:undefined; white-space: pre; border-top-left-radius: 0px; border-top-right-radius: 0px; border-bottom-right-radius: 0px; border-bottom-left-radius: 0px; word-wrap: normal; background-position: initial initial; background-repeat: initial initial;"><span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;"># 可以使用import tkinter as tk并通过tk.thing去引用其中的内容</span>
from tkinter <span class="hljs-reserved" style="box-sizing: border-box;">import</span> *
<span class="hljs-built_in" style="color: rgb(102, 0, 102); box-sizing: border-box;">window</span> = Tk()
<span class="hljs-built_in" style="color: rgb(102, 0, 102); box-sizing: border-box;">window</span>.mainloop()</code><ul class="pre-numbering" style="box-sizing: border-box; position: absolute; width: 50px; background-color: rgb(238, 238, 238); top: 0px; left: 0px; margin: 0px; padding: 6px 0px 40px; border-right-width: 1px; border-right-style: solid; border-right-color: rgb(221, 221, 221); list-style: none; text-align: right;"><li style="box-sizing: border-box; padding: 0px 5px;">1</li><li style="box-sizing: border-box; padding: 0px 5px;">2</li><li style="box-sizing: border-box; padding: 0px 5px;">3</li><li style="box-sizing: border-box; padding: 0px 5px;">4</li><li style="box-sizing: border-box; padding: 0px 5px;">5</li></ul></pre>
<p style="margin-top:0px; margin-bottom:1.1em; color:rgb(54,46,43); font-family:'microsoft yahei'; font-size:14.44444465637207px; line-height:25.98958396911621px"> 以上代码可以显示一个空白的根窗口。可以将其看成是应用程序的最外层容器,创建其他插件(widget)的时候就需要用到它。如果关闭屏幕上的窗口,则相应的窗口对象就会被销毁。所有的应用程序都只有一个主窗口;此外,还可以通过TopLevel这个小插件来创建额外的窗口。</p>
<p style="margin-top:0px; margin-bottom:1.1em; color:rgb(54,46,43); font-family:'microsoft yahei'; font-size:14.44444465637207px; line-height:25.98958396911621px"> <span style="">tkinter小插件</span>包括Button, Canvas, Checkbutton, Entry, Frame, Label, Listbox, Menu, Message, Menubutton, Text, TopLevel等。</p>
<h2 id="可变的变量" style="margin:0.8em 0px; padding:0px; font-weight:100; color:rgb(54,46,43); font-family:'microsoft yahei'; line-height:25.98958396911621px"> <a name="t1" style="color:rgb(106,57,6)" target="_blank"></a>可变的变量</h2>
<p style="margin-top:0px; margin-bottom:1.1em; color:rgb(54,46,43); font-family:'microsoft yahei'; font-size:14.44444465637207px; line-height:25.98958396911621px"> 在Python中字符串、整数、浮点数以及布尔值都是不可变的,于是tkinter自带了一些类型;他们可以就地更新,并可以在其值发生变化时通知相关的插件。</p>
<p style="margin-top:0px; margin-bottom:1.1em; color:rgb(54,46,43); font-family:'microsoft yahei'; font-size:14.44444465637207px; line-height:25.98958396911621px"> <span style="">tkinter中的可变类型</span></p>
<table style="width:700px; border-collapse:collapse; border-spacing:0px; border:1px solid rgb(238,238,238); color:rgb(54,46,43); font-family:'microsoft yahei'; font-size:14.44444465637207px; line-height:25.98958396911621px"><thead style=""><tr style=""><th style="padding:8px; line-height:20px; vertical-align:top; border:1px solid rgb(238,238,238)"> 不可变类型</th><th style="padding:8px; line-height:20px; vertical-align:top; border:1px solid rgb(238,238,238)"> 可变类型</th></tr></thead><tbody style=""><tr style=""><td style="padding:8px; line-height:20px; vertical-align:top; bord |
|