Esempio n. 1
0
 def auto(cls, plot_param, detail=False):
     cls.plot_param = plot_param
     only_image = "TkAgg" if detail else "Agg"
     plt.close('all')
     matplotlib.use(only_image)
     plt.rcParams['font.sans-serif'] = [u'SimHei']
     plt.rcParams['axes.unicode_minus'] = False
     instance, file_name, plot_size = plot_param
     width, height = (plot_size[0] - 120) / 100, plot_size[1] / 100 - 0.5
     download_dir = view_gate.query_env_define_data('G_DOWNLOAD_DIR')
     pid_dir = view_gate.query_env_define_data('G_PID_DIR')
     for ip, inst in instance.items():
         file = "{}\\{}\\__FILE_DATA__\\{}".format(download_dir, ip,
                                                   file_name)
         if not Common.is_file(file):
             raise Exception("{} 不存在\n请稍候重试".format(file))
         png = "{}\\{}_{}.png".format(pid_dir, ip, file_name.split('.')[0])
         data = pd.read_csv(file, parse_dates=True, index_col=0)
         data.plot(title="{}: {}".format(ip, file_name),
                   grid=True,
                   figsize=(width, height))
         if not detail:
             plt.savefig(png, dpi=100)
             view_gate.add_image_data.set_data(
                 ['AUTOPLOT_{}'.format(ip), png])
             inst.image_create('0.0',
                               image=view_gate.query_photo_image_data(
                                   'AUTOPLOT_{}'.format(ip)))
         else:
             plt.show()
Esempio n. 2
0
    def sub_tree(self, root, id=''):
        def parser_ploter():
            if "AutoPlot" in attrs:
                if "ManualPlot" in attrs or "OperateButtons" in attrs:
                    raise Exception("'{}'界面错误: AutoPlot不能与ManualPlot或OperateButtons同时存在".format(text))
                return "AutoPlot"
            elif "ManualPlot" in attrs:
                return "ManualPlot"
            return ""

        text, image, pages, subtree = root['Text'], root['Image'], root['Page'], root['SubTree']
        if image in self.all_id_map:
            raise Exception("'{}'界面错误: Image参数与'{}'界面冲突".format(text, self.all_id_map[image][0]))
        img = view_gate.query_photo_image_data(image)
        toolbar = False
        if pages == 'NA':
            sub_id = self.treeview.insert(id, 'end', text=text, image=img, tags=('tree.root', 'simple'), values="")
        else:
            widgets = pages['Widgets']
            shell = pages['Shell']
            attrs = pages['Attrs']
            ploter = parser_ploter()
            buttons = 'True' if "OperateButtons" in attrs else 'False'
            window = 'True' if "ResultWindow" in attrs else 'False'
            tag, values = 'tree.sub', [image, text, widgets, shell, ploter, buttons, window]
            sub_id = self.treeview.insert(id, 'end', text=text, image=img, tags=(tag, 'simple'), values=values)
            toolbar = True if "ToolBarMember" in attrs else False
            self.sub_images.append(image)
        # 保存所有节点id, 以界面image为key #
        self.all_id_map[image] = (text, sub_id, toolbar)
        if isinstance(subtree, list) and len(subtree) != 0:
            [self.sub_tree(sub, sub_id) for sub in subtree]
