-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
7dc9ab5
commit 5cf16e5
Showing
31 changed files
with
992 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,171 @@ | ||
<div align="center"> | ||
|
||
简体中文 | [English](docs/README_en.md) | ||
|
||
<a><img src="static/logo/logo.png" alt="Logo" width="150" height="150"></a> | ||
|
||
<h3 align="center">DaCapo</h3> | ||
|
||
<p align="center"> | ||
一个配置文件为驱动的图形化脚本管理器 | ||
</p> | ||
</div> | ||
|
||
<details> | ||
<summary>目录</summary> | ||
<ol> | ||
<li><a href="#简介">简介</a></li> | ||
<li><a href="#执行策略">执行策略</a></li> | ||
<li> | ||
<a href="#使用指南">使用指南</a> | ||
<ul> | ||
<li><a href="#前置准备">前置准备</a></li> | ||
<li><a href="#安装">安装</a></li> | ||
<li><a href="#添加配置">添加配置</a></li> | ||
<li><a href="#全局设置">全局设置</a></li> | ||
<li><a href="#任务设置">任务设置</a></li> | ||
<li><a href="#开始运行">开始运行</a></li> | ||
</ul> | ||
</li> | ||
<li><a href="#使用示例">使用示例</a></li> | ||
<li><a href="#致谢">致谢</a></li> | ||
</ol> | ||
</details> | ||
|
||
## 简介 | ||
|
||
本项目旨在为有繁杂用户配置的程序提供图形化界面,开发者无需编写额外代码,只需按特定要求提供和使用JSON配置文件,即可为自己的程序创建GUI。同时对于用户而言,可以将多个程序脚本集中管理,很适合一些需要周期性执行的任务。 | ||
|
||
<img src="static/images/show.png" style="zoom:50%;" /> | ||
|
||
## 执行策略 | ||
|
||
每个左侧栏的选项被称为一个实例,一个实例内部可以包含若干个任务,目前这些任务根据优先级顺序执行,没有自动管理调度。 | ||
|
||
有多个实例时可以一键执行,此时所有前台实例顺序执行,后台实例则并发执行。所谓前后台实例指的是这个实例包含的任务是否占用屏幕键鼠等设备,能否完全后台执行。 | ||
|
||
## 使用指南 | ||
|
||
### 前置准备 | ||
|
||
在开始使用前,你需要提供一个配置模板,里面包含了需要生成的内容。在一个配置目录中,必须包含`args.json`,`i18n`则可以省略。具体来说,它应该是这样的结构: | ||
|
||
``` | ||
----Template/ # 该命名不重要 | ||
|----args.json | ||
|----i18n/ | ||
|----zh-CN.json | ||
|----en-US.json | ||
|----...... | ||
``` | ||
|
||
#### args.json | ||
|
||
该文件包含所有需要生成的配置内容,一共分为4级,分别代表任务组、任务、选项组、选项,其中**任务**是命令执行的单位。 | ||
|
||
第一个任务组用来做一些总体设置,其中**必须**包含一个"General"任务,而第一个任务组的所有任务都不会进入执行队列,你应该把要执行的任务的设置项放到后面的任务组中。 | ||
|
||
选项`argument`目前支持3种类型,分别是`input`输入框,`select`下拉框以及`checkbox`复选框。 | ||
|
||
> 注意,DaCapo不提供对input输入框内容的数据校验,你需要在自己的程序中处理可能的异常。 | ||
``` | ||
menu | ||
├── task | ||
│ ├── group | ||
│ │ ├── argument | ||
│ │ │ ├── type: "select" | ||
│ │ │ ├── value: "example" | ||
│ │ │ ├── option: ["this", "is", "an", "example"] | ||
│ │ │ └── ... | ||
``` | ||
|
||
<img src="static/images/architecture.png" style="zoom: 50%;" /> | ||
|
||
#### i18n | ||
|
||
这个目录下包含参数翻译及帮助信息,如果你只提供一种语言,但也想写一些帮助信息,可以创建一个该类json文件,把`name`留空只填写`help`。每个语种的json文件内是这样组织的: | ||
|
||
- 第一层分别是Menu任务组、Task任务、以及所有Group选项组。 | ||
|
||
<img src="static/images/trans1.png" style="zoom:50%;" /> | ||
|
||
- 第二层,对于Menu和Task来说是是任务组名、任务名的翻译。 | ||
|
||
<img src="static/images/trans2.png" style="zoom:50%;" /> | ||
|
||
而对于Group来说既包含了该Group的翻译(_info)也包含了其下所有设置项的翻译,若设置项为下拉框,则直接在name和help同级翻译所有选项。 | ||
|
||
<img src="static/images/trans3.png" style="zoom:50%;" /> | ||
|
||
|
||
|
||
然后, 你的程序应该接收一个json配置文件,这次省略了任务组,层级为`Task`任务-`Group`选项组-`Argument`选项,形式如下: | ||
|
||
<img src="static/images/config.png" style="zoom:50%;" /> | ||
|
||
|
||
|
||
### 安装 | ||
|
||
#### 获取发布版 | ||
|
||
你可以到[这里](https://github.com/Aues6uen11Z/DaCapo/releases)下载最新的发布版,目前仅支持Windows系统,解压后点击DaCapo.exe即可运行。 | ||
|
||
#### 从源码构建 | ||
|
||
新建Python3.6以上版本虚拟环境,安装`requirements.txt`的依赖包,执行`main.py`即可,应该没什么坑。 | ||
|
||
|
||
|
||
### 添加配置 | ||
|
||
打开程序后,首先点击齿轮图标进入设置页面,在“添加新实例”处选择”导入“,选择[前置准备](#前置准备)一节提到的模板目录。 | ||
|
||
> 注意不要点进该目录,目前文件浏览器无法返回上一级,点过头了只能重新选 | ||
然后输入新配置名,格式为实例名@模板名,最后点击应用。 | ||
|
||
> 同一个模板可以创建多个实例,已经导入过的模板下次可以选择“从已有模板创建” | ||
<img src="static/images/guide1.gif" style="zoom:50%;" /> | ||
|
||
|
||
|
||
### 全局设置 | ||
|
||
进入全局设置页面,也就是“General”任务对应的页面,重点注意“基本设置”一组。 | ||
|
||
<img src="static/images/guide2.png" style="zoom:50%;" /> | ||
|
||
|
||
|
||
### 任务设置 | ||
|
||
随后从第二个任务组开始,设置所有任务项,重点注意“任务设置”组。其中默认优先级数字越小优先级越高,修改将在下次启动时生效。 | ||
|
||
<img src="static/images/guide3.png" style="zoom:50%;" /> | ||
|
||
|
||
|
||
### 开始运行 | ||
|
||
所有设置完成后回到主页,检查等待队列中任务的顺序是否合适,若还想调整可以手动点击任务将其移动到终止队列,终止队列的任务将不再执行。 | ||
|
||
一切就绪后点击“运行”卡片右侧的开始按钮将开始单个实例,点击左栏开始按钮将开始所有实例任务。 | ||
|
||
任务执行情况可以通过日志面板观察,`dacapo.log`文件也会记录一些粗粒度信息。 | ||
|
||
## 使用示例 | ||
|
||
三言两语可能难以表达清楚,建议结合[示例](https://github.com/Aues6uen11Z/DaCapo/tree/master/examples/SimpleScript)理解,若仍有疑问欢迎在Issue中提问,也欢迎PR来补充文档。 | ||
|
||
## 致谢 | ||
|
||
[NiceGUI](https://github.com/zauberzeug/nicegui):本项目使用的GUI库,功能灵活强大,维护者十分友善且回复极快,社区也非常活跃。 | ||
|
||
[niceguiToolkit](https://github.com/CrystalWindSnake/nicegui-toolkit):一个NiceGUI辅助工具,作者也是很乐于助人,其教程和答疑让我受益匪浅,B站/微信公众号同名:数据大宇宙,学NiceGUI找他就对了! | ||
|
||
[SRC](https://github.com/LmeSzinc/StarRailCopilot)/[ALAS](https://github.com/LmeSzinc/AzurLaneAutoScript):一切的开始,本项目仿照了其页面布局和配置文件方式。 | ||
|
||
[Nuitka](https://github.com/Nuitka/Nuitka):本项目使用的打包工具。 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,168 @@ | ||
<div align="center"> | ||
|
||
[简体中文](../README.md) | English | ||
|
||
<a><img src="../static/logo/logo.png" alt="Logo" width="150" height="150"></a> | ||
|
||
<h3 align="center">DaCapo</h3> | ||
|
||
<p align="center"> | ||
A graphical script manager driven by configuration files | ||
</p> | ||
</div> | ||
|
||
<details> | ||
<summary>Table of Contents</summary> | ||
<ol> | ||
<li><a href="#Introduction">Introduction</a></li> | ||
<li><a href="#Execution-strategy">Execution Strategy</a></li> | ||
<li> | ||
<a href="#Getting Start">Getting Start</a> | ||
<ul> | ||
<li><a href="#Preparation">Preparation</a></li> | ||
<li><a href="#Installation">Installation</a></li> | ||
<li><a href="#Adding-configuration">Adding Configuration</a></li> | ||
<li><a href="#Global-settings">Global Settings</a></li> | ||
<li><a href="#Task-settings">Task Settings</a></li> | ||
<li><a href="#Start-running">Start Running</a></li> | ||
</ul> | ||
</li> | ||
<li><a href="#Usage-examples">Usage Examples</a></li> | ||
<li><a href="#Acknowledgements">Acknowledgements</a></li> | ||
</ol> | ||
</details> | ||
|
||
## Introduction | ||
|
||
This project aims to provide a graphical interface for programs with complex user configurations. Developers do not need to write additional code, but only need to provide and use JSON configuration files according to specific requirements to create a GUI for their programs. At the same time, for users, it allows for centralized management of multiple program scripts, which is very suitable for tasks that require periodic execution. | ||
|
||
<img src="../static/images/show_en.png" style="zoom:50%;" /> | ||
|
||
## Execution Strategy | ||
|
||
Each option in the left sidebar is referred to as an instance. An instance can contain several tasks, which currently execute in order of priority without automatic management scheduling. | ||
|
||
When there are multiple instances, they can be executed with a single click. At this point, all foreground instances execute sequentially, while background instances execute concurrently. The term foreground and background instances refers to whether the tasks contained in the instance require screen, keyboard, and mouse devices, and whether they can be executed completely in the background. | ||
|
||
## Getting Start | ||
|
||
### Preparation | ||
|
||
Before you start using it, you need to provide a configuration template that includes the content to be generated. In a configuration directory, `args.json` must be included, while `i18n` can be omitted. Specifically, the structure should look like this: | ||
|
||
``` | ||
----Template/ # Dirname is not import | ||
|----args.json | ||
|----i18n/ | ||
|----zh-CN.json | ||
|----en-US.json | ||
|----...... | ||
``` | ||
|
||
#### args.json | ||
|
||
This file contains all the configuration content that needs to be generated, divided into 4 levels, representing task groups, tasks, option groups, and options, respectively, with **tasks** being the units of command execution. | ||
|
||
The first task group is used for overall settings, which **must** include a “General” task, and none of the tasks in the first task group will enter the execution queue. You should place the settings for tasks you want to execute in the subsequent task groups. | ||
|
||
The `argument` option currently supports 3 types: `input` for text input fields, `select` for dropdown menus, and `checkbox` for check boxes. | ||
|
||
> Note that DaCapo does not provide data validation for the content of input fields, and you will need to handle possible exceptions within your own program. | ||
``` | ||
menu | ||
├── task | ||
│ ├── group | ||
│ │ ├── argument | ||
│ │ │ ├── type: "select" | ||
│ │ │ ├── value: "example" | ||
│ │ │ ├── option: ["this", "is", "an", "example"] | ||
│ │ │ └── ... | ||
``` | ||
|
||
<img src="../static/images/architecture.png" style="zoom: 50%;" /> | ||
|
||
#### i18n | ||
|
||
This directory contains parameter translations and help information. If you provide only one language but still want to write some help information, you can create a JSON file of this kind, leaving `name` empty and filling in only `help`. The JSON file for each language is organized as follows: | ||
|
||
- The first level consists of the Menu task group, Task tasks, and all Group option groups. | ||
|
||
<img src="../static/images/trans1.png" style="zoom:50%;" /> | ||
|
||
- The second level consists of translations for the names of task groups and tasks for Menu and Task. | ||
|
||
<img src="../static/images/trans2.png" style="zoom:50%;" /> | ||
|
||
- For Group, it includes not only the translation of the Group itself ($_info) but also the translations of all its setting items. If a setting item is a dropdown menu, then all options are translated at the same level as name and help. | ||
|
||
<img src="../static/images/trans3.png" style="zoom:50%;" /> | ||
|
||
|
||
Next, your program should accept a JSON configuration file. This time, the task group level is omitted, and the hierarchy is `Task` - `Group` - `Argument`, as follows: | ||
|
||
<img src="../static/images/config.png" style="zoom:50%;" /> | ||
|
||
|
||
|
||
### Installation | ||
|
||
#### Obtain the Release Version | ||
You can download the latest release version [here](https://github.com/Aues6uen11Z/DaCapo/releases). Currently, only Windows systems are supported. After extracting the files, click on DaCapo.exe to run the application. | ||
|
||
#### Building from Source Code | ||
Create a Python virtual environment with version 3.6 or higher, install the dependencies listed in `requirements.txt`, and then execute `main.py`. There shouldn’t be any major issues. | ||
|
||
|
||
|
||
### Adding Configuration | ||
|
||
Once the program is open, click on the gear icon to enter the settings page. At the “Add New Instance” section, choose “Import,” and select the template directory mentioned in the [Preparation](#preparation) section. | ||
|
||
> Note: Do not navigate into the directory, as the file browser currently cannot go back to the previous level. If you go too far, you will have to select again. | ||
Then, enter a new configuration name in the format of instance name@template name, and finally, click Apply. | ||
|
||
> You can create multiple instances from the same template. For templates that have already been imported, you can choose “From template” the next time. | ||
<img src="../static/images/guide1.gif" style="zoom:50%;" /> | ||
|
||
|
||
|
||
### Global Settings | ||
|
||
Navigate to the global settings page, which corresponds to the “General” task page. Pay close attention to the “Basic Settings” group. | ||
|
||
<img src="../static/images/guide2.png" style="zoom:50%;" /> | ||
|
||
|
||
|
||
### Task Settings | ||
|
||
After setting the “General” task, proceed to configure all tasks starting from the second task group. Pay close attention to the “Task Settings” group. The default priority is set by a numerical value, with smaller numbers indicating higher priority. Changes will take effect upon the next startup. | ||
|
||
<img src="../static/images/guide3.png" style="zoom:50%;" /> | ||
|
||
|
||
|
||
### Start Running | ||
|
||
Once all settings are completed, return to the homepage and check if the order of tasks in the waiting queue is appropriate. If you want to make adjustments, you can manually click on a task to move it to the termination queue, and tasks in the termination queue will not be executed. | ||
|
||
When everything is ready, click the start button on the right side of the “Run” card to begin a single instance, or click the start button on the left sidebar to begin all instance tasks. | ||
|
||
The status of task execution can be observed through the log panel, and the `dacapo.log` file will also record some coarse-grained information. | ||
|
||
## Usage Examples | ||
|
||
The screenshot above shows the interface in Chinese, but you can easily switch to an English interface in the settings. It may be challenging to explain everything clearly in a few words, so it’s recommended to refer to the [example](https://github.com/Aues6uen11Z/DaCapo/tree/master/examples/SimpleScript) for a better understanding. If you have any further questions, please don’t hesitate to ask them in an Issue, and you are also welcome to submit a PR to help improve the documentation. | ||
|
||
## Acknowledgements | ||
|
||
[NiceGUI](https://github.com/zauberzeug/nicegui):The GUI library used in this project, which is versatile and powerful. The maintainers are very friendly and respond quickly, and the community is also very active. | ||
|
||
[niceguiToolkit](https://github.com/CrystalWindSnake/nicegui-toolkit):An auxiliary tool for NiceGUI, the author of which is also very helpful. His tutorials and answers to questions have been very beneficial to me. | ||
|
||
[SRC](https://github.com/LmeSzinc/StarRailCopilot)/[ALAS](https://github.com/LmeSzinc/AzurLaneAutoScript):Where it all began, this project imitates their page layout and configuration file approach. | ||
|
||
[Nuitka](https://github.com/Nuitka/Nuitka):The packaging tool used in this project. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import json | ||
import os | ||
import random | ||
import time | ||
import logging | ||
|
||
logging.basicConfig(level=logging.DEBUG, format='%(asctime)s - %(levelname)s - %(message)s') | ||
logging.getLogger() | ||
|
||
|
||
path = 'config.json' | ||
logging.info(os.path.abspath(path)) | ||
with open(path, 'r') as f: | ||
config = json.load(f) | ||
|
||
for i in range(10): | ||
time.sleep(1) | ||
logging.info(config['Task1']['Group3']['setting1']) | ||
logging.info(config['Task1']['Group3']['setting2']) | ||
logging.info(config['Task1']['Group3']['setting3']) | ||
if random.random() < 0.05: | ||
logging.error(f'Error occurred') | ||
raise Exception("Error occurred") |
Oops, something went wrong.