代码拉取完成,页面将自动刷新
同步操作将从 gfdgd xi/Wine 运行器 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
#!/usr/bin/env python3
# 使用系统默认的 python3 运行
#################################################################################################################
# 作者:gfdgd xi
# 版本:2.5.0
# 更新时间:2022年11月20日
# 感谢:感谢 wine、deepin-wine 以及星火团队,提供了 wine、deepin-wine、spark-wine-devel 给大家使用,让我能做这个程序
# 基于 Python3 的 PyQt5 构建
#################################################################################################################
#################
# 引入所需的库
#################
import os
import sys
import traceback
import updatekiller
import PyQt5.QtGui as QtGui
import PyQt5.QtCore as QtCore
import PyQt5.QtWidgets as QtWidgets
desktopList = []
desktopUsrList = []
def GetDesktopList(path):
for i in os.listdir(path):
if os.path.isdir(f"{path}/{i}"):
GetDesktopList(f"{path}/{i}")
if os.path.isfile(f"{path}/{i}"):
try:
desktop = {}
with open(f"{path}/{i}") as file:
things = file.read()
for k in things.splitlines():
if not "=" in k:
continue
desktop[k[:k.index("=")].lower()] = k[k.index("=") + 1:]
desktopList.append([desktop["Name".lower()], desktop["Icon".lower()], desktop["Exec".lower()], f"{path}/{i}"])
except:
traceback.print_exc()
delButton.setEnabled(len(desktopList))
class DesktopList(QtCore.QThread):
show = QtCore.pyqtSignal(int)
def __init__(self) -> None:
super().__init__()
def run(self):
if os.path.exists(f"{homePath}/.local/share/applications"):
GetDesktopList(f"{homePath}/.local/share/applications")
self.show.emit(0)
def ShowDesktop(temp):
nmodel = QtGui.QStandardItemModel(window)
if not len(desktopList):
item = QtGui.QStandardItem("无")
nmodel.appendRow(item)
y = 0
for i in desktopList:
#item = QtGui.QStandardItem(QtGui.QIcon(i[1]), i[0])
#nmodel.appendRow(item)
if os.path.exists(i[1]):
nmodel.setItem(y, 0, QtGui.QStandardItem(QtGui.QIcon(i[1]), i[0]))
else:
nmodel.setItem(y, 0, QtGui.QStandardItem(QtGui.QIcon.fromTheme(i[1]), i[0]))
nmodel.setItem(y, 1, QtGui.QStandardItem(i[2]))
nmodel.setItem(y, 2, QtGui.QStandardItem(i[3]))
y += 1
nmodel.setHeaderData(0, QtCore.Qt.Horizontal, "程序名")
nmodel.setHeaderData(1, QtCore.Qt.Horizontal, "运行路径")
nmodel.setHeaderData(2, QtCore.Qt.Horizontal, ".desktop 文件所在路径")
nmodel.setColumnCount(3)
desktopListView.setModel(nmodel)
def GetDesktopThread():
global desktop
desktop = DesktopList()
desktop.show.connect(ShowDesktop)
desktop.start()
def DeleteButton():
index = desktopListView.currentIndex().row()
if index < 0:
QtWidgets.QMessageBox.critical(window, "错误", "未选中任何项")
return
print(index)
print(desktopList[index][3])
#desktopListView.rowMoved(index)
#desktopListView.removeRow(index)
try:
os.remove(desktopList[index][3])
del desktopList[index]
ShowDesktop(0)
except:
traceback.print_exc()
QtWidgets.QMessageBox.critical(window, "错误", traceback.format_exc())
programPath = os.path.split(os.path.realpath(__file__))[0] # 返回 string
homePath = os.getenv("HOME")
iconPath = "{}/deepin-wine-runner.svg".format(programPath)
#GetDesktopList(f"{homePath}/.local/share/applications")
#print(desktopList)
app = QtWidgets.QApplication(sys.argv)
window = QtWidgets.QMainWindow()
widget = QtWidgets.QWidget()
layout = QtWidgets.QGridLayout()
delButton = QtWidgets.QPushButton("删除指定图标")
delButton.clicked.connect(DeleteButton)
#desktopListView = QtWidgets.QListView()
desktopListView = QtWidgets.QTableView()
desktopListView.setEditTriggers(QtWidgets.QAbstractItemView.NoEditTriggers)
desktopListView.setSelectionBehavior(QtWidgets.QAbstractItemView.SelectRows)#(QAbstractItemView::SelectRows)
layout.addWidget(desktopListView, 0, 0, 1, 4)
layout.addWidget(delButton, 1, 3, 1, 1)
widget.setLayout(layout)
window.setCentralWidget(widget)
window.setWindowTitle("图标管理")
window.resize(int(window.frameGeometry().width() * 1.5), int(window.frameGeometry().height() * 1.2))
window.setWindowIcon(QtGui.QIcon(f"{programPath}/deepin-wine-runner.svg"))
window.show()
GetDesktopThread()
app.exec_()
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。