官术网_书友最值得收藏!

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

主站蜘蛛池模板: 呼伦贝尔市| 钟山县| 台东市| 香格里拉县| 金平| 玉田县| 麦盖提县| 吴忠市| 江源县| 峨边| 盐津县| 枣阳市| 漠河县| 山阳县| 云浮市| 稷山县| 雷州市| 琼海市| 仪征市| 仲巴县| 大余县| 石柱| 临湘市| 张北县| 三台县| 嘉义市| 南岸区| 承德市| 铁力市| 星子县| 梁河县| 长子县| 凉山| 彩票| 阜宁县| 九江县| 南平市| 江陵县| 洪湖市| 嵊泗县| 瑞昌市|