初步Qt迁移
This commit is contained in:
@@ -1,15 +1,14 @@
|
|||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python3
|
||||||
import os
|
import os
|
||||||
|
import sys
|
||||||
import json
|
import json
|
||||||
import base64
|
import base64
|
||||||
import requests
|
import requests
|
||||||
import ttkthemes
|
|
||||||
import traceback
|
import traceback
|
||||||
import webbrowser
|
import webbrowser
|
||||||
import tkinter as tk
|
|
||||||
import tkinter.ttk as ttk
|
|
||||||
import tkinter.messagebox as messagebox
|
|
||||||
import urllib.parse as parse
|
import urllib.parse as parse
|
||||||
|
import PyQt5.QtGui as QtGui
|
||||||
|
import PyQt5.QtWidgets as QtWidgets
|
||||||
|
|
||||||
# 读取文本文档
|
# 读取文本文档
|
||||||
def readtxt(path: "路径")->"读取文本文档":
|
def readtxt(path: "路径")->"读取文本文档":
|
||||||
@@ -28,17 +27,18 @@ def Update(name, stars, contact, things, version):
|
|||||||
"Version": version
|
"Version": version
|
||||||
}
|
}
|
||||||
try:
|
try:
|
||||||
messagebox.showinfo(message=requests.post(parse.unquote(base64.b64decode("aHR0cCUzQS8vMTIwLjI1LjE1My4xNDQvdWVuZ2luZS1ydW5uZXIvYnVnL3VwbG9hZC5waHA=").decode("utf-8")), data=data).text)
|
QtWidgets.QMessageBox.information(widget, "提示", requests.post(parse.unquote(base64.b64decode("aHR0cCUzQS8vMTIwLjI1LjE1My4xNDQvdWVuZ2luZS1ydW5uZXIvYnVnL3VwbG9hZC5waHA=").decode("utf-8")), data=data).text)
|
||||||
|
print(data)
|
||||||
except:
|
except:
|
||||||
traceback.print_exc()
|
traceback.print_exc()
|
||||||
messagebox.showerror(title="错误", message="服务器疑似出现错误,可以进行以下尝试:①多尝试几次;②使用其他反馈途径\n错误信息:{}".format(traceback.format_exc()))
|
QtWidgets.QMessageBox.critical(widget, "错误", f"服务器疑似出现错误,可以进行以下尝试:①多尝试几次;②使用其他反馈途径\n错误信息:{traceback.format_exc()}")
|
||||||
|
|
||||||
def UpdateButtonClick():
|
def UpdateButtonClick():
|
||||||
#判断是否为空
|
#判断是否为空
|
||||||
if nameThings.get() == "" or starValue.get() == "" or contactThings.get() == "" or updateThings.get(1.0, "end").replace(" ", "").replace("\n", "") == "":
|
if nameThings.text() == "" or starMenu.currentText() == "" or contactThings.text() == "" or updateThings.toPlainText().replace(" ", "").replace("\n", "") == "":
|
||||||
messagebox.showerror(title="错误", message="反馈信息未填写完整!")
|
QtWidgets.QMessageBox.critical(widget, "错误", "反馈信息未填写完整!")
|
||||||
return
|
return
|
||||||
Update(name=nameThings.get(), stars=starValue.get(), contact=contactThings.get(), things=updateThings.get(1.0, "end"), version=version)
|
Update(name=nameThings.text(), stars=starMenu.currentText(), contact=contactThings.text(), things=updateThings.toPlainText(), version=version)
|
||||||
|
|
||||||
def OpenGiteeIssues():
|
def OpenGiteeIssues():
|
||||||
webbrowser.open_new_tab("https://gitee.com/gfdgd-xi/uengine-runner/issues")
|
webbrowser.open_new_tab("https://gitee.com/gfdgd-xi/uengine-runner/issues")
|
||||||
@@ -46,6 +46,9 @@ def OpenGiteeIssues():
|
|||||||
def OpenGithubIssues():
|
def OpenGithubIssues():
|
||||||
webbrowser.open_new_tab("https://github.com/gfdgd-xi/uengine-runner/issues")
|
webbrowser.open_new_tab("https://github.com/gfdgd-xi/uengine-runner/issues")
|
||||||
|
|
||||||
|
def OpenGitlinkIssues():
|
||||||
|
webbrowser.open_new_tab("https://www.gitlink.org.cn/gfdgd_xi/uengine-runner/issues")
|
||||||
|
|
||||||
# 获取用户主目录
|
# 获取用户主目录
|
||||||
def get_home()->"获取用户主目录":
|
def get_home()->"获取用户主目录":
|
||||||
return os.path.expanduser('~')
|
return os.path.expanduser('~')
|
||||||
@@ -53,7 +56,7 @@ def get_home()->"获取用户主目录":
|
|||||||
###########################
|
###########################
|
||||||
# 程序信息
|
# 程序信息
|
||||||
###########################
|
###########################
|
||||||
iconPath = "{}/runner.png".format(os.path.split(os.path.realpath(__file__))[0])
|
iconPath = "{}/runner.svg".format(os.path.split(os.path.realpath(__file__))[0])
|
||||||
programPath = os.path.split(os.path.realpath(__file__))[0] # 返回 string
|
programPath = os.path.split(os.path.realpath(__file__))[0] # 返回 string
|
||||||
information = json.loads(readtxt(programPath + "/information.json"))
|
information = json.loads(readtxt(programPath + "/information.json"))
|
||||||
version = information["Version"]
|
version = information["Version"]
|
||||||
@@ -61,68 +64,42 @@ version = information["Version"]
|
|||||||
###########################
|
###########################
|
||||||
# 窗口创建
|
# 窗口创建
|
||||||
###########################
|
###########################
|
||||||
# 读取主题
|
app = QtWidgets.QApplication(sys.argv)
|
||||||
try:
|
window = QtWidgets.QMainWindow()
|
||||||
theme = not ("dark" in readtxt(get_home() + "/.gtkrc-2.0") and "gtk-theme-name=" in readtxt(get_home() + "/.gtkrc-2.0"))
|
widget = QtWidgets.QWidget()
|
||||||
except:
|
widgetLayout = QtWidgets.QGridLayout()
|
||||||
print("主题读取错误,默认使用浅色主题")
|
nameThings = QtWidgets.QLineEdit()
|
||||||
theme = True
|
contactThings = QtWidgets.QLineEdit()
|
||||||
if theme:
|
starMenu = QtWidgets.QComboBox()
|
||||||
window = tk.Tk()
|
updateThings = QtWidgets.QTextEdit()
|
||||||
themes = ttkthemes.ThemedStyle(window)
|
updateButton = QtWidgets.QPushButton("提交")
|
||||||
themes.set_theme("breeze")
|
otherUpload = QtWidgets.QHBoxLayout()
|
||||||
else:
|
giteeButton = QtWidgets.QPushButton("Gitee Issues")
|
||||||
import ttkbootstrap
|
githubButton = QtWidgets.QPushButton("Github Issues")
|
||||||
style = ttkbootstrap.Style(theme="darkly")
|
gitlinkButton = QtWidgets.QPushButton("Gitlink Issues")
|
||||||
window = style.master # 创建窗口
|
otherUpload.addWidget(QtWidgets.QLabel("如果无法正常反馈,可以用其他方式反馈:"))
|
||||||
win = ttk.Frame()
|
otherUpload.addWidget(giteeButton)
|
||||||
|
otherUpload.addWidget(githubButton)
|
||||||
starValue = tk.StringVar()
|
otherUpload.addWidget(gitlinkButton)
|
||||||
starValue.set("5分")
|
otherUpload.addSpacerItem(QtWidgets.QSpacerItem(20, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum))
|
||||||
|
starMenu.addItems(["5分", "4分", "3分", "2分", "1分"])
|
||||||
name = ttk.Label(win, text="你的昵称:")
|
widgetLayout.addWidget(QtWidgets.QLabel("你的昵称:"), 0, 0, 1, 1)
|
||||||
nameThings = ttk.Entry(win, width=25)
|
widgetLayout.addWidget(QtWidgets.QLabel("联系方式(电子邮箱):"), 0, 2, 1, 1)
|
||||||
|
widgetLayout.addWidget(QtWidgets.QLabel("评分:"), 0, 4, 1, 1)
|
||||||
contact = ttk.Label(win, text="联系方式(电子邮箱):")
|
widgetLayout.addWidget(QtWidgets.QLabel("反馈内容(支持 Markdown 格式):"), 1, 0, 1, 2)
|
||||||
contactThings = ttk.Entry(win, width=25)
|
widgetLayout.addWidget(nameThings, 0, 1, 1, 1)
|
||||||
|
widgetLayout.addWidget(contactThings, 0, 3, 1, 1)
|
||||||
star = ttk.Label(win, text="评分:")
|
widgetLayout.addWidget(starMenu, 0, 5, 1, 1)
|
||||||
starMenu = ttk.OptionMenu(win, starValue, "5分", "5分", "4分", "3分", "2分", "1分")
|
widgetLayout.addWidget(updateThings, 2, 0, 1, 6)
|
||||||
|
widgetLayout.addLayout(otherUpload, 3, 0, 1, 5)
|
||||||
updateThingsTips = ttk.Label(win, text="反馈内容(支持 Markdown 格式):")
|
widgetLayout.addWidget(updateButton, 3, 5, 1, 1)
|
||||||
updateThings = tk.Text(win, width=100)
|
giteeButton.clicked.connect(OpenGiteeIssues)
|
||||||
|
githubButton.clicked.connect(OpenGithubIssues)
|
||||||
otherUpload = ttk.Frame(win)
|
gitlinkButton.clicked.connect(OpenGitlinkIssues)
|
||||||
# 所属内容
|
updateButton.clicked.connect(UpdateButtonClick)
|
||||||
tips = ttk.Label(otherUpload, text="如果无法正常反馈,可以用其他方式反馈:")
|
widget.setLayout(widgetLayout)
|
||||||
giteeButton = ttk.Button(otherUpload, text="Gitee Issues", command=OpenGiteeIssues)
|
window.setCentralWidget(widget)
|
||||||
githubButton = ttk.Button(otherUpload, text="Github Issues", command=OpenGithubIssues)
|
window.setWindowTitle(f"UEngine 运行器 {version} 问题/建议反馈")
|
||||||
|
window.setWindowIcon(QtGui.QIcon(iconPath))
|
||||||
updateButton = ttk.Button(win, text="提交", command=UpdateButtonClick)
|
window.show()
|
||||||
|
sys.exit(app.exec_())
|
||||||
# 设置窗口
|
|
||||||
window.title("UEngine 运行器 {} 问题/建议反馈".format(version))
|
|
||||||
window.resizable(0, 0)
|
|
||||||
window.iconphoto(False, tk.PhotoImage(file=iconPath))
|
|
||||||
|
|
||||||
tips.grid(row=0, column=0)
|
|
||||||
giteeButton.grid(row=0, column=1)
|
|
||||||
githubButton.grid(row=0, column=2)
|
|
||||||
|
|
||||||
name.grid(row=0, column=0)
|
|
||||||
nameThings.grid(row=0, column=1)
|
|
||||||
|
|
||||||
contact.grid(row=0, column=2)
|
|
||||||
contactThings.grid(row=0, column=3)
|
|
||||||
|
|
||||||
star.grid(row=0, column=4)
|
|
||||||
starMenu.grid(row=0, column=5)
|
|
||||||
|
|
||||||
updateThingsTips.grid(row=1, column=0, columnspan=2)
|
|
||||||
updateThings.grid(row=2, column=0, columnspan=6)
|
|
||||||
|
|
||||||
otherUpload.grid(row=3, column=0, columnspan=4, sticky=tk.W)
|
|
||||||
updateButton.grid(row=3, column=5)
|
|
||||||
|
|
||||||
win.pack(expand="yes", fill="both")
|
|
||||||
window.mainloop()
|
|
||||||
@@ -1,15 +1,12 @@
|
|||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python3
|
||||||
#########################################
|
#########################################
|
||||||
# 版本:1.6.2
|
# 版本:1.8.0
|
||||||
# 更新时间:2022年06月19日
|
# 更新时间:2022年07月23日
|
||||||
#########################################
|
#########################################
|
||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
import traceback
|
import traceback
|
||||||
import ttkthemes
|
import PyQt5.QtWidgets as QtWidgets
|
||||||
import tkinter as tk
|
|
||||||
import tkinter.ttk as ttk
|
|
||||||
import tkinter.messagebox as messagebox
|
|
||||||
########################
|
########################
|
||||||
#
|
#
|
||||||
########################
|
########################
|
||||||
@@ -29,40 +26,34 @@ def readtxt(path: "路径")->"读取文本文档":
|
|||||||
###################
|
###################
|
||||||
# 判断是不是 root
|
# 判断是不是 root
|
||||||
###################
|
###################
|
||||||
|
app = QtWidgets.QApplication(sys.argv)
|
||||||
if os.geteuid() != 0:
|
if os.geteuid() != 0:
|
||||||
print("不是以 root 权限运行本程序!")
|
print("不是以 root 权限运行本程序!")
|
||||||
root = tk.Tk()
|
QtWidgets.QMessageBox.critical(None, "错误", "不是以 root 权限运行本程序!")
|
||||||
root.overrideredirect(1)
|
|
||||||
root.withdraw()
|
|
||||||
messagebox.showerror(title="错误", message="不是以 root 权限运行本程序!")
|
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
###################
|
###################
|
||||||
#
|
#
|
||||||
###################
|
###################
|
||||||
window = tk.Tk()
|
|
||||||
style = ttkthemes.ThemedStyle(window)
|
|
||||||
style.set_theme("breeze")
|
|
||||||
window.withdraw()
|
|
||||||
try:
|
try:
|
||||||
if sys.argv[1] == "1" and messagebox.askokcancel(title="提示", message="你确定要删除吗?"):
|
if sys.argv[1] == "1" and QtWidgets.QMessageBox.question(None, "提示", "你确定要删除吗?", QtWidgets.QMessageBox.Ok, QtWidgets.QMessageBox.Cancel) == QtWidgets.QMessageBox.Ok:
|
||||||
os.remove("/data/uengine/data/data/misc/adb/adb_keys")
|
os.remove("/data/uengine/data/data/misc/adb/adb_keys")
|
||||||
messagebox.showinfo(title="提示", message="完成")
|
QtWidgets.QMessageBox.information(None, "提示", "完成")
|
||||||
except:
|
except:
|
||||||
traceback.print_exc()
|
traceback.print_exc()
|
||||||
messagebox.showerror(title="错误", message=traceback.format_exc())
|
QtWidgets.QMessageBox.critical(None, "错误", traceback.format_exc())
|
||||||
sys.exit(2)
|
sys.exit(2)
|
||||||
if sys.argv[1] == "1":
|
if sys.argv[1] == "1":
|
||||||
sys.exit(0)
|
sys.exit(0)
|
||||||
|
|
||||||
if not messagebox.askyesno(title="提示", message='''请阅读以下提示然后确定是否继续:
|
if QtWidgets.QMessageBox.question(None, "提示", '''请阅读以下提示然后确定是否继续:
|
||||||
1、安装后即可使用 adb 连接 UEngine;
|
1、安装后即可使用 adb 连接 UEngine;
|
||||||
2、重置 UEngine 或 adb 就需要重新设置该支持补丁;
|
2、重置 UEngine 或 adb 就需要重新设置该支持补丁;
|
||||||
3、需要 root 权限;'''):
|
3、需要 root 权限;''') == QtWidgets.QMessageBox.No:
|
||||||
sys.exit(0)
|
sys.exit(0)
|
||||||
# 写入(需要 root)
|
# 写入(需要 root)
|
||||||
if not os.path.exists("/data/uengine/data/data/misc/adb"):
|
if not os.path.exists("/data/uengine/data/data/misc/adb"):
|
||||||
messagebox.showerror(title="错误", message="无法读取 UEngine 数据!")
|
QtWidgets.QMessageBox.critical(None, "错误", "无法读取 UEngine 数据!")
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
try:
|
try:
|
||||||
things = readtxt(sys.argv[2])
|
things = readtxt(sys.argv[2])
|
||||||
@@ -74,8 +65,8 @@ try:
|
|||||||
if os.path.exists("/data/uengine/data/data/misc/adb/adb_keys"):
|
if os.path.exists("/data/uengine/data/data/misc/adb/adb_keys"):
|
||||||
old = readtxt("/data/uengine/data/data/misc/adb/adb_keys") + "\n"
|
old = readtxt("/data/uengine/data/data/misc/adb/adb_keys") + "\n"
|
||||||
write_txt("/data/uengine/data/data/misc/adb/adb_keys", old + "\n".join(adbKey))
|
write_txt("/data/uengine/data/data/misc/adb/adb_keys", old + "\n".join(adbKey))
|
||||||
messagebox.showinfo(title="提示", message="完成")
|
QtWidgets.QMessageBox.information(None, "提示", "完成")
|
||||||
except:
|
except:
|
||||||
traceback.print_exc()
|
traceback.print_exc()
|
||||||
messagebox.showerror(title="错误", message=traceback.format_exc())
|
QtWidgets.QMessageBox.information(None, "错误", traceback.format_exc())
|
||||||
sys.exit(2)
|
sys.exit(2)
|
||||||
Reference in New Issue
Block a user