阙辉

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()

 

posted on 2018-06-22 11:36  真辉辉  阅读(182)  评论(0)    收藏  举报

导航