准备用python3做图形界面的开发,了解有如下几种工具:
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# touch tkinter_demo.py
#!/usr/bin/python3
# -*- coding: UTF-8 -*-
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的第一个窗口程序。
更多回帖