def press_bar_handle(key): if key == 'TB_EXPAND': tree_inst.expand_trees() elif key in ['TB_ABOUT', "MENU_ABOUT"]: TopAbout() elif key in ['TB_SCREEN', 'MENU_SCREEN']: ScreenShot() elif key in ['TB_HELP', 'MENU_HELP']: pdf = 'SystemController.pdf' if not Common.is_file(pdf): WidgetTip.error('{}不存在,请确认!'.format(pdf)) return Common.create_thread(lambda: Common.system_open(pdf)) elif key in ['MENU_SET', 'TB_SET']: GuiSettings.pack() elif key == 'MENU_EXIT': app_gate.close() elif key == 'TB_LAST': tree_inst.last() elif key == 'TB_NEXT': tree_inst.next() elif key in ["MENU_WHITE", "MENU_BLACK"]: WidgetTip.info("敬请期待 !") else: # 根据界面 image 值即可进入对应界面 # tree_inst.selection(key)
def pack_sub_tree_fm(): tree_view_data = view_gate.query_tree_view_data() try: treeview = TreeView(tree_fm, tree_view_data, switch_page) except Exception as e: WidgetTip.error("界面数据异常: %s" % str(e)) view_gate.exception_data.set_data(traceback.format_exc()) app_gate.close(ask=False) return treeview
def parser_widget_actions(): for act in actions: if act == 'UploadFile': for ip in ips: # 本地的文件路径传给上传列表,同时修改脚本参数为文件名 _local_f = shell_params[ip][-1] prev_uploads[ip].append(_local_f) shell_params[ip][-1] = Common.basename(_local_f) else: WidgetTip.error("Not support WidgetAction: {}".format(act)) continue
def switch_page(args_tuple): # image, text, widgets, shell, ploter, buttons, window = args_tuple = self.page_args self.page_args = [] [self.page_args.append(i) for i in list(args_tuple)] try: button = args_tuple[5] new_page = pager.switch_page(args_tuple[1:]) if not new_page and self.last_page_key: tree_inst.selection( self.last_page_key) # 界面切换失败时还原到上一个可用界面 return self.last_page_key = args_tuple[0] self.page_inst = new_page self.select_inst.show_button(button) except Exception as e: WidgetTip.error("切换界面异常:%s" % e) view_gate.exception_data.set_data(traceback.format_exc())
def manual(cls, params): try: matplotlib.use('TkAgg') plt.ion() # 开启interactive mode plt.close('all') ''' l = len(params) if l == 1: axes = plt.subplots(figsize=(12, 6), nrows=1, ncols=1, sharey=True, sharex=True)[1] ax_list = [axes] elif 1 < l <= 2: axes = plt.subplots(figsize=(12, 6), nrows=2, ncols=1, sharey=True, sharex=True)[1] ax_list = [axes[1], axes[0]] else: axes = plt.subplots(figsize=(12, 6), nrows=2, ncols=2, sharey=True, sharex=True)[1] ax_list = [axes[1, 0], axes[0, 0], axes[1, 1], axes[0, 1]] ''' download_dir = view_gate.query_env_define_data('G_DOWNLOAD_DIR') index = 0 for ip, res_list in params.items(): # proc, res, period = res_list proc, res = res_list file = "{}\\{}\\__FILE_DATA__\\{}.csv".format( download_dir, ip, proc) if not Common.is_file(file): raise Exception("{} 不存在\n如果是首次登录,请等待30秒再进此界面".format(file)) data = pd.read_csv(file, usecols=['Date', res], parse_dates=True, index_col=0) axes = plt.subplots(figsize=(12, 6), nrows=1, ncols=1, sharey=True, sharex=True)[1] data.plot(ax=axes, title="{}: {}".format(ip, proc), grid=True) #data.plot(ax=ax_list[index], title="{}: {}".format(ip, proc), grid=True) index += 1 plt.rcParams['font.sans-serif'] = [u'SimHei'] plt.rcParams['axes.unicode_minus'] = False plt.subplots_adjust(wspace=0.02, hspace=0.2) # 调整子图间距 # plt.savefig('aa.png', dpi=200) plt.show() except Exception as e: WidgetTip.error(str(e))
def check_input(): if not all(input_list): WidgetTip.error('输入不可为空') return False ip, user, upwd, rpwd = input_list if not Common.is_ip(ip): WidgetTip.error('请输入正确的IP地址') return False if ip in ip_exist_list: WidgetTip.error('{} 输入重复'.format(ip)) return False ip_exist_list.append(ip) return True
def check_limit_dependence(self, key, value): if key not in ['SDAY', 'EDAY', 'SMONTH', 'EMONTH']: return True if key == 'SDAY': if 'SMONTH' not in self.opts_dict: return True if int(value) < 28: return True month = int(self.opts_dict['SMONTH']) if month == 2 and int(value) > 28: WidgetTip.error('开始月份为2月时,日期不能设置大于28号!') self.reset_combox_list([[1, 1]]) self.pop_opts_dict('SDAY') return False elif month in [4, 6, 9, 11] and int(value) > 30: WidgetTip.error('开始月份为%s月时,日期不能设置大于30号!' % month) self.reset_combox_list([[1, 1]]) self.pop_opts_dict('SDAY') return False elif key == 'EDAY': if 'EMONTH' not in self.opts_dict: return True if int(value) < 28: return True month = int(self.opts_dict['EMONTH']) if month == 2 and int(value) > 28: WidgetTip.error('结束月份为2月时,日期不能设置大于28号!') self.reset_combox_list([[1, 2]]) self.pop_opts_dict('EDAY') return False elif month in [4, 6, 9, 11] and int(value) > 30: WidgetTip.error('结束月份为%s月时,日期不能设置大于30号!' % month) self.reset_combox_list([[1, 2]]) self.pop_opts_dict('EDAY') return False elif key == 'SMONTH': if 'SDAY' not in self.opts_dict: return True day = int(self.opts_dict['SDAY']) if int(value) == 2 and day > 28: WidgetTip.error('开始月份为2月时,日期不能设置大于28号!') self.reset_combox_list([[0, 1]]) self.pop_opts_dict('SMONTH') return False elif int(value) in [4, 6, 9, 11] and day > 30: WidgetTip.error('开始月份为%s月时,日期不能设置大于30号!' % value) self.reset_combox_list([[0, 1]]) self.pop_opts_dict('SMONTH') return False elif key == 'EMONTH': if 'EDAY' not in self.opts_dict: return True day = int(self.opts_dict['EDAY']) if int(value) == 2 and day > 28: WidgetTip.error('开始月份为2月时,日期不能设置大于28号!') self.reset_combox_list([[0, 2]]) self.pop_opts_dict('EMONTH') return False elif int(value) in [4, 6, 9, 11] and day > 30: WidgetTip.error('开始月份为%s月时,日期不能设置大于30号!' % value) self.reset_combox_list([[0, 2]]) self.pop_opts_dict('EMONTH') return False return True
def try_switch(): task = view_gate.query_running_task_data() if task: WidgetTip.error("请等待任务 {} 执行结束或手动'取消'该任务后继续".format(task)) return False return True