Python tkinter编程之Button_5 设置Button的高度和宽度

# -*-coding:utf-8-*-
#Button的宽度与高度
'''
width:宽度
height:高度
'''
def show_b1():
    print('b1 press')
def show_b2():
    print('b2 press')
def show_b3():
    print('b3 press')
from tkinter import *
root = Tk()
#创建Button对象时,指定宽度与高度
b1 = Button(root, text = '30X1', width = 30, height = 2, command = show_b1)
b1.pack()
#使用属性width和height来指定宽度与高度
b2 = Button(root, text = '30X2')
b2['width'] = 30
b2['height'] = 3
b2['command'] = show_b2
b2.pack()
#使用configure方法来指定宽度与高度
b3 = Button(root, text = '30X3')
b3.configure(width = 30, height = 3, command = show_b3)
b3.pack()
root.mainloop()

 

你可能感兴趣的:(Python)