Docs - Examples
A few code examples are provided with the library code. Here you’ll find a step-by-step explanation of each one.
You can get the code for all the examples at the GitHub repo.
In this section
- tally: Quick tally indicator.
- tally-str: A different (maybe easier) way to access tally information.
- ping: Check if your switcher is alive (ping-like).
- scan: Scan a network for ATEM switchers.
- scan-query: Scan a network for ATEM switchers and show some settings.
- change-settings: Change some settings on a switcher.
- change-settings-multi: Change some settings on multiple switchers at once.
- events: Using
PyATEMMax
’s events. - scheduled-tasks: A more elaborate example, including scheduled tasks.
Running the examples
If you haven’t installed the library you will need to copy the library code into the examples folder before running the examples:
A better option, which you will need if you want to modify PyATEMMax
’s code, is to create a symbolic link:
Hey! There’s strange code in the examples!
In order to provide some level of Type Checking and make it easier to not mix variable types, this code uses Python Type Hints (PEP 484).
This can make the code look a little strange if you’re used to the classic Python. As an example, in scheduled-tasks.py
you can find this function:
This is equivalent to:
… but includes a couple hints that can help your code editor warn you if you’re using a wrong variable type somewhere.
If you don’t know what linting
is or you don’t want to know, you can safely ignore it, you don’t have to write your code like this.
Common structure in all/most examples
The usual format in these example scripts follows::
- the necessary
import
statements for the script
- welcome message
- constant initialization for the script
- read of command line arguments
- after all this initialization the
ATEMMax
object is usually created
- at some point the script will tell the
ATEMMax
object to connect
- after calling
connect()
it’s usual to wait for the connection to be established
- and then, after doing its stuff the script normally closes the
ATEMMax
object
Having this in mind, the step-by-step explanations will omit detail in these initialization sections, as
- they are (more or less) the same in all the examples.
- they do stuff with other Python libraries.
Stripped down (no-nonsense) versions
Some examples include a stripped down version which removes all non-essential clutter:
- Command line argument management.
- Console messages.
- Fancy constants.
- Shebangs and Python source encoding marks.
- Docstrings.
While the full examples could even serve as a general CLI utilities, the stripped down versions are more likely what someone will build as a quickScript to solve a problem at hand. If you always connect to the same switcher (more likely than not) you will not need code to get the IP address from the command line, etc.