<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>

                ThinkChat2.0新版上線,更智能更精彩,支持會話、畫圖、視頻、閱讀、搜索等,送10W Token,即刻開啟你的AI之旅 廣告
                # Tkinter 按鈕 > 原文: [https://pythonbasics.org/tkinter-button/](https://pythonbasics.org/tkinter-button/) 按鈕是 GUI 中的標準小部件。 它們帶有默認的 Tkinter 模塊,您可以將它們放在窗口中。 Python 函數或方法可以與按鈕關聯。 該函數或方法稱為回調函數。 如果單擊該按鈕,則會調用回調函數。 關于按鈕的注釋:tkinter 按鈕只能顯示單一字體的文本。 按鈕文字可以是多行。 這意味著此小部件不會在文本旁邊顯示圖標,因為您需要另一個小部件。 ## 示例 ### 簡介 您可以使用以下幾行創建并放置按鈕: ```py exitButton = Button(self, text="Exit", command=self.clickExitButton) exitButton.place(x=0, y=0) ``` 回調方法是`clickExitButton`,該方法在上一行(`command =`)中分配。這是一種簡單的方法: ```py def clickExitButton(self): exit() ``` 如果沒有回調方法,則會顯示一個按鈕,但是單擊該按鈕不會執行任何操作。 該窗口應顯示: ![tkinter button](https://img.kancloud.cn/ee/8e/ee8ebd783995922c80568412e52c8b4a_628x434.jpg) ### 按鈕示例 要運行該示例,請將其另存為`button.py`并使用 python 解釋器運行它。 此示例打開一個窗口,顯示一個按鈕,您可以單擊該按鈕。 ```py from tkinter import * class Window(Frame): def __init__(self, master=None): Frame.__init__(self, master) self.master = master # widget can take all window self.pack(fill=BOTH, expand=1) # create button, link it to clickExitButton() exitButton = Button(self, text="Exit", command=self.clickExitButton) # place button at (0,0) exitButton.place(x=0, y=0) def clickExitButton(self): exit() root = Tk() app = Window(root) root.wm_title("Tkinter button") root.geometry("320x200") root.mainloop() ``` [下載 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>

                              哎呀哎呀视频在线观看