调整 Python 中 ttk 按钮高度
Ttk 为 tkinter 的标准组件添加样式,可以通过不同的属性和函数对其进行配置。我们可以使用 grid(options) 方法更改 ttk 按钮的高度。此方法包含一些具有不同选项的各种属性。如果我们想要调整 ttk 按钮大小,我们可以指定内部填充值,如 ipadx 和 ipady。
实例
让我们通过一个示例来理解它:
#Import tkinter library
from tkinter import *
from tkinter import ttk
#Create an instance of tkinter frame or window
win = Tk()
#Set the geometry of tkinter frame
win.geometry("750x250")
#Create a button using the ttk themed widget
button = ttk.Button(win, text = "Button")
button.grid(ipadx=10, ipady=30 )
win.mainloop()输出
在上面的代码中,我们已向按钮组件添加了内部填充。现在,运行程序以显示输出:

广告
数据结构
网络
RDBMS
操作系统
Java
iOS
HTML
CSS
Android
Python
C 编程
C++
C#
MongoDB
MySQL
Javascript
PHP