tkinter图书信息界面
时间: 2023-11-05 12:56:23 浏览: 69
以下是一个简单的使用Tkinter实现的图书信息界面示例代码:
```python
import tkinter as tk
# 创建主窗口
root = tk.Tk()
# 设置窗口标题
root.title("图书信息")
# 设置窗口大小和位置
root.geometry("400x300+200+100")
# 创建标签和输入框
label_title = tk.Label(root, text="书名:")
label_title.grid(row=0, column=0, pady=10)
entry_title = tk.Entry(root)
entry_title.grid(row=0, column=1, pady=10)
label_author = tk.Label(root, text="作者:")
label_author.grid(row=1, column=0, pady=10)
entry_author = tk.Entry(root)
entry_author.grid(row=1, column=1, pady=10)
label_publisher = tk.Label(root, text="出版社:")
label_publisher.grid(row=2, column=0, pady=10)
entry_publisher = tk.Entry(root)
entry_publisher.grid(row=2, column=1, pady=10)
label_price = tk.Label(root, text="价格:")
label_price.grid(row=3, column=0, pady=10)
entry_price = tk.Entry(root)
entry_price.grid(row=3, column=1, pady=10)
# 创建按钮
button_submit = tk.Button(root, text="提交")
button_submit.grid(row=4, column=0, pady=10)
button_clear = tk.Button(root, text="清空")
button_clear.grid(row=4, column=1, pady=10)
# 进入消息循环
root.mainloop()
```
运行后,可以看到如下界面:
![图书信息界面](https://img-blog.csdnimg.cn/20210905150947877.png)
你可以根据自己的需求修改标签和输入框的位置和样式。同时,你还可以为按钮添加回调函数,实现提交和清空等操作。
阅读全文
相关推荐
![-](https://img-home.csdnimg.cn/images/20241231045053.png)
![-](https://img-home.csdnimg.cn/images/20241231045053.png)
![-](https://img-home.csdnimg.cn/images/20241231045053.png)
![zip](https://img-home.csdnimg.cn/images/20241231045053.png)
![zip](https://img-home.csdnimg.cn/images/20241231045053.png)
![zip](https://img-home.csdnimg.cn/images/20241231045053.png)
![rar](https://img-home.csdnimg.cn/images/20241231044955.png)
![zip](https://img-home.csdnimg.cn/images/20241231045053.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)
![zip](https://img-home.csdnimg.cn/images/20241231045053.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://img-home.csdnimg.cn/images/20241231044955.png)