2.3、Button 显示文本与图像
# compound:指定文本与图像位置关系
# bitmap:指定位图
from Tkinter import *
root = Tk()
#图像居下,居上,居右,居左,文字位于图像之上
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()
#消息循环
root.mainloop()
代码
from tkinter import *
quehui = Tk()
Button(quehui,
text = 'quehui_1',
compound = 'bottom',
bitmap = 'error'
).pack()
Button(quehui,
text ='quehui_2',
compound = 'top',
bitmap = 'error'
).pack()
Button(quehui,
text = 'quehui_3',
compound = 'right',
bitmap = 'error'
).pack()
Button(quehui,
text = 'quehui_4',
compound = 'left',
bitmap = 'error'
).pack()
Button(quehui,
text = 'quehui_5',
compound = 'center',
bitmap = 'error'
).pack()
quehui.mainloop()

浙公网安备 33010602011771号