Tkinter禁止用户调整窗口尺寸大小
禁止用户调整窗口尺寸大小的方式:
root.resizable(False,False)
例子:
from tkinter import *
from tkinter import ttk
import csv
from tkinter import messagebox
root = Tk()
root.geometry('400x300')
root.wm_title('信息录入')
root.resizable(False,False)
Label(root,text='信息录入',font=('楷体',20),bg='gray',fg='white').pack()
ttk.Separator(root,orient='horizontal').pack(fill='x')
f = Frame(root)
f.pack()
Label(f,text='姓名').grid(row=0,column=0)
name = Entry(f)
name.grid(row=0,column=1)
Label(f,text='身份证号').grid(row=1,column=0)
uid = Entry(f)
uid.grid(row=1,column=1)
Label(f,text='职业').grid(row=2,column=0)
job = Entry(f)
job.grid(row=2,column=1)
Label(f,text='手机号').grid(row=3,column=0)
phone = Entry(f)
phone.grid(row=3,column=1)
Label(f,text='备注').grid(row=4,column=0)
description = Entry(f)
description.grid(row=4,column=1)
def tj():
name1 = name.get()
uid1 = uid.get()
job1 = job.get()
phone1 = phone.get()
description1 = description.get()
file = open(f'{name1}.csv',mode='w',encoding='utf-8')
csv_writer = csv.writer(file)
csv_writer.writerow([name1,uid1,job1,phone1,description1])
file.close()
messagebox.showinfo('提示','保存成功')
def close():
root.destroy()
ttk.Button(f,text='提交',command=tj).grid(row=5,column=0)
ttk.Button(f,text='关闭',command=close).grid(row=5,column=1)
root.mainloop()