- Tkinter GUI Application Development Cookbook
- Alejandro Rodas de Paz
- 139字
- 2021-08-27 19:44:00
There's more...
The content of an Entry widget can be modified programmatically with the insert() method, which takes two arguments:
- index: The position to insert the text; note that entry positions are 0-indexed
- string: The text to insert
A common pattern to reset the content of an entry with a default value can be achieved with a combination of delete() and insert():
entry.delete(0, tk.END) entry.insert(0, "default value")
Another pattern is to append the text in the current position of the text cursor. Here, you can use the INSERT constant instead of having to calculate the numerical index:
entry.insert(tk.INSERT, "cursor here")
Like the Button class, the Entry class also accepts the relief and state options to modify its border style and state. Keep in mind that calls to delete() and insert() are ignored when the state is "disabled" or "readonly".
推薦閱讀
- Python從入門到精通(精粹版)
- CKA/CKAD應試教程:從Docker到Kubernetes完全攻略
- Mastering Rust
- Node.js全程實例
- Processing創意編程指南
- 3ds Max印象 電視欄目包裝動畫與特效制作
- 遠方:兩位持續創業者的點滴思考
- 分布式架構原理與實踐
- H5+移動營銷設計寶典
- Deep Learning for Natural Language Processing
- Mastering Bootstrap 4
- Java Web開發基礎與案例教程
- Developing Java Applications with Spring and Spring Boot
- Node.js應用開發
- Professional JavaScript