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

How it works…

Our ListFrame class has only two methods to interact with the inner list: pop_selection() and insert_item(). The first one returns and deletes the current selection, or none if there is no item selected, whereas the second one inserts a new item at the end of the list.

These methods are used in the parent class to transfer an item from one list to the other one:

def move(self, frame_from, frame_to):
value = frame_from.pop_selection()
if value:
frame_to.insert_item(value)

We also took advantage of the parent frame containers to correctly pack them with the appropriate padding:

# ...
self.frame_a.pack(side=tk.LEFT, padx=10, pady=10)
self.frame_b.pack(side=tk.RIGHT, padx=10, pady=10)

Thanks to these frames, our calls to the geometry manager are more isolated and organized in our global layout.

主站蜘蛛池模板: 江孜县| 南城县| 五原县| 大同县| 清苑县| 秀山| 天柱县| 武宣县| 靖边县| 光泽县| 铁岭市| 临泽县| 武平县| 合作市| 西平县| 承德县| 平南县| 白山市| 塔河县| 明星| 社旗县| 屏边| 梧州市| 文水县| 大田县| 萨嘎县| 县级市| 灵武市| 乾安县| 青田县| 应城市| 普定县| 石棉县| 东宁县| 固始县| 安徽省| 邳州市| 松江区| 陈巴尔虎旗| 吕梁市| 泾川县|