From 27abc3ad542e304f5bbfa8b8ed8e9fbf4ef9471c Mon Sep 17 00:00:00 2001 From: YangHu Date: Wed, 19 Feb 2020 10:32:56 +0800 Subject: [PATCH] 1.0.1.0219 --- CHANGELOG.md | 4 + Ui_onmyoji.py | 278 ------------------------ gui/__init__.py | 0 gui/tkui.py | 287 +++++++++++++++++++++++++ onmyoji.ui | 538 ----------------------------------------------- requirements.txt | 1 - ui.py | 59 ++---- 7 files changed, 313 insertions(+), 854 deletions(-) delete mode 100644 Ui_onmyoji.py create mode 100644 gui/__init__.py create mode 100644 gui/tkui.py delete mode 100644 onmyoji.ui diff --git a/CHANGELOG.md b/CHANGELOG.md index 365043b..8a3e1bc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # CHANGELOG +## v1.0.1.0219 +#### Fixes (bugs & defects): +* 抛弃PyQt,用tkinter重写ui,以减小文件体积。 + ## v1.0.1.0211 #### New features: * 根据[#39](https://github.com/AcademicDog/onmyoji_bot/issues/39),增加了更换素材和R卡的选项。 diff --git a/Ui_onmyoji.py b/Ui_onmyoji.py deleted file mode 100644 index 6d81431..0000000 --- a/Ui_onmyoji.py +++ /dev/null @@ -1,278 +0,0 @@ -# -*- coding: utf-8 -*- - -# Form implementation generated from reading ui file 'c:\Users\74205\Documents\github\onmyoji_bot\onmyoji.ui' -# -# Created by: PyQt5 UI code generator 5.13.0 -# -# WARNING! All changes made in this file will be lost! - - -from PyQt5 import QtCore, QtGui, QtWidgets - - -class Ui_MainWindow(object): - def setupUi(self, MainWindow): - MainWindow.setObjectName("MainWindow") - MainWindow.resize(359, 651) - MainWindow.setMinimumSize(QtCore.QSize(300, 590)) - MainWindow.setMaximumSize(QtCore.QSize(16777215, 16777215)) - self.centralwidget = QtWidgets.QWidget(MainWindow) - self.centralwidget.setObjectName("centralwidget") - self.gridLayout_6 = QtWidgets.QGridLayout(self.centralwidget) - self.gridLayout_6.setObjectName("gridLayout_6") - self.frame = QtWidgets.QFrame(self.centralwidget) - self.frame.setMinimumSize(QtCore.QSize(0, 0)) - self.frame.setMaximumSize(QtCore.QSize(16777215, 16777215)) - self.frame.setFrameShape(QtWidgets.QFrame.Box) - self.frame.setFrameShadow(QtWidgets.QFrame.Sunken) - self.frame.setObjectName("frame") - self.gridLayout_3 = QtWidgets.QGridLayout(self.frame) - self.gridLayout_3.setObjectName("gridLayout_3") - self.label = QtWidgets.QLabel(self.frame) - font = QtGui.QFont() - font.setFamily("Times New Roman") - font.setPointSize(24) - self.label.setFont(font) - self.label.setObjectName("label") - self.gridLayout_3.addWidget(self.label, 0, 0, 1, 1) - self.verticalLayout = QtWidgets.QVBoxLayout() - self.verticalLayout.setObjectName("verticalLayout") - self.tabWidget = QtWidgets.QTabWidget(self.frame) - self.tabWidget.setMinimumSize(QtCore.QSize(0, 0)) - self.tabWidget.setMaximumSize(QtCore.QSize(16777215, 16777215)) - self.tabWidget.setObjectName("tabWidget") - self.tab = QtWidgets.QWidget() - self.tab.setObjectName("tab") - self.gridLayout_2 = QtWidgets.QGridLayout(self.tab) - self.gridLayout_2.setObjectName("gridLayout_2") - self.groupBox = QtWidgets.QGroupBox(self.tab) - self.groupBox.setObjectName("groupBox") - self.gridLayout = QtWidgets.QGridLayout(self.groupBox) - self.gridLayout.setObjectName("gridLayout") - self.mitama_single = QtWidgets.QRadioButton(self.groupBox) - self.mitama_single.setAutoFillBackground(False) - self.mitama_single.setChecked(True) - self.mitama_single.setObjectName("mitama_single") - self.gridLayout.addWidget(self.mitama_single, 0, 0, 1, 1) - self.mitama_driver = QtWidgets.QRadioButton(self.groupBox) - self.mitama_driver.setObjectName("mitama_driver") - self.gridLayout.addWidget(self.mitama_driver, 0, 1, 1, 1) - self.mitama_passenger = QtWidgets.QRadioButton(self.groupBox) - self.mitama_passenger.setObjectName("mitama_passenger") - self.gridLayout.addWidget(self.mitama_passenger, 1, 0, 1, 1) - self.mitama_dual = QtWidgets.QRadioButton(self.groupBox) - self.mitama_dual.setObjectName("mitama_dual") - self.gridLayout.addWidget(self.mitama_dual, 1, 1, 1, 1) - self.gridLayout_2.addWidget(self.groupBox, 0, 0, 1, 1) - self.groupBox_4 = QtWidgets.QGroupBox(self.tab) - self.groupBox_4.setObjectName("groupBox_4") - self.gridLayout_9 = QtWidgets.QGridLayout(self.groupBox_4) - self.gridLayout_9.setObjectName("gridLayout_9") - self.radioButton_1 = QtWidgets.QRadioButton(self.groupBox_4) - self.radioButton_1.setChecked(True) - self.radioButton_1.setObjectName("radioButton_1") - self.gridLayout_9.addWidget(self.radioButton_1, 0, 0, 1, 1) - self.radioButton_3 = QtWidgets.QRadioButton(self.groupBox_4) - self.radioButton_3.setObjectName("radioButton_3") - self.gridLayout_9.addWidget(self.radioButton_3, 1, 0, 1, 2) - self.radioButton_2 = QtWidgets.QRadioButton(self.groupBox_4) - self.radioButton_2.setObjectName("radioButton_2") - self.gridLayout_9.addWidget(self.radioButton_2, 0, 2, 1, 1) - self.gridLayout_2.addWidget(self.groupBox_4, 1, 0, 1, 1) - self.tabWidget.addTab(self.tab, "") - self.tab_4 = QtWidgets.QWidget() - self.tab_4.setObjectName("tab_4") - self.verticalLayout_3 = QtWidgets.QVBoxLayout(self.tab_4) - self.verticalLayout_3.setObjectName("verticalLayout_3") - self.plainTextEdit_3 = QtWidgets.QPlainTextEdit(self.tab_4) - self.plainTextEdit_3.setReadOnly(True) - self.plainTextEdit_3.setObjectName("plainTextEdit_3") - self.verticalLayout_3.addWidget(self.plainTextEdit_3) - self.tabWidget.addTab(self.tab_4, "") - self.tab_2 = QtWidgets.QWidget() - self.tab_2.setObjectName("tab_2") - self.gridLayout_5 = QtWidgets.QGridLayout(self.tab_2) - self.gridLayout_5.setObjectName("gridLayout_5") - self.line_4 = QtWidgets.QFrame(self.tab_2) - self.line_4.setFrameShape(QtWidgets.QFrame.HLine) - self.line_4.setFrameShadow(QtWidgets.QFrame.Sunken) - self.line_4.setObjectName("line_4") - self.gridLayout_5.addWidget(self.line_4, 2, 0, 1, 1) - self.checkBox_2 = QtWidgets.QCheckBox(self.tab_2) - self.checkBox_2.setObjectName("checkBox_2") - self.gridLayout_5.addWidget(self.checkBox_2, 7, 0, 1, 1) - self.plainTextEdit_2 = QtWidgets.QPlainTextEdit(self.tab_2) - self.plainTextEdit_2.setMaximumSize(QtCore.QSize(16777215, 16777215)) - self.plainTextEdit_2.setReadOnly(True) - self.plainTextEdit_2.setObjectName("plainTextEdit_2") - self.gridLayout_5.addWidget(self.plainTextEdit_2, 0, 0, 1, 1) - self.checkBox_3 = QtWidgets.QCheckBox(self.tab_2) - self.checkBox_3.setChecked(True) - self.checkBox_3.setObjectName("checkBox_3") - self.gridLayout_5.addWidget(self.checkBox_3, 3, 0, 1, 1) - self.horizontalSlider = QtWidgets.QSlider(self.tab_2) - self.horizontalSlider.setSliderPosition(10) - self.horizontalSlider.setOrientation(QtCore.Qt.Horizontal) - self.horizontalSlider.setObjectName("horizontalSlider") - self.gridLayout_5.addWidget(self.horizontalSlider, 4, 0, 1, 1) - self.groupBox_3 = QtWidgets.QGroupBox(self.tab_2) - self.groupBox_3.setMinimumSize(QtCore.QSize(0, 0)) - self.groupBox_3.setObjectName("groupBox_3") - self.gridLayout_8 = QtWidgets.QGridLayout(self.groupBox_3) - self.gridLayout_8.setObjectName("gridLayout_8") - self.lineEdit_3 = QtWidgets.QLineEdit(self.groupBox_3) - self.lineEdit_3.setAlignment(QtCore.Qt.AlignRight|QtCore.Qt.AlignTrailing|QtCore.Qt.AlignVCenter) - self.lineEdit_3.setObjectName("lineEdit_3") - self.gridLayout_8.addWidget(self.lineEdit_3, 0, 1, 1, 1) - self.label_5 = QtWidgets.QLabel(self.groupBox_3) - self.label_5.setObjectName("label_5") - self.gridLayout_8.addWidget(self.label_5, 0, 0, 1, 1) - self.gridLayout_5.addWidget(self.groupBox_3, 1, 0, 1, 1) - self.comboBox = QtWidgets.QComboBox(self.tab_2) - self.comboBox.setObjectName("comboBox") - self.comboBox.addItem("") - self.comboBox.addItem("") - self.comboBox.addItem("") - self.gridLayout_5.addWidget(self.comboBox, 6, 0, 1, 1) - self.tabWidget.addTab(self.tab_2, "") - self.tab_3 = QtWidgets.QWidget() - self.tab_3.setObjectName("tab_3") - self.gridLayout_4 = QtWidgets.QGridLayout(self.tab_3) - self.gridLayout_4.setObjectName("gridLayout_4") - self.plainTextEdit = QtWidgets.QPlainTextEdit(self.tab_3) - self.plainTextEdit.setMaximumSize(QtCore.QSize(16777215, 16777215)) - self.plainTextEdit.setReadOnly(True) - self.plainTextEdit.setObjectName("plainTextEdit") - self.gridLayout_4.addWidget(self.plainTextEdit, 0, 0, 1, 1) - self.tabWidget.addTab(self.tab_3, "") - self.verticalLayout.addWidget(self.tabWidget) - self.line = QtWidgets.QFrame(self.frame) - self.line.setFrameShape(QtWidgets.QFrame.HLine) - self.line.setFrameShadow(QtWidgets.QFrame.Sunken) - self.line.setObjectName("line") - self.verticalLayout.addWidget(self.line) - self.groupBox_2 = QtWidgets.QGroupBox(self.frame) - sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Expanding) - sizePolicy.setHorizontalStretch(0) - sizePolicy.setVerticalStretch(0) - sizePolicy.setHeightForWidth(self.groupBox_2.sizePolicy().hasHeightForWidth()) - self.groupBox_2.setSizePolicy(sizePolicy) - self.groupBox_2.setMinimumSize(QtCore.QSize(0, 0)) - self.groupBox_2.setLayoutDirection(QtCore.Qt.LeftToRight) - self.groupBox_2.setObjectName("groupBox_2") - self.gridLayout_7 = QtWidgets.QGridLayout(self.groupBox_2) - self.gridLayout_7.setObjectName("gridLayout_7") - self.label_2 = QtWidgets.QLabel(self.groupBox_2) - self.label_2.setObjectName("label_2") - self.gridLayout_7.addWidget(self.label_2, 3, 0, 1, 1) - self.label_3 = QtWidgets.QLabel(self.groupBox_2) - self.label_3.setObjectName("label_3") - self.gridLayout_7.addWidget(self.label_3, 4, 0, 1, 1) - self.checkBox = QtWidgets.QCheckBox(self.groupBox_2) - self.checkBox.setChecked(True) - self.checkBox.setObjectName("checkBox") - self.gridLayout_7.addWidget(self.checkBox, 1, 0, 1, 1) - self.lineEdit = QtWidgets.QLineEdit(self.groupBox_2) - sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Preferred, QtWidgets.QSizePolicy.Preferred) - sizePolicy.setHorizontalStretch(0) - sizePolicy.setVerticalStretch(0) - sizePolicy.setHeightForWidth(self.lineEdit.sizePolicy().hasHeightForWidth()) - self.lineEdit.setSizePolicy(sizePolicy) - self.lineEdit.setMaximumSize(QtCore.QSize(16777215, 20)) - self.lineEdit.setAlignment(QtCore.Qt.AlignRight|QtCore.Qt.AlignTrailing|QtCore.Qt.AlignVCenter) - self.lineEdit.setObjectName("lineEdit") - self.gridLayout_7.addWidget(self.lineEdit, 3, 1, 1, 1) - self.lineEdit_2 = QtWidgets.QLineEdit(self.groupBox_2) - self.lineEdit_2.setMaximumSize(QtCore.QSize(16777215, 20)) - self.lineEdit_2.setAlignment(QtCore.Qt.AlignRight|QtCore.Qt.AlignTrailing|QtCore.Qt.AlignVCenter) - self.lineEdit_2.setObjectName("lineEdit_2") - self.gridLayout_7.addWidget(self.lineEdit_2, 4, 1, 1, 1) - self.checkBox_4 = QtWidgets.QCheckBox(self.groupBox_2) - self.checkBox_4.setObjectName("checkBox_4") - self.gridLayout_7.addWidget(self.checkBox_4, 0, 0, 1, 1) - self.verticalLayout.addWidget(self.groupBox_2) - self.gridLayout_3.addLayout(self.verticalLayout, 1, 0, 1, 1) - self.start_btn = QtWidgets.QPushButton(self.frame) - self.start_btn.setMinimumSize(QtCore.QSize(246, 23)) - self.start_btn.setLayoutDirection(QtCore.Qt.RightToLeft) - self.start_btn.setObjectName("start_btn") - self.gridLayout_3.addWidget(self.start_btn, 2, 0, 1, 1) - self.pushButton = QtWidgets.QPushButton(self.frame) - self.pushButton.setMinimumSize(QtCore.QSize(246, 0)) - self.pushButton.setObjectName("pushButton") - self.gridLayout_3.addWidget(self.pushButton, 3, 0, 1, 1) - self.gridLayout_6.addWidget(self.frame, 1, 0, 1, 1) - MainWindow.setCentralWidget(self.centralwidget) - self.menubar = QtWidgets.QMenuBar(MainWindow) - self.menubar.setGeometry(QtCore.QRect(0, 0, 359, 23)) - self.menubar.setObjectName("menubar") - self.menu = QtWidgets.QMenu(self.menubar) - self.menu.setObjectName("menu") - MainWindow.setMenuBar(self.menubar) - self.statusBar = QtWidgets.QStatusBar(MainWindow) - self.statusBar.setObjectName("statusBar") - MainWindow.setStatusBar(self.statusBar) - self.actionFile = QtWidgets.QAction(MainWindow) - self.actionFile.setObjectName("actionFile") - self.actionAbout_2 = QtWidgets.QAction(MainWindow) - self.actionAbout_2.setObjectName("actionAbout_2") - self.actionAbout = QtWidgets.QAction(MainWindow) - self.actionAbout.setStatusTip("") - self.actionAbout.setObjectName("actionAbout") - self.menu.addAction(self.actionAbout) - self.menubar.addAction(self.menu.menuAction()) - - self.retranslateUi(MainWindow) - self.tabWidget.setCurrentIndex(0) - self.comboBox.setCurrentIndex(1) - self.start_btn.clicked.connect(MainWindow.start_onmyoji) - self.pushButton.clicked.connect(MainWindow.stop_onmyoji) - QtCore.QMetaObject.connectSlotsByName(MainWindow) - - def retranslateUi(self, MainWindow): - _translate = QtCore.QCoreApplication.translate - MainWindow.setWindowTitle(_translate("MainWindow", "onmyoji_bot")) - self.label.setText(_translate("MainWindow", "辅助助手")) - self.groupBox.setTitle(_translate("MainWindow", "模式")) - self.mitama_single.setText(_translate("MainWindow", "单刷")) - self.mitama_driver.setText(_translate("MainWindow", "单人司机")) - self.mitama_passenger.setText(_translate("MainWindow", "单人乘客")) - self.mitama_dual.setText(_translate("MainWindow", "双开")) - self.groupBox_4.setTitle(_translate("MainWindow", "副本(调试中)")) - self.radioButton_1.setText(_translate("MainWindow", "八岐大蛇")) - self.radioButton_3.setText(_translate("MainWindow", "卑弥呼")) - self.radioButton_2.setText(_translate("MainWindow", "业原火")) - self.tabWidget.setTabText(self.tabWidget.indexOf(self.tab), _translate("MainWindow", "御魂")) - self.plainTextEdit_3.setPlainText(_translate("MainWindow", "选择好要打的御灵及层数,点击开始按钮即可。")) - self.tabWidget.setTabText(self.tabWidget.indexOf(self.tab_4), _translate("MainWindow", "御灵")) - self.checkBox_2.setText(_translate("MainWindow", "结束后打BOSS")) - self.plainTextEdit_2.setPlainText(_translate("MainWindow", "把狗粮队长放在最左边,点开需要打的章节,然后开始。\n" -"\n" -"支持自动换狗粮,只打经验怪。\n" -"\n" -"最好把“合并相同式神”选项关闭。")) - self.checkBox_3.setText(_translate("MainWindow", "换狗粮拖放式神进度条,进度:")) - self.groupBox_3.setTitle(_translate("MainWindow", "延迟设置")) - self.lineEdit_3.setText(_translate("MainWindow", "3")) - self.label_5.setText(_translate("MainWindow", "满级狗粮识别延迟(秒):")) - self.comboBox.setItemText(0, _translate("MainWindow", "更换素材")) - self.comboBox.setItemText(1, _translate("MainWindow", "更换N卡")) - self.comboBox.setItemText(2, _translate("MainWindow", "更换R卡")) - self.tabWidget.setTabText(self.tabWidget.indexOf(self.tab_2), _translate("MainWindow", "探索")) - self.plainTextEdit.setPlainText(_translate("MainWindow", "网址:https://github.com/AcademicDog/onmyoji_bot\n" -"\n" -"交流Q群:592055060")) - self.tabWidget.setTabText(self.tabWidget.indexOf(self.tab_3), _translate("MainWindow", "关于")) - self.groupBox_2.setTitle(_translate("MainWindow", "高级选项")) - self.label_2.setText(_translate("MainWindow", " 画面超时时间(秒):")) - self.label_3.setText(_translate("MainWindow", " 操作超时时间(秒):")) - self.checkBox.setText(_translate("MainWindow", "超时自动关闭阴阳师")) - self.lineEdit.setText(_translate("MainWindow", "100")) - self.lineEdit_2.setText(_translate("MainWindow", "20")) - self.checkBox_4.setText(_translate("MainWindow", "调试模式")) - self.start_btn.setText(_translate("MainWindow", "开始")) - self.pushButton.setText(_translate("MainWindow", "结束")) - self.menu.setTitle(_translate("MainWindow", "帮助")) - self.actionFile.setText(_translate("MainWindow", "File")) - self.actionAbout_2.setText(_translate("MainWindow", "About")) - self.actionAbout.setText(_translate("MainWindow", "About")) diff --git a/gui/__init__.py b/gui/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/gui/tkui.py b/gui/tkui.py new file mode 100644 index 0000000..738ffc2 --- /dev/null +++ b/gui/tkui.py @@ -0,0 +1,287 @@ +import tkinter as tk +import tkinter.messagebox +from tkinter import ttk + + +class Application(tk.Frame): + def __init__(self, master=None): + super().__init__(master) + self.master = master + self.master.wm_title('OnmyojiBot') + self.pack() + + # 初始化参数 + self.run_section = 0 + self.run_mode = tk.IntVar() + + self.watchdog_enable = tk.BooleanVar() + self.max_win_time = tk.IntVar() + self.max_op_time = tk.IntVar() + + self.fight_boss_enable = tk.BooleanVar() + self.slide_shikigami = tk.BooleanVar() + self.slide_shikigami_progress = tk.IntVar() + self.zhunbei_delay = tk.IntVar() + self.change_shikigami = 1 + + self.debug_enable = tk.BooleanVar() + + self.run_mode.set(0) + self.watchdog_enable.set(True) + self.max_win_time.set(100) + self.max_op_time.set(20) + self.fight_boss_enable.set(False) + self.slide_shikigami.set(True) + self.slide_shikigami_progress.set(10) + self.zhunbei_delay.set(3) + self.debug_enable.set(False) + + # 创建菜单栏 + self.create_menubar() + + # 创建标题 + self.create_title() + + # 创建选项卡 + self.create_section() + + # 创建选项 + self.create_frame0() + self.create_frame1() + self.create_frame2() + self.create_frame3() + + # 创建高级菜单 + self.create_advance() + + # 创建日志 + self.create_log() + + # 创建操作按钮 + self.create_command() + + def create_menubar(self): + ''' + 创建菜单栏 + ''' + menubar = tk.Menu(self.master) + + # 创建菜单项 + menu1 = tk.Menu(menubar, tearoff=0) + menu1.add_command(label='About', command=self.say_hi) + + # 链接 + menubar.add_cascade(label="File", menu=menu1) + + # 设置 + self.master.config(menu=menubar) + + def create_title(self): + # 标题 + tk.Label(self.master, text='OnmyojiBot', + font='Helvetica 20 bold').pack(anchor=tk.W) + tk.Label( + self.master, text='https://github.com/AcademicDog/onmyoji_bot').pack(anchor=tk.W) + + # 主页面 + self.main_frame1 = tk.Frame(self.master) + self.main_frame2 = tk.Frame(self.master) + self.main_frame1.pack(side=tk.LEFT, fill=tk.BOTH, expand=True) + self.main_frame2.pack(side=tk.RIGHT, fill=tk.BOTH, expand=True) + + def create_section(self): + ''' + 创建主选项卡 + ''' + self.section = ttk.Notebook(self.main_frame1) + + # 创建选项卡1---御魂 + self.frame0 = tk.Frame(self.section) + self.section.add(self.frame0, text='御魂') + + # 创建选项卡2---御灵 + self.frame1 = tk.Frame(self.section) + self.section.add(self.frame1, text='御灵') + + # 创建选项卡3---探索 + self.frame2 = tk.Frame(self.section, padx=5, pady=5) + self.section.add(self.frame2, text='探索') + + # 创建选项卡4---关于 + self.frame3 = tk.Frame(self.section) + self.section.add(self.frame3, text='关于') + + self.section.pack(fill=tk.BOTH) + + def create_frame0(self): + ''' + 御魂参数 + ''' + # 游戏模式 + mode = tk.LabelFrame(self.frame0, text='模式') + mode.pack(padx=5, pady=5, fill=tk.BOTH) + self.run_mode = tk.IntVar() + self.run_mode.set(0) + tk.Radiobutton(mode, text='单刷', variable=self.run_mode, + value=0).grid(row=0, column=0, sticky=tk.W) + tk.Radiobutton(mode, text='单人司机', variable=self.run_mode, + value=1).grid(row=0, column=1, sticky=tk.W) + tk.Radiobutton(mode, text='单人乘客', variable=self.run_mode, + value=2).grid(row=1, column=0, sticky=tk.W) + tk.Radiobutton(mode, text='双开', variable=self.run_mode, + value=3).grid(row=1, column=1, sticky=tk.W) + + # 游戏副本 + submode = tk.LabelFrame(self.frame0, text='副本(调试中)', padx=5, pady=5) + submode.pack(padx=5, pady=5, fill=tk.BOTH, expand=True) + tk.Radiobutton(submode, text='八岐大蛇', variable=self.run_mode, + value=0).grid(row=0, column=0, sticky=tk.W) + tk.Radiobutton(submode, text='业原火', variable=self.run_mode, + value=1).grid(row=0, column=1, sticky=tk.W) + tk.Radiobutton(submode, text='卑弥呼', variable=self.run_mode, + value=2).grid(row=1, column=0, sticky=tk.W) + + def create_frame1(self): + ''' + 御灵参数 + ''' + text = tk.Text(self.frame1, height=5, width=25) + text.pack(padx=5, pady=5, expand=True, fill=tk.BOTH, anchor=tk.NW) + text.insert(tk.END, '选择好要打的御灵及层数,点击开始按钮即可。') + text.config(state=tk.DISABLED) + + def create_frame2(self): + ''' + 探索参数 + ''' + # 提示文本 + textframe = tk.Frame(self.frame2) + textframe.pack(expand=True, fill=tk.X) + s = tk.Scrollbar(textframe) + s.pack(side=tk.RIGHT) + text = tk.Text(textframe, height=5, width=21) + text.pack(side=tk.LEFT, expand=True, fill=tk.X) + text.insert(tk.INSERT, '把狗粮队长放在最左边,点开需要打的章节,然后开始。\n') + text.insert(tk.INSERT, '支持自动换狗粮,只打经验怪。\n') + text.insert(tk.END, '最好把“合并相同式神”选项关闭。\n') + s.config(command=text.yview) + text.config(yscrollcommand=s.set, state=tk.DISABLED) + + # 延迟设置 + delay = tk.LabelFrame(self.frame2, text='延迟设置') + delay.pack(fill=tk.X) + tk.Label(delay, text='满级狗粮识别延迟:').grid(row=0, column=0) + tk.Entry(delay, textvariable=self.zhunbei_delay, + width=5).grid(row=0, column=1) + + # 换狗粮设置 + tk.Checkbutton(self.frame2, text='换狗粮拖放式神进度条,进度:', + variable=self.slide_shikigami).pack(anchor=tk.W) + tk.Scale(self.frame2, from_=0, to=100, orient=tk.HORIZONTAL, showvalue=0, + variable=self.slide_shikigami_progress).pack(fill=tk.X) + self.cmb = ttk.Combobox(self.frame2) + self.cmb['value'] = ('更换素材', '更换N卡', '更换R卡') + self.cmb.pack(fill=tk.X, padx=2) + self.cmb.current(self.change_shikigami) + self.cmb.config(state='readonly') + + # 打BOSS设置 + tk.Checkbutton(self.frame2, text='结束后打BOSS', + variable=self.fight_boss_enable).pack(anchor=tk.W) + + def create_frame3(self): + ''' + 关于 + ''' + text = tk.Text(self.frame3, height=5, width=25) + text.pack(expand=True, fill=tk.BOTH) + text.insert( + tk.END, '网址:https://github.com/AcademicDog/onmyoji_bot\n\n交流Q群:592055060') + text.config(state=tk.DISABLED) + + def create_advance(self): + ''' + 高级菜单 + ''' + advance = tk.LabelFrame(self.main_frame1, text='高级选项') + advance.pack(padx=5, pady=5, fill=tk.X, side=tk.BOTTOM) + tk.Checkbutton(advance, text='调试模式', + variable=self.debug_enable).pack(anchor=tk.W) + tk.Checkbutton(advance, text='超时自动关闭阴阳师', + variable=self.watchdog_enable).pack(anchor=tk.W) + frame = tk.Frame(advance) + frame.pack(anchor=tk.W) + tk.Label(frame, text=' 画面超时时间(秒):').grid(row=0, column=0) + tk.Entry(frame, textvariable=self.max_win_time, + width=5).grid(row=0, column=1) + tk.Label(frame, text=' 操作超时时间(秒):').grid(row=1, column=0) + tk.Entry(frame, textvariable=self.max_op_time, + width=5).grid(row=1, column=1) + + def create_log(self): + ''' + 参数显示 + ''' + tk.Label(self.main_frame2, text='运行参数:').pack(anchor=tk.W) + self.params = tk.Text(self.main_frame2, height=20, width=28) + self.params.pack(anchor=tk.NW, fill=tk.BOTH, + padx=5, pady=5, expand=True) + self.params.config(state=tk.DISABLED) + + def create_command(self): + ''' + 按钮 + ''' + button_area = tk.Frame(self.main_frame2) + button_area.pack(fill=tk.X, side=tk.BOTTOM, padx=5, pady=5) + tk.Button(button_area, text='开始', + command=self.start_onmyoji).pack(fill=tk.X) + tk.Button(button_area, text='退出', + command=self.stop_onmyoji).pack(fill=tk.X) + + def show_params(self): + self.params.config(state=tk.NORMAL) + self.params.insert(tk.END, '##########################\n') + self.params.insert(tk.END, 'run_section: ' + + str(self.section.index('current'))) + self.params.insert(tk.END, '\nrun_mode: '+str(self.run_mode.get())) + self.params.insert(tk.END, '\nwatchdog_enable: ' + + str(self.watchdog_enable.get())) + self.params.insert(tk.END, '\nmax_win_time: ' + + str(self.max_win_time.get())) + self.params.insert(tk.END, '\nmax_op_time: ' + + str(self.max_op_time.get())) + self.params.insert(tk.END, '\nfight_boss_enable: ' + + str(self.fight_boss_enable.get())) + self.params.insert(tk.END, '\nslide_shikigami: ' + + str(self.slide_shikigami.get())) + self.params.insert(tk.END, '\nslide_shikigami_progress: ' + + str(self.slide_shikigami_progress.get())) + self.params.insert(tk.END, '\nzhunbei_delay: ' + + str(self.zhunbei_delay.get())) + self.params.insert(tk.END, '\nchange_shikigami: ' + + str(self.change_shikigami)) + self.params.insert(tk.END, '\ndebug_enable: ' + + str(self.debug_enable.get())+'\n') + self.params.insert(tk.END, '##########################\n\n') + self.params.see(tk.END) + self.params.config(state=tk.DISABLED) + + def say_hi(self): + ''' + 测试 + ''' + tk.messagebox.showinfo( + "OnmyojiBot", '网址:https://github.com/AcademicDog/onmyoji_bot\n\n交流Q群:592055060') + + def start_onmyoji(self): + self.show_params() + + def stop_onmyoji(self): + pass + + +if __name__ == "__main__": + root = tk.Tk() + app = Application(master=root) + app.mainloop() diff --git a/onmyoji.ui b/onmyoji.ui deleted file mode 100644 index e58fb2f..0000000 --- a/onmyoji.ui +++ /dev/null @@ -1,538 +0,0 @@ - - - MainWindow - - - - 0 - 0 - 359 - 651 - - - - - 300 - 590 - - - - - 16777215 - 16777215 - - - - onmyoji_bot - - - - - - - - 0 - 0 - - - - - 16777215 - 16777215 - - - - QFrame::Box - - - QFrame::Sunken - - - - - - - Times New Roman - 24 - - - - 辅助助手 - - - - - - - - - - 0 - 0 - - - - - 16777215 - 16777215 - - - - 0 - - - - 御魂 - - - - - - 模式 - - - - - - false - - - 单刷 - - - true - - - - - - - 单人司机 - - - - - - - 单人乘客 - - - - - - - 双开 - - - - - - - - - - 副本(调试中) - - - - - - 八岐大蛇 - - - true - - - - - - - 卑弥呼 - - - - - - - 业原火 - - - - - - - - - - - 御灵 - - - - - - true - - - 选择好要打的御灵及层数,点击开始按钮即可。 - - - - - - - - 探索 - - - - - - Qt::Horizontal - - - - - - - 结束后打BOSS - - - - - - - - 16777215 - 16777215 - - - - true - - - 把狗粮队长放在最左边,点开需要打的章节,然后开始。 - -支持自动换狗粮,只打经验怪。 - -最好把“合并相同式神”选项关闭。 - - - - - - - 换狗粮拖放式神进度条,进度: - - - true - - - - - - - 10 - - - Qt::Horizontal - - - - - - - - 0 - 0 - - - - 延迟设置 - - - - - - 3 - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - - 满级狗粮识别延迟(秒): - - - - - - - - - - 1 - - - - 更换素材 - - - - - 更换N卡 - - - - - 更换R卡 - - - - - - - - - 关于 - - - - - - - 16777215 - 16777215 - - - - true - - - 网址:https://github.com/AcademicDog/onmyoji_bot - -交流Q群:592055060 - - - - - - - - - - - Qt::Horizontal - - - - - - - - 0 - 0 - - - - - 0 - 0 - - - - Qt::LeftToRight - - - 高级选项 - - - - - - 画面超时时间(秒): - - - - - - - 操作超时时间(秒): - - - - - - - 超时自动关闭阴阳师 - - - true - - - - - - - - 0 - 0 - - - - - 16777215 - 20 - - - - 100 - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - - - 16777215 - 20 - - - - 20 - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - - 调试模式 - - - - - - - - - - - - - 246 - 23 - - - - Qt::RightToLeft - - - 开始 - - - - - - - - 246 - 0 - - - - 结束 - - - - - - - - - - - - 0 - 0 - 359 - 23 - - - - - 帮助 - - - - - - - - - File - - - - - About - - - - - About - - - - - - - - - - start_btn - clicked() - MainWindow - start_onmyoji() - - - 495 - 517 - - - 197 - 327 - - - - - pushButton - clicked() - MainWindow - stop_onmyoji() - - - 523 - 546 - - - 287 - 247 - - - - - - start_onmyoji() - stop_onmyoji() - debug() - - diff --git a/requirements.txt b/requirements.txt index a6148a8..e926cf3 100644 --- a/requirements.txt +++ b/requirements.txt @@ -2,4 +2,3 @@ numpy==1.17.1 pywin32==224 opencv_python==4.1.0.25 Pillow==6.1.0 -PyQt5==5.12.2 diff --git a/ui.py b/ui.py index 765be5b..297de38 100644 --- a/ui.py +++ b/ui.py @@ -1,5 +1,4 @@ -from PyQt5.QtWidgets import QApplication, QMainWindow -from Ui_onmyoji import Ui_MainWindow +from gui.tkui import Application import configparser import ctypes @@ -7,6 +6,7 @@ import os import subprocess import sys +import tkinter as tk import tools.logsystem @@ -18,11 +18,9 @@ def is_admin(): return False -class MyMainWindow(QMainWindow): - def __init__(self, parent=None): - super(MyMainWindow, self).__init__(parent) - self.ui = Ui_MainWindow() - self.ui.setupUi(self) +class MyBattle(Application): + def __init__(self, master): + Application.__init__(self, master) self.conf = configparser.ConfigParser() def set_conf(self): @@ -30,47 +28,33 @@ def set_conf(self): 设置参数至配置文件 ''' # 运行参数 - section = self.ui.tabWidget.currentIndex() + section = self.section.index('current') self.conf.set('DEFAULT', 'run_section', str(section)) # 一般参数 self.conf.set('watchdog', 'watchdog_enable', - str(self.ui.checkBox.isChecked())) - self.conf.set('watchdog', 'max_win_time', str(self.ui.lineEdit.text())) + str(self.watchdog_enable.get())) + self.conf.set('watchdog', 'max_win_time', str(self.max_win_time.get())) self.conf.set('watchdog', 'max_op_time', - str(self.ui.lineEdit_2.text())) + str(self.max_op_time.get())) self.conf.set('others', 'debug_enable', str( - self.ui.checkBox_4.isChecked())) + self.debug_enable.get())) # 御魂参数 - if self.ui.mitama_single.isChecked(): - # 单刷 - self.conf.set('DEFAULT', 'run_mode', '0') - - elif self.ui.mitama_driver.isChecked(): - # 司机 - self.conf.set('DEFAULT', 'run_mode', '1') - - elif self.ui.mitama_passenger.isChecked(): - # 乘客 - self.conf.set('DEFAULT', 'run_mode', '2') - - elif self.ui.mitama_dual.isChecked(): - # 双开 - self.conf.set('DEFAULT', 'run_mode', '3') + self.conf.set('DEFAULT', 'run_mode', str(self.run_mode.get())) # 探索参数 self.conf.set('explore', 'fight_boss_enable', - str(self.ui.checkBox_2.isChecked())) + str(self.fight_boss_enable.get())) self.conf.set('explore', 'slide_shikigami', - str(self.ui.checkBox_3.isChecked())) + str(self.slide_shikigami.get())) self.conf.set('explore', 'slide_shikigami_progress', - str(self.ui.horizontalSlider.value())) + str(self.slide_shikigami_progress.get())) self.conf.set('explore', 'zhunbei_delay', - str(self.ui.lineEdit_3.text())) + str(self.zhunbei_delay.get())) self.conf.set('explore', 'change_shikigami', - str(self.ui.comboBox.currentIndex())) + str(self.change_shikigami)) def get_conf(self): # 添加配置 @@ -92,6 +76,9 @@ def start_onmyoji(self): # 读取主要副本 self.get_conf() + # 显示参数 + self.show_params() + subprocess.Popen("cmd.exe /c start onmyoji.exe") # os.system("onmyoji.exe") @@ -115,17 +102,15 @@ def my_excepthook(exc_type, exc_value, tb): if __name__ == "__main__": - try: # 检测管理员权限 if is_admin(): sys.excepthook = my_excepthook # 设置战斗参数 - app = QApplication(sys.argv) - myWin = MyMainWindow() - myWin.show() - sys.exit(app.exec_()) + root = tk.Tk() + app = MyBattle(root) + app.mainloop() else: ctypes.windll.shell32.ShellExecuteW(