Tkinter cho phép lập trình GUI. Cần biết kích thước màn hình (pixel và mm) và độ sâu màu (depth). Tkinter cung cấp các phương thức cho việc này.
Ví dụ
from tkinter import *
base = Tk()
# Kích thước pixel và mm
length_1 = base.winfo_screenheight()
width_1 = base.winfo_screenwidth()
length_2 = base.winfo_screenmmheight()
width_2 = base.winfo_screenmmwidth()
# Độ sâu màn hình
screendepth = base.winfo_screendepth()
print("\n width x length (in pixels) = ", (width_1, length_1))
print("\n width x length (in mm) = ", (width_2, length_2))
print("\n Screen depth = ", screendepth)
mainloop()
Kết quả (ví dụ):
width x length (in pixels) = (1600, 900) width x length (in mm) = (423, 238) Screen depth = 32