'Can't Pass Textual Inputs to Wesocket Client and store response

I am trying to send and receive web socket data using my Client.py file. I am also trying to load the prompts ("Username?") into the Feeler console and have input from InConsole stored in the username variable in the Client.py file. So far I have been unable to make this setup work.

What is the most efficient way for me to accomplish this task?

I have the following code in Feeler.py

    ... 
def Message(output):

    message = Client.main(output)
    return message

    class OutConsole(ScrollView):
        prev = Text("")
    
        async def eval(self, text_input):
            pre_y = self.y
            with console.capture() as capture:
                try:
                    console.print(f"{text_input}")
                except Exception:
                    console.print_exception(show_locals=True)
            self.prev.append(Text.from_ansi(capture.get() + "\n"))
            await self.update(self.prev)
            self.y = pre_y
            self.animate("y", self.window.virtual_size.height, duration=1, easing="linear")
    
    
    class InConsole(TextInput):
        def __init__(self, out):
            super(InConsole, self).__init__()
            self.out = out
    
        async def on_key(self, event: events.Key) -> None:
            if event.key == "enter":
                await self.out.eval(self.value)
                self.value = ""
    
    
    class GridTest(App):
        
        async def on_mount(self) -> None:
            """Make a simple grid arrangement."""
    
            # Git code
            output = OutConsole()
            in_put = InConsole(out=output)
            
            message = Message(output)
            
            await output.eval(message)
    ...

I also Have this in Client.py

 def main():
    # Define the host IP and port for the server
    HOST = socket.gethostname()
    PORT = 5050


    # Ask For initial username and password

    return ("Username?")
    username = input(">")

    return ("Password?")
    password = getpass.getpass(f"{username}> ")

The rest of my code can be found at https://github.com/DanielATucker/Brain/tree/Client for reference.

Thanks!



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source