From 53c17f0328f3342de4a12203412ee8f4f97efd4f Mon Sep 17 00:00:00 2001 From: EillesWan Date: Sun, 6 Mar 2022 23:46:35 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B2=A1=E6=9C=89=E5=81=9A=E4=BB=BB=E4=BD=95?= =?UTF-8?q?=E6=9B=B4=E6=94=B9=EF=BC=8C=E4=B8=8A=E4=BC=A0=E4=B8=80=E4=B8=8B?= =?UTF-8?q?=E5=81=9A=E5=A4=87=E4=BB=BD=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README_en.md | 2 +- bgArrayLib/bpm.py | 12 +++++- msctLib/display.py | 5 +++ msctLib/开发说明兼指南.md | 84 ++++++++++++++++++++++++++++----------- resources/myWords.txt | 8 ++++ 查看代码数.py | 7 ++-- 6 files changed, 88 insertions(+), 30 deletions(-) diff --git a/README_en.md b/README_en.md index 73c34b9..ba811ab 100644 --- a/README_en.md +++ b/README_en.md @@ -5,7 +5,7 @@ Musicreater(音·创) is an Eilles(*W-YI*)'s app that is used for creating music Welcome to join our QQ group: 861684859 -###Author +### Author Eilles (金羿):The main author, who developed the most and especially the principal parts of Musicreater, and its predecessors, which has been called as "*Minecraft Function Music Maker*", "*Note Fun Creater*", "*Note World Creater*"(now ,they are united as ***Musicreater***!) diff --git a/bgArrayLib/bpm.py b/bgArrayLib/bpm.py index 6e1f3f4..b6fdc30 100644 --- a/bgArrayLib/bpm.py +++ b/bgArrayLib/bpm.py @@ -1,12 +1,22 @@ import mido import numpy +''' +bpm +bites per minutes +每分钟的拍数 +''' def mt2gt(mt, tpb_a, bpm_a): return round(mt / tpb_a / bpm_a * 60) -def get(mid:mido.MidiFile): +def get(mid:mido.MidiFile) -> int: + '''传入一个 MidiFile, 返回其音乐的bpm + :param mid : mido.MidFile + mido库识别的midi文件数据 + :return bpm : int + ''' # mid = mido.MidiFile(mf) long = mid.length tpb = mid.ticks_per_beat diff --git a/msctLib/display.py b/msctLib/display.py index 039e3e5..38dfef9 100644 --- a/msctLib/display.py +++ b/msctLib/display.py @@ -62,8 +62,13 @@ class disp: menus.append(menu) def setWidget(self,**kwgs) -> None: + self._wordviewBar = tk.Label(self.root) pass + def setWordView(self, **kwgs) -> None: + for key,value in kwgs.items(): + self._wordviewBar[key] = value + diff --git a/msctLib/开发说明兼指南.md b/msctLib/开发说明兼指南.md index 57fb0e8..7ff22a3 100644 --- a/msctLib/开发说明兼指南.md +++ b/msctLib/开发说明兼指南.md @@ -1,16 +1,18 @@ - -# 开发说明\|指南 +开发说明\|指南 +============== 此文件旨在使后期欲参与开发之人员减轻其开发负担,同时也为了我们正在开发的人员详细说明功能与用法 掌握开发指南之后,在调用函数等的过程中将会更加方便 -## 文件结构 +文件结构 +-------- 从主文件调用display.py以实现显示,调用functions.py以使用功能 functions.py中会调取./addon/目录下的全部功能文件,这些功能文件必须先由./addon/addons.pkl来预先定义好 -## 详细说明 +详细说明 +-------- ### msctLib @@ -19,11 +21,12 @@ functions.py中会调取./addon/目录下的全部功能文件,这些功能文 #### display.py 1. class disp + - 参数 - 1. `**kwgs`对窗口的基础设定 - `{ '组件名称' : 函数自设定 }` - 例如: - ```python + + 1. `**kwgs`对窗口的基础设定 `{ '组件名称' : 函数自设定 }` 例如: + + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ python { 'version': '0.0.1', # version指的是当前配置格式的版本 'title': "音·创", @@ -38,8 +41,6 @@ functions.py中会调取./addon/目录下的全部功能文件,这些功能文 'widget': { #对窗口部件又详细说明 'wordview':{ 'text':'言·论', - 'bg':'black', - 'fg':'white' }, 'settingbox':{}, #后文详细说明 'tracklist':{}, @@ -47,34 +48,60 @@ functions.py中会调取./addon/目录下的全部功能文件,这些功能文 'map':{}, }, } - ``` + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + - 函数 + 1. `setMenu`对菜单的基础设定 - ```python + + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ python { 菜单名 : { 选项名 : 选项函数 } } - ``` - 注: + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + + 注: `菜单名` : `str` 显示在菜单上的字符串 `选项名` : `str` 显示在菜单选项上的字符串 `选项函数` : `function` 菜单调取的函数(无返回值,无入参) - 2. `setWidget`对窗口部件的放置 + 当 `选项名` 的布尔值判定为 `False` 的时候,无论 `选项函数` 为何,皆插入一段分割线 + + 2. `setWidget`对窗口部件的放置 ```python - wordview:dict = { - 'text':'言·论', - 'bg':'black', - 'fg':'white' + wordview: dict = { #言论部分显示的字样 + 'text': str = 显示内容, + # ... 即可用 tk.Label 的参数 }, - settingbox:{}, #后文详细说明 - tracklist:{}, - operation:{}, - map:{}, + settingbox: list = [ #设置部分显示的字样及其对应的设置函数 + (设置名称:str,值类型,显示内容:str,设置操作函数:function,) + ] + tracklist: int = 音轨数量 #音轨选择框 + operation: dict = { + 按钮名称 : 执行函数 + } + map: list = [ + 音符: class Note + ] ``` 注: + + 上文中,值类型可以是如下几个项 + 1. `('str',)` 字符串类型,使用文本框输入数据 + 2. `('bool',)` 布尔类型,使用复选框输入数据 + 3. `('num',最小值:int,最大值:int,步长:int = 1)` 数值类型,使用数值滑动条输入数据 + 4. `('list',列表项:list)` 单选类型,即列表中多选一,使用单选框输入数据 + 值得注意的是,在kwgs中修改的部件设置,可以在其变量中读取或热修改,对应的变量如下 + + | 参数 | 对应类中的变量 | 变量类型 | 说明 | + |------------|------------------|---------------------------|---------------------| + | wordview | wordview | str | 显示在 言·论 区域的文字 | + | settingbox | settings | list[ Any ] | 设置项目中的值 | + | tracklist | tracknum | tuple(int,int) | 当前选择到的音轨与音轨总数| + | operation | buttons | list[ tkinter.Button ] | 按钮列表 | + | map | notes | list[ class Note ] | 当前的音符列表 | @@ -82,4 +109,13 @@ functions.py中会调取./addon/目录下的全部功能文件,这些功能文 - + # 这里是全局设置 + 'name' : str, #项目名,即包名 + 'title': str, #音乐名称 + 'repeation': bool, #是否开启重复播放 + 'player_selection': str, #玩家选择器,用于选择播放的的玩家 + # 下面是音轨独立设置 + 'track_name': str, #此音轨的名字 + 'track_sbname': str, #此音轨所使用的计分板 + - 变量 + 使用类中的变量可以对类中的内容进行实时修改 diff --git a/resources/myWords.txt b/resources/myWords.txt index 45d8687..f241a69 100644 --- a/resources/myWords.txt +++ b/resources/myWords.txt @@ -73,3 +73,11 @@ A man achieve with challenges. 美酒宜人,宜人的却不只是美酒。 ——原神 戏会落幕,人生却不会。 ——原神 历史越久远,土地上的每一件事物就会承载更多价值。 ——原神 +深邃的灵魂唤起久远的回忆 +求索之人 当为奉之 +无论前路为星辰亦或深渊,皆需往而为之 +除了路途中的花与枫叶,还有心中的「道」 ——原神 +只有败北,才能感悟差距,才有机会成长 ——原神 +命运的邂逅,必定有其意义 ——原神 +万商云来,千船继至。\n百货迭出,诸海历览。\n ——原神 +现状越是难以置信,我们越是不能停下脚步。 ——原神 diff --git a/查看代码数.py b/查看代码数.py index 9683985..4887557 100644 --- a/查看代码数.py +++ b/查看代码数.py @@ -12,10 +12,9 @@ for path, dir_list, file_list in os.walk(r"./"): print("得到文件名:" + str(file)) for i in open(file, 'r', encoding="utf-8"): code = i.replace(' ', '').replace('\n', '') - try: - code -= code[code.index('#'):] - except: - pass + + if code.startswith('#'): + continue if code: print("\t" + code) m += 1