def combobox_response(*args): combobox_select_str = self.model_choose_combobox.get() combobox_select_index = self.model_choose_combobox.current() width = int(self.maxWidth / 3) height = int((self.maxHeight / 2) - 45) if self.load_in_flag != 0: if combobox_select_index == 0: labels = [u'Web', u'Download', u'QQ', u'Wechat', u'Thunder'] statistic_analysis.draw_pie(self.APP_proportion, labels, "APP") self.photo_main = self.Load_img('app_pie.png', width, height) self.label_image.config(image=self.photo_main) elif combobox_select_index == 1: labels = [u'Web', u'Download', u'QQ', u'Wechat', u'Thunder'] statistic_analysis.draw_bar(self.APP_list, labels, "APP") self.photo_main = self.Load_img('app_bar.png', width, height) self.label_image.config(image=self.photo_main) if combobox_select_index == 2: labels = [u'Web', u'Download', u'QQ', u'Wechat', u'Thunder'] statistic_analysis.draw_pie(self.APP_length_proportion, labels, "APP_length") self.photo_main = self.Load_img('app_length_pie.png', width, height) self.label_image.config(image=self.photo_main) elif combobox_select_index == 3: labels = [u'Web', u'Download', u'QQ', u'Wechat', u'Thunder'] statistic_analysis.draw_bar(self.APP_length_list, labels, "APP_length") self.photo_main = self.Load_img('app_length_bar.png', width, height) self.label_image.config(image=self.photo_main) else: messagebox.showinfo("提示:", "未导入数据")
def load_file(self): filename = self.open_file() print(filename) if filename == "": show_text = "取消读取文件" self.change_show_text(show_text) return show_text = "正在打开" + filename + " \n最大读取包数:" + str(self.packet_load_num) self.change_show_text(show_text) self.root.update() this_pcap_file = Pcap_class.build_pcap(filename, self.packet_load_num) show_text = "成功创建Pcap类,共含" + str(len(this_pcap_file.get_packets())) + "个流量包" self.change_show_text(show_text) self.load_in_flag = 1 save_data.clear_all_table() show_text = "清空临时表完毕" self.change_show_text(show_text) save_data.save_data(this_pcap_file) show_text = "填写临时表完毕" self.change_show_text(show_text) self.static_datas = statistic_analysis.statistic_analysis_entrance() show_text = "统计分析完成" self.change_show_text(show_text) self.fill_data_table(self.static_datas) width = int(self.maxWidth / 3) height = self.maxHeight - 120 labels = [u'TCP', u'UDP', u'DNS',u'HTTP', u'HTTPS'] protocol_adjust_list = copy.deepcopy(self.static_datas[-2]) protocol_adjust_list[0] = protocol_adjust_list[0] - protocol_adjust_list[3] - protocol_adjust_list[4] protocol_adjust_list[1] = protocol_adjust_list[1] - protocol_adjust_list[2] statistic_analysis.draw_pie(protocol_adjust_list, labels, "protocol") self.photo_main = self.Load_img('protocol_pie.png', width, height) self.label_image.config(image=self.photo_main)
def combobox_response(*args): combobox_select_str = self.model_choose_combobox.get() combobox_select_index = self.model_choose_combobox.current() if self.load_in_flag != 0: if combobox_select_index == 0: labels = [u'TCP', u'UDP', u'DNS',u'HTTP', u'HTTPS'] protocol_adjust_list = copy.deepcopy(self.static_datas[-2]) protocol_adjust_list[0] = protocol_adjust_list[0] - protocol_adjust_list[3] - protocol_adjust_list[ 4] protocol_adjust_list[1] = protocol_adjust_list[1] - protocol_adjust_list[2] statistic_analysis.draw_pie(protocol_adjust_list, labels, "protocol") self.photo_main = self.Load_img('protocol_pie.png', width, height) self.label_image.config(image=self.photo_main) elif combobox_select_index == 1: labels = [u'TCP', u'UDP', u'DNS',u'HTTP', u'HTTPS'] protocol_adjust_list = [self.static_datas[2],self.static_datas[3],self.static_datas[6], self.static_datas[4],self.static_datas[5]] statistic_analysis.draw_bar(protocol_adjust_list, labels,"protocol") self.photo_main = self.Load_img('protocol_bar.png', width, height) self.label_image.config(image=self.photo_main) if combobox_select_index == 2: labels = [u'0-200', u'200-400', u'400-600', u'600-800', u'800-1000', u'1000-1200', u'1200-1400', u'1400-1600'] protocol_adjust_list = copy.deepcopy(self.static_datas[-1]) statistic_analysis.draw_pie(protocol_adjust_list, labels, "length") self.photo_main = self.Load_img('length_pie.png', width, height) self.label_image.config(image=self.photo_main) elif combobox_select_index == 3: labels = [u'200', u'400', u'600', u'800', u'1000', u'1200', u'1400', u'1600'] length_adjust_list = [int(x * self.static_datas[1]/100) for x in self.static_datas[-1]] statistic_analysis.draw_bar(length_adjust_list, labels, "length") self.photo_main = self.Load_img('length_bar.png', width, height) self.label_image.config(image=self.photo_main) else: messagebox.showinfo("提示:", "未导入数据")
def app_classify_graph(self): show_text = "应用流量分析完成" self.change_show_text(show_text) width = int(self.maxWidth / 3) height = int((self.maxHeight / 2) - 45) labels = [u'Web', u'Download', u'QQ', u'Wechat', u'Thunder'] statistic_analysis.draw_pie(self.APP_proportion, labels, "APP") self.photo_main = self.Load_img('app_pie.png', width, height) self.label_image.config(image=self.photo_main)
def statistic_graph(self): show_text = "准备分析统计数据" self.change_show_text(show_text) self.static_datas = statistic_analysis.statistic_analysis_entrance() show_text = "统计分析完成" self.change_show_text(show_text) self.fill_data_table(self.static_datas) width = int(self.maxWidth / 3) height = self.maxHeight - 120 labels = [u'TCP', u'UDP', u'DNS', u'HTTP', u'HTTPS'] protocol_adjust_list = copy.deepcopy(self.static_datas[-2]) protocol_adjust_list[0] = protocol_adjust_list[0] - protocol_adjust_list[3] - protocol_adjust_list[4] protocol_adjust_list[1] = protocol_adjust_list[1] - protocol_adjust_list[2] statistic_analysis.draw_pie(protocol_adjust_list, labels, "protocol") self.photo_main = self.Load_img('protocol_pie.png', width, height) self.label_image.config(image=self.photo_main)