Successfully import ttkbootstrap and run it on Ubuntu20.04

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.
ttkbootstrap demo

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.
Widgets in tkinter
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)
widgets in ttkbootstrap
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.
file
Decompress and enter it.

tar xvzf v1.7.3.tar.gz.tar.gz
cd ttkbootstrap-1.7.3
ls

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.

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值