<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                合規國際互聯網加速 OSASE為企業客戶提供高速穩定SD-WAN國際加速解決方案。 廣告
                # Tkinter 復選框 > 原文: [https://pythonbasics.org/tkinter_checkbox/](https://pythonbasics.org/tkinter_checkbox/) 復選框小部件非常明顯,您根本無需考慮它們。 它們就像開/關開關,您可以有多個開關。 它是 Tkinter 中包含的小部件之一。 如果您希望單擊零個或多個選項,則可以使用一個復選框。 否則,您將使用單選按鈕或其他類型的按鈕。 ## 復選框 ### Tkinter 復選框 Tkinter 復選框小部件是一個非常基本的開關。 Tkinter 中的復選框稱為`CheckButton`。 您可以添加兩個復選框,如下所示: ```py c1 = tk.Checkbutton(window, text='Python',variable=var1, onvalue=1, offvalue=0, command=print_selection) c1.pack() c2 = tk.Checkbutton(window, text='C++',variable=var2, onvalue=1, offvalue=0, command=print_selection) c2.pack() ``` ### 示例 下面的程序在窗口中添加了幾個檢查按鈕。 如果單擊復選框,則上面的文本會更改。 ```py #!/usr/bin/env python # -*- coding: utf-8 -*- import tkinter as tk window = tk.Tk() window.title('My Window') window.geometry('100x100') l = tk.Label(window, bg='white', width=20, text='empty') l.pack() def print_selection(): if (var1.get() == 1) & (var2.get() == 0): l.config(text='I love Python ') elif (var1.get() == 0) & (var2.get() == 1): l.config(text='I love C++') elif (var1.get() == 0) & (var2.get() == 0): l.config(text='I do not anything') else: l.config(text='I love both') var1 = tk.IntVar() var2 = tk.IntVar() c1 = tk.Checkbutton(window, text='Python',variable=var1, onvalue=1, offvalue=0, command=print_selection) c1.pack() c2 = tk.Checkbutton(window, text='C++',variable=var2, onvalue=1, offvalue=0, command=print_selection) c2.pack() window.mainloop() ``` ![tkinter checkbox](https://img.kancloud.cn/29/05/2905cee6c439664fb980b8243c73f484_221x165.jpg) [下載 Tkinter 示例](https://gum.co/ErLc)
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看