Computer >> บทช่วยสอนคอมพิวเตอร์ >  >> การเขียนโปรแกรม >> Python

วิธีทำให้หน้าต่าง Tkinter ไม่สามารถปรับขนาดได้


ภาพรวม

Tkinter สร้าง Resizable Window สำหรับทุกแอป สมมติต้องการ Non-resizable Window ใช้ resizable(height, width) ส่งค่า height=None และ width=None เมธอดนี้ทำงานได้ด้วย Boolean Values resizable(False, False)

ตัวอย่างโค้ด

# Import the required libraries
from tkinter import *
# Create an instance of tkinter frame
win = Tk()
# Set the geometry of frame
win.geometry("600x250")
# Set the resizable property False
win.resizable(False, False)
# Create a label for the window or frame
Label(win, text="Hello World!", font=('Helvetica bold', 20), anchor="center").pack(pady=20)
win.mainloop()

ผลลัพธ์

รันโค้ดจะแสดงหน้าต่าง Non-resizable

วิธีทำให้หน้าต่าง Tkinter ไม่สามารถปรับขนาดได้