python tkinter 使用LabelFrame方法编写UI界面

部分内容参考:洪卫的博客 https://www.cnblogs.com/shwee/p/9427975.html


import tkinter as tk  # 使用Tkinter前需要先导入
from tkinter import ttk
# 第1步,实例化object,建立窗口window
window = tk.Tk()
# 第2步,给窗口的可视化起名字
window.title('My Window')
# 第3步,设定窗口的大小(长 * 宽)
window.geometry('1280x1024')  # 这里的乘是小x
# 第4步,place 放置方法(精准的放置到指定坐标点的位置上)
# tk.Label(window, text='Pl', font=('Arial', 20), ).place(x=100, y=100, anchor='nw')
# tk.Entry(window, font=('Arial', 20), ).place(x=200, y=100, anchor='nw')
#tk.Treeview(window, font=('Arial', 20), ).place(x=300, y=100, anchor='nw')  # 表格第一列不显示
ttk.Treeview(window)
tree = ttk.Treeview(window, show="headings")  # 表格第一列不显示
# tree.pack()
# tree.grid(row=2, columnspan=2)
tree.place(x=100, y=300, anchor='nw')
tree["columns"] = (
'序号', '企业名称', '生产经营场所地址', '行业类别', '所在地区', '发证机关', '许可证编号', '办结日期', '有效期限', 'COD年排放量', '氨氮年排放量', '二氧化硫年排放量', '氮氧化物年排放量')
# 设置列,不显示
tree.column("序号", width=50)
tree.column("企业名称", width=100)
tree.column("生产经营场所地址", width=120)
tree.column("行业类别", width=50)
tree.column("所在地区", width=50)
tree.column("发证机关", width=100)
tree.column("许可证编号", width=100)
tree.column("办结日期", width=50)
tree.column("有效期限", width=50)
tree.column("COD年排放量", width=100)
tree.column("氨氮年排放量", width=100)
tree.column("二氧化硫年排放量", width=100)
tree.column("氮氧化物年排放量", width=100)

# 显示表头
tree.heading("序号", text="序号")
tree.heading("企业名称", text="企业名称")
tree.heading("生产经营场所地址", text="生产经营场所地址")
tree.heading("行业类别", text="行业类别")
tree.heading("所在地区", text="所在地区")
tree.heading("发证机关", text="发证机关")
tree.heading("许可证编号", text="许可证编号")
tree.heading("办结日期", text="办结日期")
tree.heading("有效期限", text="有效期限")
tree.heading("COD年排放量", text="COD年排放量")
tree.heading("氨氮年排放量", text="氨氮年排放量")
tree.heading("二氧化硫年排放量", text="二氧化硫年排放量")
tree.heading("氮氧化物年排放量", text="氮氧化物年排放量")


group = ttk.LabelFrame(window,text="第一步选择爬取的地区")
group.place(x=100, y=100, anchor='nw')
# w = tk.Label(group,text="自去年5G商用牌照发放后,5G的发展全面加速,今年则迎来了5G爆发之年。5G网络高速率、业的关注焦点。")
# w.pack(fill = 'y',side = 'left',padx = 10,pady = 50)
com = tk.ttk.Combobox(group) # #创建下拉菜单
com.pack(padx = 10,pady = 10)
com["value"] = '11111'                     #(a_list)  # #给下拉菜单设定值
com2 = tk.ttk.Combobox(group)  # #创建下拉菜单
com2.pack(padx = 10,pady =10)

group = ttk.LabelFrame(window,text="第二步选择是否使用代理IP")
group.place(x=300, y=100, anchor='nw')
# w = tk.Label(group,text="自去年5G商用牌照发放后,5G的发展全面加速,今年则迎来了5G爆发之年。5G网络高速率、业的关注焦点。")
# w.pack(fill = 'y',side = 'left',padx = 10,pady = 50)
com = tk.ttk.Combobox(group) # #创建下拉菜单
com.pack(padx = 10,pady = 10)
com["value"] = '11111'                     #(a_list)  # #给下拉菜单设定值
com2 = tk.ttk.Combobox(group)  # #创建下拉菜单
com2.pack(padx = 10,pady =10)

group = ttk.LabelFrame(window,text="第三步开始爬取")
group.place(x=500, y=100, anchor='nw')
# w = tk.Label(group,text="自去年5G商用牌照发放后,5G的发展全面加速,今年则迎来了5G爆发之年。5G网络高速率、业的关注焦点。")
# w.pack(fill = 'y',side = 'left',padx = 10,pady = 50)
bottom1 = tk.ttk.Button(group, text='开始爬取', command=window.quit) # #创建下拉菜单
bottom1.pack(padx = 10,pady = 10)
bottom2 = tk.ttk.Button(group, text='退出', command=window.quit) # #创建下拉菜单
bottom2.pack(padx = 10,pady = 10)

group = ttk.LabelFrame(window,text="第四步保存")
group.place(x=700, y=100, anchor='nw')
# w = tk.Label(group,text="自去年5G商用牌照发放后,5G的发展全面加速,今年则迎来了5G爆发之年。5G网络高速率、业的关注焦点。")
# w.pack(fill = 'y',side = 'left',padx = 10,pady = 50)
bottom3 = tk.ttk.Button(group, text='保存', command=window.quit) # #创建下拉菜单
bottom3.pack(padx = 10,pady = 10)




# 第5步,主窗口循环显示
window.mainloop()
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值