Hey everyone, I'm a beginner Python and PyGTK developer so sorry for the stupid question.I have a class named Client which is meant to send data to a server via UDP socket. here is a snippet of the Code: class Client: # Set the socket parameters addr = ('','') UDPSock = socket(AF_INET,SOCK_DGRAM) # callback for getting the IP address def connect_callback(self, widget, entry): hostName = entry.get_text() addr = (hostName,21567) #callback to send the message in the testfield def send_mesg_callback(self, widget, textfield): t_msg = textfield.get_buffer() if(UDPSock.sendto(t_msg,addr)): print "Sending message '",t_msg,"'....." ... I get undeclared global variable error for addr and UDPSock. But I can't access my global variables it gives me an error, even when I put a 'self.' infront of the global variables for example infront of UDPSOCK. what am i doing wrong here? -Thank you
class Client: # Set the socket parameters addr = ('','') UDPSock = socket(AF_INET,SOCK_DGRAM) # callback for getting the IP address def connect_callback(self, widget, entry): hostName = entry.get_text() addr = (hostName,21567) #callback to send the message in the testfield def send_mesg_callback(self, widget, textfield): t_msg = textfield.get_buffer() if(UDPSock.sendto(t_msg,addr)): print "Sending message '",t_msg,"'....." ...