📄 033-movinggraph.py
字号:
import appuifw, graphics, e32, key_codesBLACK = (0, 0, 0)WHITE = (255, 255, 255)key_down = Noneclicked = Nonedef handle_event(event): global clicked, key_down if event['type'] == appuifw.EEventKey: if key_down: key_down = (event['keycode'], "down") else: key_down = (event['keycode'], "pressed") elif event['type'] == appuifw.EEventKeyUp and key_down: code, mode = key_down if mode == "pressed": clicked = code key_down = Nonedef key_is_down(code): if key_down and key_down == (code, "down"): return True return Falsedef quit(): global running running = Falsedef handle_redraw(rect): if img: canvas.blit(img)img = Nonecanvas = appuifw.Canvas(event_callback=handle_event, redraw_callback=handle_redraw)appuifw.app.screen = 'full'appuifw.app.body = canvasappuifw.app.exit_key_handler = quitx = y = 100w, h = canvas.sizeimg = graphics.Image.new((w, h))img.clear(WHITE)running = Truewhile running: if key_is_down(key_codes.EKeyLeftArrow): x -= 5 elif key_is_down(key_codes.EKeyRightArrow): x += 5 elif key_is_down(key_codes.EKeyDownArrow): y += 5 elif key_is_down(key_codes.EKeyUpArrow): y -= 5 #img.clear(WHITE) img.point((x, y), outline = BLACK, width = 50) handle_redraw(None) e32.ao_yield()
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -