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

📄 np_tscreen.py

📁 该软件根据网络数据生成NetFlow记录。NetFlow可用于网络规划、负载均衡、安全监控等
💻 PY
📖 第 1 页 / 共 3 页
字号:
		self.disp = set[1]	self.bind_mode_buttons(set)	    ##############################################################################    def hide_mode(self, set):	set[0].pack_forget()	set[1].pack_forget()	set[1].delete_map_port(set[1])	self.unbind_mode_buttons(set)	    ##############################################################################    def set_drag_cursor(self, e):        e.widget.config(cursor=(drag, 'orange'))	    ##############################################################################    def set_cross_cursor(self, e):        e.widget.config(cursor=(ccross, 'orange'))	    ##############################################################################    def reset_cursor(self, e):        e.widget.config(cursor=(''))	    ##############################################################################    def bind_mode_buttons(self, set):        set[1].bind("<Enter>", self.set_cross_cursor)        set[1].bind("<Leave>", self.reset_cursor)	set[1].bind("<1>", self.tcanv_b1)	set[1].bind("<B1-Motion>", self.tcanv_b1_drag)	set[1].bind("<ButtonRelease-1>", self.tcanv_b1_up)	set[1].bind("Control-<1>", self.tcanv_b1)	set[1].bind("<Control-B1-Motion>", self.tcanv_b1_bigdrag)	set[1].bind("<Control-ButtonRelease-1>", self.tcanv_b1_up)	set[1].bind("<2>", self.tcanv_b2)	set[1].bind("<B2-Motion>", self.tcanv_b2_drag)	set[1].bind("<ButtonRelease-2>", self.tcanv_b2_up)	set[1].bind("Shift-<2>", self.tcanv_shft_b2)	set[1].bind("<Shift-B2-Motion>", self.tcanv_shft_b2_drag)	set[1].bind("<Shift-ButtonRelease-2>", self.tcanv_shft_b2_up)	set[1].bind("Control-<2>", self.tcanv_ctr_b2)	set[1].bind("<Control-B2-Motion>", self.tcanv_ctr_b2_drag)	set[1].bind("<Control-ButtonRelease-2>", self.tcanv_ctr_b2_up)	set[1].bind("<3>", self.tcanv_b3)	set[1].bind("<B3-Motion>", self.tcanv_b3_drag)	set[1].bind("<ButtonRelease-3>", self.tcanv_b3_up)        set[0].bind("<Enter>", self.set_drag_cursor)        set[0].bind("<Leave>", self.reset_cursor)	set[0].bind("<1>", self.scanv_b1)	set[0].bind("<B1-Motion>", self.scanv_b1_drag)	set[0].bind("<ButtonRelease-1>", self.scanv_b1_up)	set[0].bind("Control-<1>", self.scanv_b1)	set[0].bind("<Control-B1-Motion>", self.scanv_b1_bigdrag)	set[0].bind("<Control-ButtonRelease-1>", self.scanv_b1_up)		    ##############################################################################    def unbind_mode_buttons(self, set):        set[1].unbind("<Enter>")        set[1].unbind("<Leave>")	set[1].unbind("<1>")	set[1].unbind("<B1-Motion>")	set[1].unbind("<ButtonRelease-1>")	set[1].unbind("Control-<1>")	set[1].unbind("Control-<B1-Motion>")	set[1].unbind("Control-<ButtonRelease-1>")	set[1].unbind("<2>")	set[1].unbind("<B2-Motion>")	set[1].unbind("<ButtonRelease-2>")	set[1].unbind("<3>")	set[1].unbind("<B3-Motion>")	set[1].unbind("<ButtonRelease-3>")## 	set[0].bind("<1>", self.tcanv_b1)## 	set[0].bind("<B1-Motion>", self.tcanv_b1_drag)## 	set[0].bind("<ButtonRelease-1>", self.tcanv_b1_up)## 	set[0].bind("Control-<1>", self.tcanv_b1)## 	set[0].bind("<Control-B1-Motion>", self.tcanv_b1_bigdrag)## 	set[0].bind("<Control-ButtonRelease-1>", self.tcanv_b1_up)        set[0].unbind("<Enter>")        set[0].unbind("<Leave>")	set[0].unbind("<1>")	set[0].unbind("<B1-Motion>")	set[0].unbind("<ButtonRelease-1>")	set[0].unbind("Control-<1>")	set[0].unbind("<Control-B1-Motion>")	set[0].unbind("<Control-ButtonRelease-1>")		    ##############################################################################    def bind_map_buttons(self, map):        map.bind("<Enter>", self.set_drag_cursor)        map.bind("<Leave>", self.reset_cursor)	map.bind("<1>", self.map_b1)	map.bind("Control-<1>", self.map_b1)	map.bind("<B1-Motion>", self.map_b1_drag)	map.bind("<Control-B1-Motion>", self.map_b1_alt_drag)	map.bind("<ButtonRelease-1>", self.map_b1_up)	map.bind("<Control-ButtonRelease-1>", self.map_b1_up)	    ##############################################################################    def unbind_map_buttons(self, map):        map.unbind("<Enter>")        map.unbind("<Leave>")	map.unbind("<1>")	map.unbind("Control-<1>")	map.unbind("<B1-Motion>")	map.unbind("Control-<B1-Motion>")	map.unbind("<ButtonRelease-1>")	map.unbind("Control-<ButtonRelease-1>")    ##############################################################################    def map_b1(self, ev):	c = ev.widget	x = ev.x	y = ev.y	c.xmark = x	c.ymark = y	c.plmark = c.pl	c.mark_set = 1        if self.disp.mode == 'time':            # scan mark can be arbitrary - 0,0 allows just to use mouse movement for drag            scanx = 0            scany = 0        else:            #scanx = self.trees[self.indx].gaps[self.disp.mi][3]            scanx = 0            scany = 0            self.disp.xmark = self.trees[self.indx].gaps[self.disp.mi][3]            	self.disp.scan_mark(scanx, scany)	self.disp.scroll_with.scan_mark(scanx, 0)	self.disp.mark_set = 1	    ##############################################################################    def map_b1_drag(self, ev):        self.map_b1_drag_common(ev, 0)	    ##############################################################################    def map_b1_alt_drag(self, ev):        self.map_b1_drag_common(ev, 1)	    ##############################################################################    def map_b1_drag_common(self, ev, ctrl):	c = ev.widget	d = self.disp	x = ev.x	y = ev.y	if c.mark_set:	    xdelta = x-c.xmark	    ydelta = y-c.ymark	    if d.mode == 'time':		# easy - linear x-scaling in main window		movex = int(xdelta/d.mxfact)	    else:		# non-linear - assume dragging lhs of port                gaps = self.trees[self.indx].gaps                if ctrl:                    li = d.mi                    c.xmark = x                    if xdelta != 0:                        li = min(max(li+xdelta, 0), len(gaps)-1)                    else:                        return                    movex = gaps[li][3] - d.xmark                    d.mi = li                    #print 'gap%d tm%d x%d movex%d' % (li, gaps[li][1]/1000, gaps[li][3], movex)                else:                    t = (x-d.mxoff)/d.mxfact                    try:                        li = d.find_gap_by_time(t, gaps, 0, len(gaps)-1,                                                np_Obtree.G_BEFORE)                    except NotInRange:                        li = d.mi                    movex = gaps[li][3] - d.xmark                    d.mi = li	    movey = int(ydelta/d.myfact)			    # dragto is 10x scaled - want 1:1 movement	    dmovex = -movex/10	    dmovey = -movey/10	    d.scan_dragto(dmovex, dmovey)	    d.scroll_with.scan_dragto(dmovex, 0)	    # set TLC by using canvas offsets	    d.tlc[0] = d.canvasx(0)	    d.tlc[1] = d.canvasy(0)	    d.draw_map_port(d)	    ##############################################################################	        def map_b1_up(self, ev):	ev.widget.mark_set = 0	ev.widget.mark_set = 0	self.disp.mark_set = 0    ##############################################################################    def scanv_b1(self, ev):	ev.widget = ev.widget.scroll_with	self.tcanv_b1(ev)		    ##############################################################################    def tcanv_b1(self, ev):	#set drag anchor	canv = ev.widget        if canv.mode != 'scale':            canv.config(cursor=(drag, 'orange'))	tcanv = canv.scroll_with	x = ev.x	y = ev.y	canv.scan_mark(x, y)	tcanv.scan_mark(x, 0) #want x-pan only	canv.mark_set = 1	canv.xmark = x	tcanv.xmark = x	canv.ymark = y	    ##############################################################################    def scanv_b1_drag(self, ev):	ev.widget = ev.widget.scroll_with	self.tcanv_b1_drag(ev)	    ##############################################################################    def tcanv_b1_drag(self, ev):	# pan following mouse	#print self	canv = ev.widget	tcanv = canv.scroll_with	x = ev.x	y = ev.y	if canv.mark_set:	    movex = (x-canv.xmark)/10	    movey = (y-canv.ymark)/10	    #print 'movex %d movey %d' % (movex, movey)	    canv.scan_dragto(canv.xmark+movex, 			     canv.ymark+movey)	    tcanv.scan_dragto(canv.xmark+movex, 0)	    canv.tlc[0] = canv.canvasx(x)-x	    canv.tlc[1] =  canv.canvasy(y)-y	    #print 'tlc = (%d, %d)' % (canv.canvasx(x)-x, canv.canvasy(y)-y) 	    canv.draw_map_port(canv)	    ##############################################################################    def scanv_b1_bigdrag(self, ev):	ev.widget = ev.widget.scroll_with	self.tcanv_b1_bigdrag(ev)	    ##############################################################################    def tcanv_b1_bigdrag(self, ev):	# pan following mouse	canv = ev.widget	tcanv = canv.scroll_with	x = ev.x	y = ev.y	if canv.mark_set:	    canv.scan_dragto(x, y)	    tcanv.scan_dragto(x, 0)	    canv.tlc[0] = canv.canvasx(x)-x	    canv.tlc[1] =  canv.canvasy(y)-y	    #print 'tlc = (%d, %d)' % (canv.canvasx(x)-x, canv.canvasy(y)-y) 	    canv.draw_map_port(canv)##############################################################################	        def scanv_b1_up(self, ev):	#ev.widget.config(cursor=(''))	ev.widget = ev.widget.scroll_with	self.tcanv_b1_up(ev)##############################################################################	        def tcanv_b1_up(self, ev):        c = ev.widget        if c.mode != 'scale':            c.config(cursor=(ccross, 'orange'))	c.mark_set = 0	    ##############################################################################    def tcanv_b2(self, ev):        self.tcanv_b2_common(ev)            def tcanv_shft_b2(self, ev):        self.tcanv_b2_common(ev)            def tcanv_ctr_b2(self, ev):        self.tcanv_b2_common(ev)        def tcanv_b2_common(self, ev):        	canv = ev.widget	x = canv.canvasx(ev.x)	y = canv.canvasy(ev.y)	#print 'B1 %d, %d' % (x, y)	canv.startx=x	canv.starty=y	canv.rbox = None    def tcanv_b2_drag(self, ev):        self.tcanv_b2_drag_common(ev)    def tcanv_shft_b2_drag(self, ev):        self.tcanv_b2_drag_common(ev)    def tcanv_ctr_b2_drag(self, ev):        self.tcanv_b2_drag_common(ev)    def tcanv_b2_drag_common(self, ev):    	# draw selection box	canv = ev.widget	x = canv.canvasx(ev.x)	y = canv.canvasy(ev.y)	#print 'B1D %d, %d Start %d %d' % (x, y, canv.startx, canv.starty)	if (canv.startx != x)  and (canv.starty != y) : 	    canv.delete(canv.rbox)	canv.rbox = canv.create_rectangle(	    canv.startx, canv.starty, x, y, outline='blue')	        def tcanv_b2_up(self, ev):        self.tcanv_b2_up_common(ev, '')	        def tcanv_shft_b2_up(self, ev):        self.tcanv_b2_up_common(ev, 'shift')	        def tcanv_ctr_b2_up(self, ev):        self.tcanv_b2_up_common(ev, 'ctrl')            def tcanv_b2_up_common(self, ev, mod):	# identify TCP connection(s) selected and fire up connection info	canv = ev.widget	canv.delete(canv.rbox)        # allow for click without dragged box	x = max(canv.canvasx(ev.x), canv.startx+canv.tree.connht/2)	y = max(canv.canvasy(ev.y), canv.starty+canv.tree.connht/2)

⌨️ 快捷键说明

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