Пример #1
0
    def __init__(self, parent=None, **kw):
        Frame.__init__(self, parent, **kw)

        self.sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
        self.sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
        self.sock.bind((App.UDP_IP, App.UDP_PORT))
        self.sock.settimeout(0.0)

        self.menubar = Menu(tk)
        filemenu = Menu(self.menubar, tearoff=0)
        filemenu.add_command(label="Update", command=self.update)
        filemenu.add_separator()
        filemenu.add_command(label="Exit", command=tk.destroy)
        self.menubar.add_cascade(label="File", menu=filemenu)
        tk.config(menu=self.menubar)
        self.grid_rowconfigure(0, minsize=600)
        self.mlb = MultiListbox(tk, (('Address', 20), ('Source Port', 20),
                                     ('Message', 40)))
        self.mlb.config(height=600)
        self.mlb.grid(sticky=N + S + E + W,
                      row=0,
                      column=0,
                      columnspan=2,
                      rowspan=2)

        self.data = self.addr = self.port = 0
Пример #2
0
class App(Frame):
    UDP_IP = ""
    UDP_PORT = 51234

    def __init__(self, parent=None, **kw):
        Frame.__init__(self, parent, **kw)

        self.sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
        self.sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
        self.sock.bind((App.UDP_IP, App.UDP_PORT))
        self.sock.settimeout(0.0)

        self.menubar = Menu(tk)
        filemenu = Menu(self.menubar, tearoff=0)
        filemenu.add_command(label="Update", command=self.update)
        filemenu.add_separator()
        filemenu.add_command(label="Exit", command=tk.destroy)
        self.menubar.add_cascade(label="File", menu=filemenu)
        tk.config(menu=self.menubar)
        self.grid_rowconfigure(0, minsize=600)
        self.mlb = MultiListbox(tk, (('Address', 20), ('Source Port', 20),
                                     ('Message', 40)))
        self.mlb.config(height=600)
        self.mlb.grid(sticky=N + S + E + W,
                      row=0,
                      column=0,
                      columnspan=2,
                      rowspan=2)

        self.data = self.addr = self.port = 0
        #self._update()

    def update(self):
        readable, writable, errs = select.select([self.sock], [], [], 0.1)
        ##print len(readable)
        for item in readable:
            if item is self.sock:
                data, (addr, port) = self.sock.recvfrom(1024)
                print "Data Processing"
                self.process(data, addr, port)
        self._timer = self.after(100, self.update)

    def process(self, data, addr, port):
        print "Process Begun"
        if data == "":
            tkMessageBox.showwarning(
                "No Data", "No data file has been selected.\nPlease Open one.")
            return
        ##self.mlb.delete(0,last='end')
        self.mlb.insert(END, (addr, port, data))
Пример #3
0
 def __init__(self,parent=None,**kw):
     Frame.__init__(self,parent,**kw)
     
     self.sock = socket.socket( socket.AF_INET,socket.SOCK_DGRAM )
     self.sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
     self.sock.bind((App.UDP_IP,App.UDP_PORT))
     self.sock.settimeout(0.0)
     
     self.menubar = Menu(tk)
     filemenu = Menu(self.menubar, tearoff=0)
     filemenu.add_command(label="Update", command=self.update)
     filemenu.add_separator()
     filemenu.add_command(label="Exit", command=tk.destroy)
     self.menubar.add_cascade(label="File",menu=filemenu)
     tk.config(menu=self.menubar)
     self.grid_rowconfigure(0,minsize=600)
     self.mlb = MultiListbox(tk, (('Address', 20),('Source Port', 20), ('Message', 40)))
     self.mlb.config(height=600)
     self.mlb.grid(sticky=N+S+E+W,row=0,column=0,columnspan=2,rowspan=2)
     
     self.data = self.addr = self.port = 0
