上次很闲,实现了网购平台比价系统的实现_小憨憨。的博客-CSDN博客_比价系统原文中题主的UI设计,如涉嫌侵权,告知后则删。
略微不同。
import tkinter as tk
from tkinter import ttk
from tkinter import messagebox
#窗口设置
window=tk.Tk()
window.title('网购平台比价系统')
window.geometry('1200x700')
#平台选择
tk.Label(window,text='平台选择:').place(x=20,y=30)
#多选按钮
tk.Checkbutton(window,text='天猫').place(x=100,y=28)
tk.Checkbutton(window,text='京东').place(x=170,y=28)
tk.Checkbutton(window,text='拼多多').place(x=240,y=28)
#edit输入
tk.Label(window,text='每个平台爬取数量:').place(x=330,y=30)
tk.Text(window,width=2,height=1).place(x=450,y=32)
tk.Label(window,text='关键词:').place(x=500,y=30)
tk.Text(window,width=5,height=1).place(x=550,y=32)
var=tk.IntVar()
#排序方式
tk.Label(window,text='排序方式:').place(x=620,y=30)
#单选按钮
tk.Radiobutton(window,text='默认排序',variable=var,value=1).place(x=690,y=28)
tk.Radiobutton(window,text='价格升序',variable=var,value=2).place(x=760,y=28)
tk.Radiobutton(window,text='价格倒序',variable=var,value=3).place(x=830,y=28)
#提示框
def say__message():
tk.messagebox.showinfo(title='提示',message='爬取完成\n拼多多商品销量为总销量,京东为月销量')
#开始爬取按钮
b_select=tk.Button(window,text='开始爬取',width=20,height=1,command=say__message).place(x=1040,y=27)
#edit搜索序号
tk.Label(window,text='请输入序号:').place(x=20,y=72)
tk.Text(window,width=50,height=1).place(x=100,y=74)
#开始比价按钮
b_select=tk.Button(window,text='开始比价',width=20,height=1).place(x=500,y=68)
#加入关注按钮
b_select=tk.Button(window,text='加入关注',width=20,height=1).place(x=670,y=68)
#关注列表按钮
b_select=tk.Button(window,text='关注列表',width=20,height=1).place(x=840,y=68)
#商品价格按钮
b_select=tk.Button(window,text='更新关注商品价格',width=20,height=1).place(x=1040,y=68)
tree = ttk.Treeview(window,height=25,columns=['1','2','3','4','5','6','7','8'],show='headings')
tree.column('1',width=40)
tree.column('2',width=120)
tree.column('3',width=80)
tree.column('4',width=260)
tree.column('5',width=160)
tree.column('6',width=80)
tree.column('7',width=80)
tree.column('8',width=290)
tree.heading('1',text='序号')
tree.heading('2',text='ID')
tree.heading('3',text='平台')
tree.heading('4',text='标题')
tree.heading('5',text='商铺')
tree.heading('6',text='价格')
tree.heading('7',text='销量')
tree.heading('8',text='链接')
for i in range(1000):
tree.insert('',i,values=('a'+str(i),'b'+str(i),'c'+str(i),'d'+str(i),'e'+str(i),'f'+str(i),'g'+str(i),'h'+str(i)))
#滚动条
vbar = ttk.Scrollbar(window,orient=tk.VERTICAL,command=tree.yview)
tree.configure(yscrollcommand=vbar.set)
tree.grid(row=0,column=0,padx=20,pady=150,sticky=tk.NSEW)
vbar.grid(row=0,column=1,padx=20,pady=150,sticky=tk.NS)
window.mainloop()