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

How it works...

The first lines of our application constructor instantiate StringVar and attach a callback to the write mode. The valid mode values are as follows:

  • "w": Called when the variable is written
  • "r": Called when the variable is read
  • "u" (for unset): Called when the variable is deleted

When invoked, the callback function receives three arguments: the internal variable name, an empty string (it is used in other types of Tk variables), and the mode that triggered the operation. By declaring the method with *args, we make these arguments optional, because we are not using any of these values within the callback.

The get() method of Tk wrappers returns the current value of the variable, and the set() method updates its value. They also notify the corresponding observers, so both modifying the entry's content through the GUI or clicking on the Clear button will trigger the call to the show_message() method.

主站蜘蛛池模板: 延长县| 南康市| 虞城县| 永兴县| 南京市| 林州市| 新巴尔虎左旗| 本溪| 十堰市| 惠东县| 师宗县| 临沂市| 法库县| 友谊县| 宿迁市| 辽源市| 峨边| 镇江市| 镇康县| 库尔勒市| 武义县| 那曲县| 齐齐哈尔市| 嘉善县| 连云港市| 防城港市| 尼勒克县| 金堂县| 双鸭山市| 美姑县| 武冈市| 南平市| 平湖市| 顺昌县| 玉环县| 汪清县| 蚌埠市| 仲巴县| 安塞县| 瓮安县| 乐陵市|