设计一个录入职工信息的程序界面,信息量包括ID(身份证)、name(姓名)、sex(性别)、birthday(生日)、home(籍贯)、address(居住地)和number(职员号)。 为“退出”按钮添加事件,当点击“退出”按钮时,关闭界面。
时间: 2024-03-24 10:38:51 浏览: 5
好的,我可以为您设计一个简单的职工信息录入界面,并添加退出按钮的事件。这个界面可以使用Python的Tkinter库来实现。以下是代码示例:
```python
from tkinter import *
def submit():
# 获取录入的职工信息
id = id_entry.get()
name = name_entry.get()
sex = sex_entry.get()
birthday = birthday_entry.get()
home = home_entry.get()
address = address_entry.get()
number = number_entry.get()
# 在这里可以将职工信息保存到数据库中
# 清空录入框
id_entry.delete(0, END)
name_entry.delete(0, END)
sex_entry.delete(0, END)
birthday_entry.delete(0, END)
home_entry.delete(0, END)
address_entry.delete(0, END)
number_entry.delete(0, END)
def exit():
# 关闭界面
root.destroy()
# 创建界面
root = Tk()
root.title("职工信息录入")
# 创建标签和录入框
id_label = Label(root, text="ID(身份证):")
id_label.grid(row=0, column=0, padx=5, pady=5)
id_entry = Entry(root)
id_entry.grid(row=0, column=1, padx=5, pady=5)
name_label = Label(root, text="name(姓名):")
name_label.grid(row=1, column=0, padx=5, pady=5)
name_entry = Entry(root)
name_entry.grid(row=1, column=1, padx=5, pady=5)
sex_label = Label(root, text="sex(性别):")
sex_label.grid(row=2, column=0, padx=5, pady=5)
sex_entry = Entry(root)
sex_entry.grid(row=2, column=1, padx=5, pady=5)
birthday_label = Label(root, text="birthday(生日):")
birthday_label.grid(row=3, column=0, padx=5, pady=5)
birthday_entry = Entry(root)
birthday_entry.grid(row=3, column=1, padx=5, pady=5)
home_label = Label(root, text="home(籍贯):")
home_label.grid(row=4, column=0, padx=5, pady=5)
home_entry = Entry(root)
home_entry.grid(row=4, column=1, padx=5, pady=5)
address_label = Label(root, text="address(居住地):")
address_label.grid(row=5, column=0, padx=5, pady=5)
address_entry = Entry(root)
address_entry.grid(row=5, column=1, padx=5, pady=5)
number_label = Label(root, text="number(职员号):")
number_label.grid(row=6, column=0, padx=5, pady=5)
number_entry = Entry(root)
number_entry.grid(row=6, column=1, padx=5, pady=5)
# 创建提交和退出按钮
submit_button = Button(root, text="提交", command=submit)
submit_button.grid(row=7, column=0, padx=5, pady=5)
exit_button = Button(root, text="退出", command=exit)
exit_button.grid(row=7, column=1, padx=5, pady=5)
root.mainloop()
```
这个界面中,我们创建了7个标签和对应的录入框,以便用户输入职工的各项信息。同时,我们还创建了一个“提交”按钮和一个“退出”按钮。当用户点击“提交”按钮时,程序将获取录入框中的各项信息,并可以将它们保存到数据库中。当用户点击“退出”按钮时,程序将关闭界面。
相关推荐
![](https://img-home.csdnimg.cn/images/20210720083646.png)
![](https://img-home.csdnimg.cn/images/20210720083646.png)
![](https://img-home.csdnimg.cn/images/20210720083646.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)