首页上一页 1 下一页尾页 4 条记录 1/1页
Pygame按钮出不来
发表在Python图书答疑
2021-11-28 悬赏:1 学分
《Python项目开发案例集锦》第15章 智能停车场车牌识别计费系统 327页-329页
是否精华
是
否
版块置顶:
是
否
btn.py代码:
pygame Button(): (screencenterxywidthheightbutton_colortext_colormsgsize): .screen = screen .width.height = widthheight .button_color = button_color .text_color = text_color .font = pygame.font.SysFont(size) .rect = pygame.Rect(.width.height) .rect.centerx = centerxy[] - .width / + .rect.centery = centerxy[] - .height / + .deal_msg(msg) (msg): .msg_img = .font.render(msg.text_color.button_color) .msg_img_rect = .msg_img.get_rect() .msg_img_rect.center = .rect.center (): .screen.fill(.button_color.rect) .screen.blit(.msg_img.msg_img_rect)
main.py代码:
pygame pandas pandas pd
pygame.init() size = screen = pygame.display.set_mode(size) FPS = DARKBLUE = () BG = DARKBLUE icon = pygame.image.load() pygame.display.set_icon(icon) screen.fill(BG) clock = pygame.time.Clock() Running = pygame.display.set_caption() Running: btn_go = btn.Button(screen()BLUEWHITE) btn_go.draw_button() e pygame.event.get(): e.type == pygame.QUIT: pygame.quit() () e.type == pygame.MOUSEBUTTONDOWN: <= e.pos[] e.pos[] <= <= e.pos[] e.pos[] <= : () : carNumber = ocrutil.getCn() e: () ocrutil.messagebox.showerror((e)) img sucessimg = camara.read() : cv2.imwrite(img) cv2.error: os.remove() cv2.imwrite(img) image = pygame.image.load() image = pygame.transform.scale(image()) screen.blit(image()) pygame.display.flip() clock.tick(FPS)
颜色放在colors.py里面,代码:
WHITE = tuple([] * BLACK = tuple([] * GREEN = () BLUE = () GRAY = tuple([] * RED = () YELLOW = tuple([] * + [])
结果显示:
所以按钮去哪了?Pygame吞掉了?