1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171
| from cProfile import label import datetime from datetime import timedelta import math from dateutil.relativedelta import * import tkinter as tk from tkinter import * import os,re,sys import numpy as np import pandas as pd import matplotlib.pyplot as plt plt.rcParams['font.sans-serif']=['SimHei'] plt.rcParams['axes.unicode_minus']=False import mpl_toolkits.axisartist as axisartist from mpl_toolkits.axisartist.axislines import SubplotZero from mpl_toolkits.axes_grid1.inset_locator import inset_axes from mpl_toolkits.axes_grid1.inset_locator import mark_inset
window = tk.Tk() window.title('数据分析助手01.03') window.geometry('1000x700') biaoti = tk.Label(window, text="数 据 分 析 助 手", fg='blue',font=('Batang', 20), width=30) biaoti.place(x=250,y=30)
var1 = tk.StringVar() l = tk.Label(window, bg='white', fg='red',font=('Arial', 10), width=20, textvariable=var1) l.place(x=250,y=120)
lweidu = tk.Label(window, text="数据维度(季输1/周输2/年输3)\n(空值默认为月,其他必输):") lweidu.place(x=50,y=160) NUM_weidu = tk.StringVar() NUM_weidu.set("") date_weidu =tk.Entry(window,text = "",width=20,textvariable = NUM_weidu) date_weidu.place(x=50,y=200)
lshu = tk.Label(window, text="请输入要处理几期数据\n(空值默认为2):") lshu.place(x=50,y=230) NUM0 = tk.StringVar() NUM0.set("") date_num =tk.Entry(window,text = "",width=20,textvariable = NUM0) date_num.place(x=50,y=270)
lye = tk.Label(window, text="请输入最后的月/季/周\n(空值默认为上月):") lye.place(x=50,y=300) date_m0 = tk.StringVar() date_m0.set("") date_mm =tk.Entry(window,text = "",width=20, textvariable = date_m0) date_mm.place(x=50,y=340)
lye1 = tk.Label(window, text="是否6类特价商品\n(是输1/空值默认为否):") lye1.place(x=50,y=370) M3_M9 = tk.StringVar() M3_M9.set("") M3M9 =tk.Entry(window,text = "",width=20, textvariable = M3_M9) M3M9.place(x=50,y=410) v3_list0=['总公司下载数据', '新员工销售统计','老员工销售统计','单个商品进出货数据','库存商品统计','季度分公司分级']
def print_selection1(): value = lb.get(lb.curselection()) var1.set(value) fenghang1 = ['广东', '珠海', '汕头', '潮州', '韶关', '河源', '梅州', '惠州', '汕尾', '东莞',\ '中山', '江门', '佛山', '阳江', '湛江', '茂名', '肇庆', '清远', '揭阳', '云浮']
value1=value print("\n下面开始处理:%s" % (value1)) var4 = tk.StringVar() var4.set(fenghang1) var2 = tk.StringVar() l2 = tk.Label(window, bg='white', fg='red',font=('Arial', 10), width=16, textvariable=var2) l2.place(x=480,y=120) def print_selection2(): value = lb_2.get(lb_2.curselection()) var2.set(value) value2=value
var5 = tk.StringVar() l3 = tk.Label(window, bg='white', fg='red',font=('Arial', 10), width=26, textvariable=var5) l3.place(x=680,y=120) def print_selection3(): Aa = tk.Label(window, bg='#f4f4f4',fg="blue",font=("Arial",10),width=90,height=10,text ='',wraplength = 656,justify = 'left') Aa.place(x=120,y=480) value = lb_3.get(lb_3.curselection()) var5.set(value) value3=value
def qushitu(num_list1,num_list2,label_list0): plt.close() fig = plt.figure(num=1, figsize=(9,5),dpi=90) ax2 = plt.subplot(212, sharex=ax1) plt.show()
if value =="销售任务(实际销量)变化趋势图" or value =='新员工销售任务(实际销量)变化趋势图': num_list1 = [1] num_list2 = [2] label_list0 = [] qushitu(num_list1,num_list2,label_list0) if value =="本期出货数量及商品占比图": plt.close() fig = plt.figure(num=2, figsize=(7, 4)) ax1 = fig.add_subplot(1, 1, 1) Y_len2_1 = 1 plt.ylim(0,Y_len2_1) plt.legend(loc='upper left', fontsize=9) axins = inset_axes(ax1,width=2.5, height=1.2, loc='upper right') x2 = 1 data2_3 = [0] cor = 'blue' axins.bar(x2,dict(data2_3).values(),width=0.4, color=cor,alpha=0.5) plt.show()
lb_3 = tk.Button(window, text='请选择输出图表名称', width=29, height=2, command=print_selection3) lb_3.place(x=680,y=150) var6 = tk.StringVar() if value1 == '总公司下载数据': var6.set(('多期利润分成或本期环比','多期退货统计或本期环比',"按地区统计本期潜在客户数量",'本期出货数量及商品占比图','本期退货原因统计图','机构网点分析','销售任务(实际销量)变化趋势图','多期合并原表')) elif value1 == '新员工销售统计': var6.set(('多期利润分成或本期环比','多期退货统计或本期环比','本期出货数量及商品占比图','本期退货原因统计图','机构网点分析','多期合并原表','按地区统计本期潜在客户数量','销售任务(实际销量)变化趋势图')) elif value1 == '老员工销售统计': var6.set(('多期利润分成或本期环比','多期退货统计或本期环比','本期出货数量及商品占比图','本期退货原因统计图','机构网点分析','多期合并原表','按地区统计本期潜在客户数量','销售任务(实际销量)变化趋势图')) elif value1 == '单个商品进出货数据': model = 'null' var6.set(model) elif value1 == '季度分公司分级': var6.set(('本季清单','本季各类占比统计表','多期合并原表','本季明细',"(内)外加工数量趋势图",'多期拆分与环比')) elif value1 == '库存商品统计': var6.set(('多期退货统计或本期环比','多期合并原表','本期退货原因统计图','(内)外加工数量趋势图')) lb_3 = tk.Listbox(window, listvariable=var6, width=30, height=13) value10 = [] if value10==['M3M4M5M7M8M9'] and value1 != '单个商品进出货数据': lb_3.insert('end','M3M4M5M7M8M9') if value1 == '季度分公司分级' : NUM = 6 if NUM>6: lb_3.insert('end','连续3期排名前','多期结果','近3季升降前10名') if value2 == '广东': lb_3.insert('end','多期利润分成或本期环比','多期退货统计或本期环比','本期退货原因统计图','新员工销售任务(实际销量)变化趋势图') lb_3.place(x=680,y=200) lb_2 = tk.Button(window, text='请选择分公司名称', width=18, height=2, command=print_selection2) lb_2.place(x=480,y=150) lb_2 = tk.Listbox(window, listvariable=var4, width=19, height=13) lb_2.place(x=480,y=200)
b1 = tk.Button(window, text='请选择数据种类', width=22, height=2, command=print_selection1) b1.place(x=250,y=150)
v3_list = list(set(v3_list0)) var3 = tk.StringVar() var3.set(v3_list)
lb = tk.Listbox(window, listvariable=var3, width=23, height=13) lb.place(x=250,y=200)
lm = tk.Label(window,fg="#3066cc",text='维护日期:2021-01-27 如是我闻') lm.pack(side="bottom")
window.mainloop()
|