I created a Python plugin in QGIS & when i am running my plugin it printing the data on python console. But i want that when i run my plugin it will print the data on QGIS map canvas. How can i do this? Here is my run method which is going to print lat/long per second on Map Canvas. you just tell me how can i get lat/long on Map Canvas instead of printing it in python console. Remember Python version 3.6 QGIS version 3.2 & this code working fine no error

def run(self):
    """Run method that performs all the real work"""

    PORT_NUMBER = 5000
    SIZE = 1024

    hostName = gethostbyname('')

    mySocket = socket(AF_INET, SOCK_DGRAM)
    mySocket.bind((hostName, PORT_NUMBER))

    print ("Test server listening on port {0}\n".format(PORT_NUMBER))
    print ("Hi i am linux computer")

    while True:
        (data, addr) = mySocket.recvfrom(SIZE)
        print (data)

    # Run the dialog event loop
    result = self.dlg.exec_()
    # See if OK was pressed

    if result:
        # Do something useful here - delete the line containing pass and
        # substitute with your code.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.