准备用python3做图形界面的开发,了解有如下几种工具:
- Tkinter :是python最简单的图形化模块,总共只有14种组建;
- Pyqt :是python最复杂也是使用最广泛的图形化;
- Pyside:好象是替代pyqt;
- Wx :是python当中居中的一个图形化,学习结构很清晰
- Pywin :是python windows 下的模块,摄像头控制(opencv),常用于外挂制作;
原来用过pyqt5\pyside2\pyside5。
由于这几天安装都比较麻烦。所以这次用tkinter来做。
用pip3 install tkinter是安装不了的。要使用apt install python3-tk来安装:
forlinx@ok3568:~$ sudo apt install python3-tk
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following packages were automatically installed and are no longer required:
libpython2-stdlib libpython2.7-minimal libpython2.7-stdlib python2
python2-minimal python2.7 python2.7-minimal
Use 'sudo apt autoremove' to remove them.
Suggested packages:
tix python3-tk-dbg
The following NEW packages will be installed:
python3-tk
0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded.
Need to get 104 kB of archives.
After this operation, 911 kB of additional disk space will be used.
Get:1 http://ports.ubuntu.com/ubuntu-ports focal-updates/main arm64 python3-tk arm64 3.8.10-0ubuntu1~20.04 [104 kB]
Fetched 104 kB in 2s (50.6 kB/s)
Selecting previously unselected package python3-tk:arm64.
......
(Reading database ... 239683 files and directories currently installed.)
Preparing to unpack .../python3-tk_3.8.10-0ubuntu1~20.04_arm64.deb ...
Unpacking python3-tk:arm64 (3.8.10-0ubuntu1~20.04) ...
Setting up python3-tk:arm64 (3.8.10-0ubuntu1~20.04) ...
这样python3 tkinter就安装成功了。注意不要用apt install python-tk,这样就会安装给python2.7的tkinter。
测试一下:
forlinx@ok3568:~$ dpkg --list | grep python3-tk
ii python3-tk:arm64 3.8.10-0ubuntu1~20.04 arm64 Tkinter - Writing Tk applications with Python 3.x
新建一个测试程序:
root@ok3568:~/Documents
import tkinter
top=tkinter.Tk(className='飞凌OK3568')
label = tkinter.Label(top)
label['text'] = '电子发烧友、飞凌OK3568进行python测试'
button = tkinter.Button(top)
button['text'] = '点一下'
button.pack()
label.pack()
top.mainloop()
然后python3 tkinter_demo.py就启动了飞凌OK3568的第一个窗口程序。