You can find the corresponding code for this session here: https://github.com/lennemo09/COMP1010-Fall2023-GUI-Lecture
First you need to make sure you have installed the following dependencies in your Python environment:
tk
(Tkinter)Pillow
(PIL)requests
For how to install pip packages with PyCharm, please see the following video:
https://youtu.be/C7U51qQ2scA?si=fY3CzHY_WPaJhGtl
If you’re using the command line interface (CLI) like Terminal for MacOS or Command Prompt/PowerShell for Windows, install the required packages with pip
:
pip install tk
pip install requests
pip install Pillow
If pip
is not a known command on your system, try again using:
python3 -m pip install tk
python3 -m pip install requests
python3 -m pip install Pillow
If you’re using conda
, use the following commands:
conda install tk
conda install requests
conda install Pillow
Before we get started, create a new Python file with the following lines and run it.
import tkinter as tk
from tkinter import ttk
import requests
from PIL import Image, ImageTk
from io import BytesIO
If the code runs without any errors, we’re good to go!
<aside> 💡 What is an “API”?
</aside>