Пример #4
0
class App(Frame):
    UDP_IP=""
    UDP_PORT=51234

    
    def __init__(self,parent=None,**kw):
        Frame.__init__(self,parent,**kw)
        
        self.sock = socket.socket( socket.AF_INET,socket.SOCK_DGRAM )
        self.sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
        self.sock.bind((App.UDP_IP,App.UDP_PORT))
        self.sock.settimeout(0.0)
        
        self.menubar = Menu(tk)
        filemenu = Menu(self.menubar, tearoff=0)
        filemenu.add_command(label="Update", command=self.update)
        filemenu.add_separator()
        filemenu.add_command(label="Exit", command=tk.destroy)
        self.menubar.add_cascade(label="File",menu=filemenu)
        tk.config(menu=self.menubar)
        self.grid_rowconfigure(0,minsize=600)
        self.mlb = MultiListbox(tk, (('Address', 20),('Source Port', 20), ('Message', 40)))
        self.mlb.config(height=600)
        self.mlb.grid(sticky=N+S+E+W,row=0,column=0,columnspan=2,rowspan=2)
        
        self.data = self.addr = self.port = 0
        #self._update()
        
    def update(self):
        readable,writable,errs = select.select([self.sock],[],[],0.1)
        ##print len(readable)
        for item in readable:
            if item is self.sock:
                data,(addr,port) = self.sock.recvfrom(1024)
                print "Data Processing"
                self.process(data,addr,port)
        self._timer = self.after(100,self.update)
    def process(self,data,addr,port):
        print "Process Begun"
        if data=="":
            tkMessageBox.showwarning("No Data","No data file has been selected.\nPlease Open one.")
            return
        ##self.mlb.delete(0,last='end')
        self.mlb.insert(END, (addr,port,data))  
Пример #5
0
    tk.minsize(width=400, height=400)

    menubar = Menu(tk)

    filemenu = Menu(menubar, tearoff=0)
    filemenu.add_command(label="Open Format", command=open_format)
    filemenu.add_command(label="Open Data", command=open_data)
    filemenu.add_command(label="Export", command=export)
    filemenu.add_separator()
    filemenu.add_command(label="Exit", command=tk.destroy)

    menubar.add_cascade(label="File", menu=filemenu)
    #menubar.add_command(label="Process",command=process)
    tk.config(menu=menubar)

    mlb = MultiListbox(tk, (('Field Name', 40), ('Type', 20), ('Data', 20)))
    mlb.pack(expand=YES, fill=BOTH)

    format_file = Label(tk, text="Format:", relief="ridge", justify='left')
    format_file.pack(side="left", fill=X, expand=1)

    data_file = Label(tk, text="Data:", relief="ridge", justify='left')
    data_file.pack(side="right", fill=X, expand=1)

    formatname = "Format: " + os.path.basename(format_filename)
    format_file.config(text=formatname)
    if format_filename:
        process_format()

    dataname = "Data: " + os.path.basename(data_filename)
    data_file.config(text=dataname)
Пример #6
0
    tk.minsize(width=400,height=400)
    
    menubar = Menu(tk)
    
    filemenu = Menu(menubar, tearoff=0)
    filemenu.add_command(label="Open Format", command=open_format)
    filemenu.add_command(label="Open Data", command=open_data)
    filemenu.add_command(label="Export", command=export)
    filemenu.add_separator()
    filemenu.add_command(label="Exit", command=tk.destroy)
    
    menubar.add_cascade(label="File",menu=filemenu)
    #menubar.add_command(label="Process",command=process)
    tk.config(menu=menubar)
    
    mlb = MultiListbox(tk, (('Field Name', 40),('Type', 20), ('Data', 20)))
    mlb.pack(expand=YES,fill=BOTH)

    format_file = Label(tk,text="Format:",relief="ridge",justify='left')
    format_file.pack(side="left",fill=X,expand=1)
    
    data_file = Label(tk,text="Data:",relief="ridge",justify='left')
    data_file.pack(side="right",fill=X,expand=1)

    formatname = "Format: " + os.path.basename(format_filename)
    format_file.config(text=formatname)
    if format_filename:
        process_format()

    dataname = "Data: " + os.path.basename(data_filename)
    data_file.config(text=dataname)