Before you start writing any code you need to have an 'environment' set up on your computer. Don't rush this part, as it can cause problems later down the track.
Tkinter and Python work on all these OSes. You don't need a powerful computer either. There are some differences though in setting up each of these. You may need to do your own research and learning to get things working on your machine.
- In these videos we will be using Python version 3.10 (latest version in 2022)
- Download Python from python.org
- Install it on your machine
There are lots of code editors you can use to write your software. In this series I am going to use VS Code. You can use whatever you like, but if you are not sure, VS Code is powerful and pretty easy to get started with.
- Download and install Visual Studio Code
- Once it is installed, run it to open the editor and start exploring
An editor should make writing code easy and fun. You want to think about your ideas and code, not how to use the software to write your code. Spend some time getting used to the editor and setting it up for yourself so that you have a smooth and simple workflow going.
- Now we will install some extensions. Click on the Extensions icon in the left Activity Bar

- Search for and install some extensions to help you write your code and work with python. Only the first one is a must install, the others are good but up to you:
- Python
- this will also install other extensions automatically
- indent-rainbow - helps with understanding python's indentation requirements
- Rainbow Brackets - helps to see pairs of brackets
- autoDocstring - helps to write internal documentation
- GitHub Pull Requests and Issues - if you want to use github with VS Code
- vscode-icons - an icon theme
- Tkinter Snippets - helps with writing your code
- Python
- Click on the cog icon in the bottom left and choose Colour Theme, then pick the one you like from the list
- Click on the cog icon in the bottom left and choose File Icon Theme, then pick VSCode Icons from the list
In VS Code it is important to have all your code and files together in one directory to make things easier for you when you are learning. Don't just download code files and open them from your downloads folder. Move everything into your working folder and keep it organised.
- From the File menu choose the Open Folder option
- Navigate to the location where you want to store your working folder. It could be on your desktop, in your documents or on another drive. Pick a location and use it consistently. I use Documents
- Create a new folder here to store your code and files. Give it a simple name without spaces. Something like snappytk
- Click on the new folder and then the Select Folder button to open this folder as your base working folder in VS Code
When building applications with Python it is a good idea to use a virtual environment approach. This just keeps things consistent and separated from any other projects you may be working on. It also makes repeating the environment you used to create your software on a new machine easy.
For more information on the why, what, how of using python virtual environments, read more at this link.
- Open a New Terminal window from the Terminal menu option
- Depending on your OS you will use a different command such as:
- Mac: python3 -m venv .snappytk
- Windows: python -m venv .snappytk
- Wait a moment for the command to complete
- You should now see a .snappytk folder appear in your folder list in VS Code like the pic below

Now that you have software installed and setup, it is time to test to see if it all works!
- Create a new file called hello_world.py
- Make sure it is not in the .snappytk folder but outside this. I put mine in a code folder like in this pic

- You should now be able to type your code in the new hello_world.py in the editor window
- Type in the code below and save your file:
print("Hello, World!") - Run your code from the Run menu, or use the the 'play' arrow in the upper right of the editor window to run the python file.
- You should see the message Hello, World! print out in the terminal window that appears at the bottom of the screen.
When we ran the code before we most likely were using the default python interpreter. This is not using our virtual environment that we created! We need to change to it and try running the code again.
- Use the keyboard shortcut Ctl+Shift+p on Windows or Cmd+Shift+p on Mac to open the Command Palette
- Type Select Interpreter into the search box and choose the option '.snappytk': venv to use the virtual environment you created
- In the terminal window below the editor, click the trash can icon to remove the current terminal window
- Run your code again and a new terminal will appear. This time you should see (.snappytk) at the front of some of the lines to tell you that you are using the virtual environment's version of python
- Great work!
If you see a powershell error about not being able to 'activate' the virtual environment, run the line of code below in the powershell terminal and then try to run your python code again.
Set-ExecutionPolicy -ExecutionPolicy Unrestricted -Scope CurrentUser
Did you get it all working? Give yourself a pat on the back for getting through the setup.
Perseverance is an important skill to work on as you grow and hone your software development skills. No matter how much experience you have there are always problems you have to overcome.
Now go and explore VS Code some more. I recommend learning some of the keyboard shortcuts, installing any more extensions you find you want to try, or just checking out the interface and hovering and clicking on things!
