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

如何在 Tkinter 中添加占位符

How to add a placeholder in Tkinter(如何在 Tkinter 中添加占位符)
本文介紹了如何在 Tkinter 中添加占位符的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)吧!

問題描述

如何將占位符添加到 tkinter 中的條目?例如,我不相信它具有像 HTML 這樣的占位符功能.我發(fā)現(xiàn)要使文本在單擊時消失,您必須添加一個 onclick 事件,但是如何創(chuàng)建 onclick 事件以及如何制作文字出現(xiàn)在第一位?這是我正在使用的代碼.

How would I add a placeholder to an entry in tkinter? I don't believe it has a placeholder function like HTML for example. I figured out that to make the text disappear when you click it, you will have to add an onclick event, but how do I create the onclick event and how do you make the text appear in the first place? Here is the code I'm working with.

我想說"在此處輸入您的整數(shù)"

I would like it to say " Enter your integer here"

    vcmd = (self.register(self.onValidate), '%S')
    self.text = Entry(self, validate='key', vcmd=vcmd)
    self.text.pack()
       
def onValidate(self, S):
    if S in '0123456789.':
        return True
    return False

def clear_entry(self):
    self.text.delete(0, END)
    self.text.pack()

推薦答案

據(jù)我所知,你不能像 HTML 一樣添加占位符,但你可以做出類似的行為.當(dāng)您進(jìn)入時,您可以執(zhí)行以下操作>

U can't add placeholder like HTML as far as i know, but u can make similar behavior. When you make entry you can do something like>

from tkinter import *   

def clear_entry(event, entry):
    entry.delete(0, END)

root = Tk()

entry = Entry(root)

entry.pack()
placeholder_text = 'some text'
entry.insert(0, placeholder_text)

entry.bind("<Button-1>", lambda event: clear_entry(event, entry))

root.mainloop()

P.S:這是我自己寫的,還沒有測試過

P.S: I've wrote this from my head , haven't tested it

這篇關(guān)于如何在 Tkinter 中添加占位符的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網(wǎng)!

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

相關(guān)文檔推薦

How to draw a rectangle around a region of interest in python(如何在python中的感興趣區(qū)域周圍繪制一個矩形)
How can I detect and track people using OpenCV?(如何使用 OpenCV 檢測和跟蹤人員?)
How to apply threshold within multiple rectangular bounding boxes in an image?(如何在圖像的多個矩形邊界框中應(yīng)用閾值?)
How can I download a specific part of Coco Dataset?(如何下載 Coco Dataset 的特定部分?)
Detect image orientation angle based on text direction(根據(jù)文本方向檢測圖像方向角度)
Detect centre and angle of rectangles in an image using Opencv(使用 Opencv 檢測圖像中矩形的中心和角度)
主站蜘蛛池模板: 亚洲国产精品99久久久久久久久 | 在线观看中文字幕一区二区 | 国产在线观看免费 | 午夜影视| 日韩视频在线播放 | 日韩欧美二区 | 中文字幕在线一区二区三区 | 国产999精品久久久久久 | 一级做a爰片性色毛片 | 欧美视频福利 | 久草.com| 超碰超碰| 午夜日韩| 91在线免费视频 | 婷婷开心激情综合五月天 | 一区二区三区欧美在线观看 | 18性欧美| 日韩在线欧美 | 国产成人精品一区二区三区视频 | 天天干天天色 | 国产日韩欧美综合 | 欧美亚洲国产一区二区三区 | 一区二区不卡视频 | 亚洲一级淫片 | 久久精品国产久精国产 | 国产亚洲精品久久午夜玫瑰园 | 免费久久网站 | 中文字幕在线看人 | 欧美6一10sex性hd | 免费午夜视频 | 国产欧美日韩综合精品一区二区 | 欧美国产日韩在线 | 国产精品资源在线 | 亚洲国产精品91 | 毛片com | 日本不卡一区二区三区 | 精品一区av | 91在线一区二区三区 | 日韩三区在线观看 | 91免费电影 | 欧美日韩在线一区二区三区 |