CATALOGUE
What is ttkbootstrap?
Ttkbootstrap is a supercharged theme extension for tkinter that enables on-demand modern flat style themes inspired by Bootstrap.
And you don’t need to use ttkbootstrap at the beginning of the project.Ttkbootstrap provides lots of ways for you to easily convert from Tkinter to Ttkbootstrap.
How to verify that you have successfully installed ttkbootstrap?
Use the following teminal command to check whether ttkbootstrap is already installed.
python3 -m ttkbootstrap
If the following demo appears,it means your installation is successful.
Step 1:First,check your python version
Ttkbootstrap is based on tkinter.And in most cases,tkinter is installed along with python.If your python doesn’t have tkinter,use the following terminal command.It is suitable for Ubuntu and else debian-based Linux.
sudo apt-get install python3-tk
Then you can find the folder ‘tkinter’ in your Python root diectory.For me,it is located at “/usr/lib/python3.8/tkinter”.
Enter this folder and open the file “ttk.py”.At the top of this document,you can see the author has defined many widgets.
All of these widgets will be referenced in ttkbootstrap.(/usr/local/lib/python3.8/dist-packages/ttkbootstrap-1.7.3-pt3.8.egg/ttkbootstrap/widgets.py)
In my test,the python version installed on ubuntu 20.04 is 3.8.10.If your ubuntu version is below 20.04,for example 18.04.Then the python version you installed directly is 3.6.This version of python misses some widgets.So your ttkbootstrap can’t work properly.There will be kind of “no moudle named Spinbox” or other problems.
So,make sure that your python version is higher than 3.8.10.I don’t know if 3.7 series could operate.But 3.8.10 is safe.
In addition to this, up to now my ttkbootstrap version is 1.7.3.So abstractly you can also reduce your ttkbootstrap version to match the python version.But that hasn’t been tested by me.
ps:If your ubuntu version below 20.04,you can also install python with version higher than 3.6.But it might be more convoluted.So if you are not a professor,just give up upgrading your python on lower ubuntu version and try to upgrade your ubuntu version.
Step 2:Download the ttkbootstrap
It’s more easier to download the ttkbootstrap on windows system.You can get ttkbootstrap by using just one terminal command.
For linux,you can get ttkbootstrap in a couple of ways.You can just download it on its github by clicking here.
Or using following terminal command.
wget https://github.com/israel-dryer/ttkbootstrap/archive/refs/tags/v1.7.3.tar.gz
Then you can find it at the location where you executed the command.
Decompress and enter it.
tar xvzf v1.7.3.tar.gz.tar.gz
cd ttkbootstrap-1.7.3
ls
Step 3:Install the ttkbootstrap
Our next step is to use this file ‘setup.py’ to install.
sudo python3 setup.py build
sudo python3 setup.py install
Then our installation is complete.
But some people might meet this problem importerror No Module named “Setuptools”.
It means,your setup.py file needs setuptools. Some python packages used to use distutils for distribution, but most now use setuptools, a more complete package.
To install setuptools on Debian:
sudo apt-get install python3-setuptools
Make sure your python version is higher than 3.8.10 or equal.Otherwise the above command will not work properly too.
Now using the same way at the beginning of this article test your installation.