标签:print root int ext imp error err and pac
from tkinter import * root = Tk() #定义按钮的回调函数 def BackCallButton(): print("按钮回调函数") #通过command属性指定回调函数 Btn1 = Button(root, text = "Button", command = BackCallButton).pack() #显示Button的各个不同效果 #flat, groove, raised, ridge, solid, or sunken Button(root,text = ‘FLAT‘,relief=FLAT).pack() Button(root,text = ‘GROOVE‘,relief=GROOVE).pack() Button(root,text = ‘RAISED‘,relief=RAISED).pack() Button(root,text = ‘RIDGE‘,relief=RIDGE).pack() Button(root,text = ‘SOLID‘,relief=SOLID).pack() Button(root,text = ‘SUNKEN‘,relief=SUNKEN).pack() #与Label一样,Button也可以同时显示文本与图像,使用属性compound Button(root,text = ‘botton‘,compound = ‘bottom‘,bitmap = ‘error‘).pack() Button(root,text = ‘top‘,compound = ‘top‘,bitmap = ‘error‘).pack() Button(root,text = ‘right‘,compound = ‘right‘,bitmap = ‘error‘).pack() Button(root,text = ‘left‘,compound = ‘left‘,bitmap = ‘error‘).pack() Button(root,text = ‘center‘,compound = ‘center‘,bitmap = ‘error‘).pack() def printEventInfo(event): print (‘event.time = ‘ , event.time) print (‘event.type = ‘ , event.type) print (‘event.WidgetId = ‘, event.widget) print (‘event.KeySymbol = ‘,event.keysym) b = Button(root,text = ‘Infomation‘) #bind方法,建立事件与回调函数(响应函数)之间的关系 b.bind("<Return>",printEventInfo) b.pack() #focus_set设置控件焦点 b.focus_set() root.mainloop()
标签:print root int ext imp error err and pac
原文地址:http://www.cnblogs.com/moodsky/p/6030433.html