首页 > 代码库 > Python Tkinter 基础控件学习
Python Tkinter 基础控件学习
# -*- coding: utf-8 -*- from Tkinter import * def btn_click(): b2[‘text‘] = ‘clicked‘ evalue = http://www.mamicode.com/e.get()"<Enter>", btn_click_bind) b2.pack() # 弹出Toplevel窗体 b3 = Button(root, text = ‘showToplevel‘, command=show_toplevel) b3.pack() # 输入框 e = Entry(root, text = ‘input your name‘) e.pack() # password框 epwd = Entry(root, text = ‘input your pwd‘, show = ‘*‘) epwd.pack() # 菜单 def menu_click(): print ‘I am menu‘ xmenu = Menu(root) submenu = Menu(xmenu, tearoff = 0) for item in [‘java‘, ‘cpp‘, ‘c‘, ‘php‘]: xmenu.add_command(label = item, command = menu_click) for item in [‘think in java‘, ‘java web‘, ‘android‘]: submenu.add_command(label = item, command = menu_click) xmenu.add_cascade(label = ‘progame‘, menu = submenu) # 弹出菜单 def pop(event): submenu.post(event.x_root, event.y_root) # 获取鼠标左键点击的坐标 def get_clickpoint(event): print event.x, event.y # frame for x in [‘red‘, ‘blue‘, ‘yellow‘]: Frame(height = 20, width = 20, bg = x).pack() root[‘menu‘] = xmenu root.bind(‘<Button-3>‘, pop) root.bind(‘<Button-1>‘, get_clickpoint) root.mainloop()
Python Tkinter 基础控件学习
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。