⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 np_plot.py

📁 该软件根据网络数据生成NetFlow记录。NetFlow可用于网络规划、负载均衡、安全监控等
💻 PY
📖 第 1 页 / 共 5 页
字号:
        # Force zero y origin        #        self.zero_origin = zero_origin         #        # Any decorations        #        self.decs = decorations	#	# Set up toolbar	#	if standalone == 'yes':	    self.quitfun = self.finish	else:	    self.quitfun = self._destroy	#	self.toolbar()        if mode == MODE_HIST:            self.toolbar.entryconfig('TS', state=DISABLED)            self.style = STYLE_BARS        if mode == MODE_PDF:            self.toolbar.entryconfig('TS', state=DISABLED)            self.toolbar.entryconfig('HIST', state=DISABLED)            self.style = STYLE_BARS        if mode == MODE_CDF:            self.toolbar.entryconfig('TS', state=DISABLED)            self.toolbar.entryconfig('HIST', state=DISABLED)            self.toolbar.entryconfig('PDF', state=DISABLED)	#	# Set up set manipulation window	#        self.sw_show = 0        self.swindow()        # but don't show if only 1        if len(sets) == 1:            #self.toolbar.show_swb.configure(state=DISABLED)            self.toolbar.entryconfig('sets', state=DISABLED)		# Set up drawing area	self.canvasses = []                if delay_activation != 'yes':            # draw            self.activate()##############################################################################    def activate(self):        	#	# Draw top level data and activate event loop	#	c = Plot_canv(self, self.sets, style=self.style, mode=self.mode, zero_origin=self.zero_origin)	self.canvasses.append(c)	self.canv_curr = 0	c.canv.pack(side=LEFT, fill=BOTH, expand = 1)                if self.standalone == 'yes':            self.root.mainloop()        else:            self.root.wait_window(self.root)##############################################################################    def toolbar(self):	self.frame = Frame(self.root)	self.frame.config(bg='black')	self.frame.pack(side=LEFT, fill=BOTH, expand=1)	# create a toolbar	toolbar = self.toolbar = Menu(self.root)	toolbar.config(background='grey')	toolbar.add_command(label="Quit", command=self.quitfun,                            background='grey', foreground='red')        toolbar.add_separator() 	self.stylev_curr = IntVar() 	self.stylev_curr.set(self.style)	stym = self.stylemenu = Menu(self.toolbar)        stym.config(background='grey')	stym.add_radiobutton(label='Points', 				  command=self.set_style_POINTS, 				  variable=self.stylev_curr,				  value=STYLE_POINTS, indicatoron=1, 				  selectcolor='blue')	stym.add_radiobutton(label='Lines', 				  command=self.set_style_LINES, 				  variable=self.stylev_curr,				  value=STYLE_LINES, indicatoron=1, 				  selectcolor='blue')	stym.add_radiobutton(label='LinesPoints', 				  command=self.set_style_LINESPOINTS, 				  variable=self.stylev_curr,				  value=STYLE_POINTS | STYLE_LINES, indicatoron=1, 				  selectcolor='blue')	stym.add_radiobutton(label='Bars', 				  command=self.set_style_BARS, 				  variable=self.stylev_curr,				  value=STYLE_BARS, indicatoron=1, 				     selectcolor='blue')        	stym.add_radiobutton(label='Errorbars-s.d.', 				  command=self.set_style_EBARS, 				  variable=self.stylev_curr,				  value=STYLE_EBARS_SD, indicatoron=1, 				     selectcolor='blue', state=self.ebsd)	stym.add_radiobutton(label='Errorbars-s.e.', 				  command=self.set_style_EBARS, 				  variable=self.stylev_curr,				  value=STYLE_EBARS_SE, indicatoron=1, 				     selectcolor='blue', state=self.ebse)        toolbar.add_cascade(label='Style', menu=stym)	toolbar.add_command(label="sets", command=self.show_sw,                            background='grey')	self.v = IntVar()	self.v.set(self.mode)	toolbar.add_radiobutton(label="TS", background='grey',                                variable=self.v, value=MODE_TS,                                 indicatoron=0,                                 command=self.set_mode_TS)	toolbar.add_radiobutton(label="HIST", background='grey',                                variable=self.v, value=MODE_HIST,                                 indicatoron=0,                                 command=self.set_mode_HIST)	toolbar.add_radiobutton(label="PDF", background='grey',                                variable=self.v, value=MODE_PDF,                                indicatoron=0,                                 command=self.set_mode_PDF)	toolbar.add_radiobutton(label="CDF", background='grey',                                variable=self.v, value=MODE_CDF,                                indicatoron=0,                                 command=self.set_mode_CDF)		        self.smoothtype = StringVar()	smoom = self.smoothmenu = Menu(self.toolbar, background='grey')        	meansmoom = Menu(smoom, background='grey')	meansmoom.add_radiobutton(label='5s', 				  command=self.mode_smooth, 				  variable=self.smoothtype,				  value='mean:5', indicatoron=0,                                  background='grey')	meansmoom.add_radiobutton(label='10s', 				  command=self.mode_smooth, 				  variable=self.smoothtype,				  value='mean:10', indicatoron=0,                                  background='grey')	meansmoom.add_radiobutton(label='60s', 				  command=self.mode_smooth, 				  variable=self.smoothtype,				  value='mean:60', indicatoron=0,                                  background='grey')        smoom.add_cascade(label='Mean over...', menu=meansmoom)        	smasmoom = Menu(smoom, background='grey')	smasmoom.add_radiobutton(label='5s', 				  command=self.mode_smooth, 				  variable=self.smoothtype,				  value='sma:5', indicatoron=0,                                  background='grey')	smasmoom.add_radiobutton(label='10s', 				  command=self.mode_smooth, 				  variable=self.smoothtype,				  value='sma:10', indicatoron=0,                                  background='grey')	smasmoom.add_radiobutton(label='60s', 				  command=self.mode_smooth, 				  variable=self.smoothtype,				  value='sma:60', indicatoron=0,                                  background='grey')        smoom.add_cascade(label='Sma over...', menu=smasmoom)        	emasmoom = Menu(smoom, background='grey')	emasmoom.add_radiobutton(label='0.1', 				  command=self.mode_smooth, 				  variable=self.smoothtype,				  value='ema:0.1', indicatoron=0,                                  background='grey')	emasmoom.add_radiobutton(label='0.2', 				  command=self.mode_smooth, 				  variable=self.smoothtype,				  value='ema:0.2', indicatoron=0,                                  background='grey')	emasmoom.add_radiobutton(label='0.5', 				  command=self.mode_smooth, 				  variable=self.smoothtype,				  value='ema:0.5', indicatoron=0,                                  background='grey')        smoom.add_cascade(label='Ema alpha...', menu=emasmoom)        smoom.add_radiobutton(label='Han', 				  command=self.mode_smooth, 				  variable=self.smoothtype,				  value='han', indicatoron=0,                                  background='grey')    ##     smoom.add_radiobutton(label='Other', ## 				  command=self.mode_smooth, ## 				  variable=self.smoothtype,## 				  value='', indicatoron=0,##                                   background='grey')        self.osmoom = osmoom =  Menu(smoom, background='grey')        osmoom.add_radiobutton(label='Other', 				  command=self.mode_smooth, 				  variable=self.smoothtype,				  value='', indicatoron=0,                                  background='grey')        smoom.add_cascade(label='Other', menu=osmoom)                toolbar.add_cascade(label='Smooth', menu=smoom)	toolbar.add_command(label="Print", command=self.hardcopy,                            background='grey')        if len(self.sets) == 1:            toolbar.add_command(label="Data", command=self.showsetdata,                            background='grey')        addm = self.addm = Menu(self.toolbar, background='grey')        addm.add_command(label="Add data set", command=self.addset,                            background='grey')        addm.add_command(label="Add function", command=self.addfn,                            background='grey')        addm.add_command(label="Set fields", command=self.add_setfields,                            background='grey')        toolbar.add_cascade(label='Add', menu=addm)                self.root.config(menu=toolbar)##############################################################################    def swindow(self):        sw = self.sw = Toplevel()        sw.transient(self.root)        sw.winfo_toplevel().title('np_plot Sets')        maxlen = 0        nlines = len(self.sets)        for s in self.sets:            maxlen = max([maxlen, len(s.path)])        ht = nlines*20 +40        wi = maxlen*60        sw.config(height=ht, width=wi)        toolbar = sw.toolbar = Menu(sw)	toolbar.config(background='grey')	toolbar.add_command(label="Hide", command=self.hide_sw,                            background='grey', foreground='black')  		# just a separator        toolbar.add_separator(background='black')        sw.defer_redraw=IntVar()        sw.defer_redraw.set(0)	toolbar.add_checkbutton(label="Defer Draw", command=self.defer,                            background='grey', foreground='black',                                variable=sw.defer_redraw, indicatoron=0,                                selectcolor='blue', hidemargin=0)	toolbar.add_command(label="ReDraw", command=self.redraw,                            background='grey', foreground='black', state=DISABLED)        sw.config(menu=toolbar)        # just to make a vertical gap	sep = Frame(sw)	sep.configure(bg='grey60', height=10, relief=RAISED)	sep.pack(side=TOP, fill=X)        	sw.allframe = Frame(sw)	sw.allframe.configure(bg='black', height=50, relief=RAISED)	sw.allframe.pack(side=TOP, fill=X)        self.hideall = IntVar()        self.hideall.set(0)        sw.allframe.allb = Checkbutton(sw.allframe, text=' Hide ', command=self.all_hide,fg='black', bg='grey', indicatoron=0, variable=self.hideall)        sw.allframe.allb.pack(side=LEFT)        self.hidenone = IntVar()        self.hidenone.set(0)        sw.allframe.noneb = Checkbutton(sw.allframe, text='Show',                                 command=self.all_show,fg='black', bg='grey',                                 indicatoron=0, variable=self.hidenone)        sw.allframe.noneb.pack(side=LEFT)        sw.allframe.lab =  Checkbutton(sw.allframe, text='All Sets',                                 command=self.all_show,                                 disabledforeground='red', bg='black',                                 indicatoron=0, state=DISABLED)        sw.allframe.lab.pack(side=LEFT, fill=X, expand=1)        # just to make a vertical gap	sep = Frame(sw)	sep.configure(bg='grey60', height=10, relief=RAISED)	sep.pack(side=TOP, fill=X)        maxchar = 0        for s in self.sets:            maxchar = max([maxchar, len(s.path)])        #print maxchar        sw.setframe = Frame(sw)        sw.setframe.configure(bg='black', relief=RAISED)        sw.setframe.pack(side=TOP, fill=X)        self.showset = IntVar()        self.showset.set(0)                i = 0        tag0 = 'a'        tag = 'a'        for s in self.sets:            #print tag            s.tg = tag0 + tag            hide = s.hidden[-1]            if hide:                bstate = DISABLED                fg = 'grey80'                bg = 'grey'                txt = 'Show'            else:                bstate = NORMAL                fg = s.col                bg = 'black'                txt = 'Hide'            s.ops = Frame(sw.setframe)            s.ops.configure(bg='black', width=wi, height=25)            s.ops.pack(side=TOP, fill=X)                        s.ops.top = Radiobutton(s.ops, text=' Top ',                                command=self.raisefn,                                variable=self.topset,                               value=i, indicatoron=0, selectcolor='blue')            s.ops.top.configure(bg='grey', fg='black', state=bstate)            s.ops.top.pack(side=LEFT)                        s.ops.hide = Checkbutton(s.ops, text=txt, variable=s.hide,                                command=self.hidefn, indicatoron=0,                                onvalue=1, offvalue=0, selectcolor='grey')            s.ops.hide.configure(bg='grey', fg='black')            s.hide.set(hide)            s.ops.hide.pack(side=LEFT)            ####            s.ops.data = Radiobutton(s.ops, text='data', variable=self.showset,                               value=i, command=self.showsetdata,                                     indicatoron=0)            s.ops.data.configure(bg='grey', fg='black')            s.ops.data.pack(side=LEFT)            ####            s.ops.delete = Radiobutton(s.ops, text='Delete',                                       variable=self.delset, value=i,                                       command=self.deleteset,                                       indicatoron=0)            s.ops.delete.configure(bg='grey', fg='black')            s.ops.delete.pack(side=LEFT)            ####            s.ops.col = Checkbutton(s.ops, text='%s (%d)' % (s.path, s.len),                                    background=bg,                                    foreground=fg, variable=s.docol,                                    command=self.scolfn, indicatoron=0,                                    onvalue=1, offvalue=0, selectcolor='blue',                                    disabledforeground='grey40',                                    width=maxchar+10, state=bstate)            s.ops.col.pack(side=LEFT)            i += 1            #tag += 'a'            nt = ord(tag)+1            if nt > ord('z'):                nt = ord('a')                tag0 = chr(ord(tag0)+1)            tag = chr(nt)        # just to make a vertical gap	sw.sep = Frame(sw)	sw.sep.configure(bg='grey60', height=10, relief=RAISED)	sw.sep.pack(side=TOP, fill=X)        if not self.sw_show:            sw.withdraw() #start hidden##############################################################################    def hide_sw(self):        self.sw.withdraw()        self.sw_show = 0##############################################################################    def show_sw(self):        self.sw.deiconify()        self.sw_show = 1##############################################################################    def all_hide(self):        self.hideall.set(0)                for s in self.sets:            s.hide.set(1)        if self.sw.defer_redraw.get():            self.hide_deferred()        else:            self.hideit()##############################################################################

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -