久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

<tfoot id='51pOJ'></tfoot>

<legend id='51pOJ'><style id='51pOJ'><dir id='51pOJ'><q id='51pOJ'></q></dir></style></legend>

      <bdo id='51pOJ'></bdo><ul id='51pOJ'></ul>
    <i id='51pOJ'><tr id='51pOJ'><dt id='51pOJ'><q id='51pOJ'><span id='51pOJ'><b id='51pOJ'><form id='51pOJ'><ins id='51pOJ'></ins><ul id='51pOJ'></ul><sub id='51pOJ'></sub></form><legend id='51pOJ'></legend><bdo id='51pOJ'><pre id='51pOJ'><center id='51pOJ'></center></pre></bdo></b><th id='51pOJ'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='51pOJ'><tfoot id='51pOJ'></tfoot><dl id='51pOJ'><fieldset id='51pOJ'></fieldset></dl></div>

    <small id='51pOJ'></small><noframes id='51pOJ'>

      1. 單擊按鈕并按回車時調用相同的函數

        Call the same function when clicking the Button and pressing enter(單擊按鈕并按回車時調用相同的函數)

              <tbody id='ZWxyx'></tbody>

            <small id='ZWxyx'></small><noframes id='ZWxyx'>

              <bdo id='ZWxyx'></bdo><ul id='ZWxyx'></ul>
            • <tfoot id='ZWxyx'></tfoot>

                <legend id='ZWxyx'><style id='ZWxyx'><dir id='ZWxyx'><q id='ZWxyx'></q></dir></style></legend>

                • <i id='ZWxyx'><tr id='ZWxyx'><dt id='ZWxyx'><q id='ZWxyx'><span id='ZWxyx'><b id='ZWxyx'><form id='ZWxyx'><ins id='ZWxyx'></ins><ul id='ZWxyx'></ul><sub id='ZWxyx'></sub></form><legend id='ZWxyx'></legend><bdo id='ZWxyx'><pre id='ZWxyx'><center id='ZWxyx'></center></pre></bdo></b><th id='ZWxyx'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='ZWxyx'><tfoot id='ZWxyx'></tfoot><dl id='ZWxyx'><fieldset id='ZWxyx'></fieldset></dl></div>
                • 本文介紹了單擊按鈕并按回車時調用相同的函數的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                  問題描述

                  我有一個具有 Entry 小部件和提交 Button 的 GUI.

                  I have a GUI that has Entry widget and a submit Button.

                  我基本上是在嘗試使用 get() 并打印 Entry 小部件內的值.我想通過單擊 submit Button 或按鍵盤上的 enterreturn 來執行此操作.

                  I am basically trying to use get() and print the values that are inside the Entry widget. I wanted to do this by clicking the submit Button or by pressing enter or return on keyboard.

                  我嘗試將 "<Return>" 事件與我按下提交按鈕時調用的相同函數綁定:

                  I tried to bind the "<Return>" event with the same function that is called when I press the submit Button:

                  self.bind("<Return>", self.enterSubmit)
                  

                  但我得到一個錯誤:

                  需要 2 個參數

                  但是 self.enterSubmit 函數只接受一個,因為 Buttoncommand 選項只需要一個.

                  But self.enterSubmit function only accepts one, since for the command option of the Button is required just one.

                  為了解決這個問題,我嘗試創建 2 個功能相同的函數,它們只是具有不同數量的參數.

                  To solve this, I tried to create 2 functions with identical functionalities, they just have different number of arguments.

                  有沒有更有效的方法來解決這個問題?

                  Is there a more efficient way of solving this?

                  推薦答案

                  您可以創建一個接受任意數量參數的函數,如下所示:

                  You can create a function that takes any number of arguments like this:

                  def clickOrEnterSubmit(self, *args):
                      #code goes here
                  

                  這稱為任意參數列表.調用者可以隨意傳入任意數量的參數,并且它們都將被打包到 args 元組中.Enter 綁定可以傳入它的 1 個 event 對象,而 click 命令可以不傳入任何參數.

                  This is called an arbitrary argument list. The caller is free to pass in as many arguments as they wish, and they will all be packed into the args tuple. The Enter binding may pass in its 1 event object, and the click command may pass in no arguments.

                  這是一個最小的 Tkinter 示例:

                  Here is a minimal Tkinter example:

                  from tkinter import *
                  
                  def on_click(*args):
                      print("frob called with {} arguments".format(len(args)))
                  
                  root = Tk()
                  root.bind("<Return>", on_click)
                  b = Button(root, text="Click Me", command=on_click)
                  b.pack()
                  root.mainloop()
                  

                  結果,按Enter并點擊按鈕后:

                  Result, after pressing Enter and clicking the button:

                  frob called with 1 arguments
                  frob called with 0 arguments
                  

                  如果您不愿意更改回調函數的簽名,可以將要綁定的函數包裝在 lambda 表達式中,并丟棄未使用的變量:

                  If you're unwilling to change the signature of the callback function, you can wrap the function you want to bind in a lambda expression, and discard the unused variable:

                  from tkinter import *
                  
                  def on_click():
                      print("on_click was called!")
                  
                  root = Tk()
                  
                  # The callback will pass in the Event variable, 
                  # but we won't send it to `on_click`
                  root.bind("<Return>", lambda event: on_click())
                  b = Button(root, text="Click Me", command=frob)
                  b.pack()
                  
                  root.mainloop()
                  

                  這篇關于單擊按鈕并按回車時調用相同的函數的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

                  【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

                  相關文檔推薦

                  How to make a discord bot that gives roles in Python?(如何制作一個在 Python 中提供角色的不和諧機器人?)
                  Discord bot isn#39;t responding to commands(Discord 機器人沒有響應命令)
                  Can you Get the quot;About mequot; feature on Discord bot#39;s? (Discord.py)(你能得到“關于我嗎?Discord 機器人的功能?(不和諧.py))
                  message.channel.id Discord PY(message.channel.id Discord PY)
                  How do I host my discord.py bot on heroku?(如何在 heroku 上托管我的 discord.py 機器人?)
                  discord.py - Automaticaly Change an Role Color(discord.py - 自動更改角色顏色)
                • <small id='r0FXr'></small><noframes id='r0FXr'>

                    <tbody id='r0FXr'></tbody>
                    <bdo id='r0FXr'></bdo><ul id='r0FXr'></ul>

                    • <tfoot id='r0FXr'></tfoot>
                      <legend id='r0FXr'><style id='r0FXr'><dir id='r0FXr'><q id='r0FXr'></q></dir></style></legend>

                          1. <i id='r0FXr'><tr id='r0FXr'><dt id='r0FXr'><q id='r0FXr'><span id='r0FXr'><b id='r0FXr'><form id='r0FXr'><ins id='r0FXr'></ins><ul id='r0FXr'></ul><sub id='r0FXr'></sub></form><legend id='r0FXr'></legend><bdo id='r0FXr'><pre id='r0FXr'><center id='r0FXr'></center></pre></bdo></b><th id='r0FXr'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='r0FXr'><tfoot id='r0FXr'></tfoot><dl id='r0FXr'><fieldset id='r0FXr'></fieldset></dl></div>
                            主站蜘蛛池模板: 天天曰夜夜操 | 国产美女永久免费无遮挡 | 亚洲一区亚洲二区 | 99精品视频一区二区三区 | 午夜电影福利 | 精久久久久 | a看片 | 久久久久国产一区二区三区 | 亚洲香蕉 | 一区二区三区四区不卡视频 | 婷婷色国产偷v国产偷v小说 | a级片www| 国产精品成人品 | 中文字幕中文字幕 | 日韩视频一区 | 一区二区在线不卡 | 久久久久亚洲精品国产 | 一区中文字幕 | 欧美亚洲另类在线 | 午夜电影网 | 欧美性久久 | 成人免费视频网站在线看 | 久久久久黄 | 久久亚洲欧美日韩精品专区 | 一级在线观看 | 欧美久久久久久久久中文字幕 | 亚洲国产18| 亚洲高清在线观看 | 国产欧美日韩在线播放 | 日韩欧美一区二区三区免费观看 | 久久精品毛片 | 中文字幕亚洲一区二区三区 | 91一区| 精品国产成人 | 天天操操 | 一级亚洲| 台湾av在线| 在线观看成人免费视频 | 欧美乱淫视频 | 国产成人a亚洲精品 | av大片|