Computer >> Hướng Dẫn Máy Tính >  >> Lập Trình >> Python

Cách tăng cỡ chữ widget Text

Tùy chỉnh widget Tkinter bằng sửa thuộc tính: font-family, text-size, width, height frame. Text widget dùng nhập nhiều dòng. Tương tự text widget chuẩn.

Cấu hình text property bằng font('font-family font-size font-style') định nghĩa font-family, font-size, font style.

Ví dụ

#Import tkinter library
from tkinter import *
#Tạo instance Tkinter frame
win= Tk()
#Đặt geometry
win.geometry("750x250")
#Tạo Text widget
text= Text(win, width= 60, height= 10, font=('Century Schoolbook', 20, 'italic'))
text.insert(INSERT, "Hello\nWelcome to TutorialsPoint.com!")
text.pack()
win.mainloop()

Kết quả

Chạy mã hiển thị trình soạn thảo với font tùy chỉnh.

Cách tăng cỡ chữ widget Text

Thay đổi thuộc tính font để thấy thay đổi.