# -*- coding: UTF-8 -*-
import tkinter as tk
from tkinter import *
from tkinter import messagebox
if __name__ == "__main__":
window = tk.Tk()
window.title('信息查询')
width = 680
height = 540
# 设置窗体固定最大值和最小值一样,设置窗体大小不可改变
window.maxsize(width,height)
window.minsize(width,height)
# 获取屏幕宽、
screen_width=window.winfo_screenwidth()
screen_height=window.winfo_screenheight()
# 居中获取宽、高
windowX= (screen_width-width)/2
windowY=(screen_height-height)/2
window.geometry("%dx%d+%d+%d"%(width,height,windowX,windowY))
label = tk.Label(window,text="查询姓名",width=40)
# 声明输入框
e = Entry(window)
# 单人查询
def showONE():
global gname
gname = e.get()
print("查询姓名:",gname)
messagebox.showinfo(title="查询提示1", message="查询名字是的%s!"%gname)
#初始化 按钮名称:以及绑定事件
buttonIns = tk.Button(window, text='单人查询', relief=tk.RAISED, command=showONE,bg="pink")
buttonDel = tk.Button(window, text='清空', relief=tk.RAISED, command="",bg="pink")
# x y:按钮横坐标、纵坐标 width、height:按钮宽、高
label.place(x=90,y=20,width=80, height=30)
e.place(x=160,y=20,width=80, height=30)
buttonIns.place(x=260, y=20, width=80, height=30)
buttonDel.place(x=460, y=20, width=80, height=30)
window.mainloop()
评论