How do I pass a string from a Form to my code running on my client?

Total noob with Python so be gentle.

I am running selenium on my machine via the uplink and call specific functions based on button clicks. Is it possible to pass a string from the form to my local machine? I’m not seeing it, but it may be right in front of my face.

Thanks!

Welcome, @mark1!

It’s not built in to Python, but Anvil makes it pretty easy!

The general idea comes from here: Calling server functions from client code. You can pass parameters to an Uplink function, just as you would pass them to a Server-side function.

The difference is in where you place the called function. You still mark it as @anvil.server.callable, but you place it in your Uplink module, as shown in Calling functions remotely.

Note that the Uplink program must be active, running, in order to respond.

Edit: a bit about Anvil naming conventions:

  1. “Client” usually means your Anvil code, running in someone’s web browser.
  2. “Server” usually means your Anvil code, running on one of Anvil’s server machines.
  3. “Uplink” usually means your Anvil code, running on one of your own PCs, in a stand-alone Python interpreter.

None of these locations shares memory with any other. Information is passed to and fro via function calls. (And the Client can’t receive a function call, it can only make calls.)

So your title says “my client”, but your message says “via uplink”. I’m assuming you mean bullet 3, not bullet 1.

1 Like