IIPP Week 5 - Mouse input, list methods, dictionaries

Week 5a - Mouse Input and More Lists

Mouse Input

def click_handler(pos)
frame.set_mouseclick_handler(click_handler)

List Methods

  • in
  • index
  • append
  • pop, remove("a") != pop(list.index("a")) 前者不返回值,后者返回值

Iteration

Tips: We cannot change the value when iterating

for can be used to change the value or screen value

  • return x ** 2 for x in range(0, 5)
  • [return x ** 2 for x in range(0, 5)]
  • return x for x in range(0, 10) if x % 2 == 0

Week 5b - Dictionaries and Images

Dictionary

dic = {} is same as dic = dict()

Key

We just can use hashable type like tuples, booleans, numbers, strings , class as the key of dictionary

But what is hashable?

The value can be any type

Iterate
  • for key in dic
  • for value in dic.value()
  • for key, value in dic.item()

Image

canvas.draw_image(image, center_source, width_height_source, center_dest, width_height_dest)

  • draw_image()
  • simplegui.load_image
  • get.width()
  • get.height()

Change Label

label1 = frame.add_label("haha")
label1.set_text("hehe")
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值