Esempio n. 3
0
 def __init__(self):
     self.sel = None
     self.last = None
     self.temp_png = '__temp__.png'
     # 先对全屏幕进行截图
     im = ImageGrab.grab()
     im.save(self.temp_png)
     im.close()
     # 变量X和Y用来记录鼠标左键按下的位置
     self.X = tk.IntVar(value=0)
     self.Y = tk.IntVar(value=0)
     self.top = tk.Toplevel()
     self.top.overrideredirect(True)
     width = self.top.winfo_screenwidth()
     height = self.top.winfo_screenheight()
     self.canvas = tk.Canvas(self.top, width=width, height=height)
     view_gate.add_image_data.set_data(['SCREEN_TEMP', self.temp_png])
     self.canvas.create_image(width//2, height//2, image=view_gate.query_photo_image_data('SCREEN_TEMP'))
     # 删除刚画完的图形,要不然鼠标移动的时候是黑乎乎的一片矩形
     def deleteLastDraw():
         try:
             self.canvas.delete(self.last)
         except:
             pass
     # 鼠标左键按下的位置
     def onLeftButtonDown(event):
         self.X.set(event.x)
         self.Y.set(event.y)
         self.sel = True
     self.canvas.bind('<Button-1>', onLeftButtonDown)
     # 鼠标左键移动,显示选取的区域
     def onLeftButtonMove(event):
         if not self.sel:
             return
         deleteLastDraw()
         self.last = self.canvas.create_rectangle(self.X.get(),
                                                  self.Y.get(),
                                                  event.x,
                                                  event.y,
                                                  width = 2,
                                                  outline='Red')
     self.canvas.bind('<B1-Motion>', onLeftButtonMove)
     # 获取鼠标左键抬起的位置,保存区域截图
     def onLeftButtonUp(event):
         self.sel = False
         deleteLastDraw()
         Common.sleep(0.1)
         # 考虑鼠标左键从右下方按下而从左上方抬起的截图
         left, right = sorted([self.X.get(), event.x])
         top, bottom = sorted([self.Y.get(), event.y])
         pic = ImageGrab.grab((left+1, top+1, right, bottom))
         save_name = "ScreenShot-{0}.png".format(Common.get_time(format=False))
         pic.save(save_name)
         self.top.destroy()
         Common.remove(self.temp_png)
         WidgetTip.info("截图成功: {0}\n截图保存在工具家目录下".format(save_name))
     self.canvas.bind('<ButtonRelease-1>', onLeftButtonUp)
     # 让canvas充满窗口,并随窗口自动适应大小
     self.canvas.pack(fill='both', expand=1)
Esempio n. 4
0
 def __init__(self, master, images, callback):
     for image, text in images:
         btn = ttk.Button(master,
                          image=view_gate.query_photo_image_data(image),
                          style="App.TButton",
                          command=lambda x=image: callback(x))
         btn.pack(side='left')
         WidgetTip.enter_tips(btn, text)
Esempio n. 5
0
 def default(self, width, height):
     self.width = width
     self.height = height
     master = tk.Frame(self.master)
     master.pack()
     self.current_page = master
     my_fm = TitleFrame(master, width, height, "统 计 信 息", True).master()
     fm = tk.Frame(my_fm)
     fm.pack(fill='both')
     tk.Label(fm, image=view_gate.query_photo_image_data('GUIDE')).pack()
Esempio n. 6
0
 def pack(self):
     self.top = top = tk.Toplevel()
     top.title('关于软件')
     top.geometry('{}x{}'.format(500, 340))
     top.resizable(False, False)
     top.wm_attributes('-topmost', 1)
     top.protocol("WM_DELETE_WINDOW", self.close)
     center_window(top)
     tk.Label(top, image=view_gate.query_photo_image_data('ABOUT')).pack()
     # 中间部分说明
     tk.Label(top,
              bg=Global.G_DEFAULT_COLOR,
              justify='left',
              text=view_gate.query_about_info_data(),
              font=(Global.G_DEFAULT_FONT, 10)
              ).pack(fill='both', ipady=5)
     # 底部版权说明
     tk.Label(top, text=view_gate.query_env_define_data('G_COPYRIGHT_INFO')).pack()
Esempio n. 7
0
 def __init__(self, master):
     self.master = master
     self.head_image = view_gate.query_photo_image_data('LGN_HEAD')
     self.count_limit = view_gate.query_login_limit_data()
     self.default_pwd = view_gate.query_default_pwd_data()
     self.sub_login = []