Python Forum
A dynamically updating GUI screen from URL
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
A dynamically updating GUI screen from URL
#20
(Apr-17-2019, 06:32 PM)Alfalfa Wrote: The error is caused by the indentation, simply remove "@QtCore.pyqtSlot()" which is useless there, and reduce the indentation of lines 14 and 15 so it is coherent with the rest of your code.

import sys, time, socket
from PyQt5 import QtWidgets, QtCore
HOST = '192.168.1.38'  # The server's hostname or IP address, NodeMCU IP Address
PORT = 80              # The port used by the server, PORT NUMBER in ARDUINO CODE

class WorkerThread(QtCore.QObject):
    signal = QtCore.pyqtSignal(int)
 
    def __init__(self):
        super().__init__()

    with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s:
         s.connect((HOST, PORT))
         s.sendall(b'Hello, world')

    def run(self):
        while True:
            data = s.recv(1024)  
            print('Received distance value', repr(data)) 
            self.signal.emit(int(data))   
        
Error:
Traceback (most recent call last): File "c:/Users/User/Desktop/PYQT/work_1.py", line 20, in run data = s.recv(1024) NameError: name 's' is not defined
I tried Huh
Reply


Messages In This Thread
RE: A dynamically updating GUI screen from URL - by bescf - Apr-18-2019, 12:55 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  A dynamically updating screen for PyQt GUI from URL bescf 0 2,675 Mar-25-2019, 06:58 AM
Last Post: bescf

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020