注意:python版本必须是python3.10以上才能运行.
1.前言:
在高版本Xubuntu22.04安装有道词典后,启动时,界面无法启动,通过手动启动后,发现以下报错log。
# youdao-dict
File "/usr/share/youdao-dict/app/plugins/youdao/window.py", line 288, in showCenter
self.setX(x)
File "/usr/share/youdao-dict/dae/window.py", line 644, in showCenter
self.move(x, y)
TypeError: arguments did not match any overloaded call:
move(self, QPoint): argument 1 has unexpected type 'float'
move(self, int, int): argument 1 has unexpected type 'float'
提示:
从上边的log看出,有道词典的是因为需要传入的使int类型,但实际给的是float类型,需要作下手动转换下类型。
本质原因是高版本的python版本导致的,因为有道词典调用的api比较老的缘故。
2.解决
1.创建待用目录
# mkdir -p youdao/DEBIAN
2.解压.deb
# dpkg -X youdao-dict_6.0.0-ubuntu-amd64.deb youdao
3.解压deb包中的control信息
# dpkg -e youdao-dict_6.0.0-ubuntu-amd64.deb youdao/DEBIAN
4.修改代码
<1>.float转int类型
usr/share/youdao-dict/app/plugins/youdao/window.py
def showCenter(self):
# show center
desktop = QtWidgets.qApp.desktop()
geometry = desktop.screenGeometry(desktop.primaryScreen())
x = geometry.x() + (geometry.width() - self.width())/2
y = geometry.y() + (geometry.height() - self.height())/2
+ self.setX(int(x))
+ self.setY(int(y))
self.show()
<2>.float转int类型
usr/share/youdao-dict/dae/window.py
def showCenter(self):
screen = qApp.primaryScreen()
geometry = screen.availableGeometry()
x = geometry.x() + (geometry.width() - self.width())/2
y = geometry.y() + (geometry.height() - self.height())/2
+ self.move(int(x), (y))
self.show()
5.重新打包
# dpkg -b debin/ youdao.deb
6.卸载已安装.deb包
# sudo dpkg -r youdao-dict
7.重新安装
# sudo dpkg -i youdao.deb
3.运行图示
Enjoy it!!!