diff --git a/Musicreater.New.py b/Musicreater.New.py index 76b22de..4b64f3d 100644 --- a/Musicreater.New.py +++ b/Musicreater.New.py @@ -38,14 +38,9 @@ __ver__ = f'{version.version[1]} {version.version[0]}' __author__ = '金羿Eilles' -import tkinter -import tkinter.simpledialog as sdialog -import tkinter.filedialog as fdialog -from msctLib.settings import settings - diff --git a/msctLib/data.py b/msctLib/data.py index 4290dce..d913fd1 100644 --- a/msctLib/data.py +++ b/msctLib/data.py @@ -78,7 +78,7 @@ class jsonIO: class uniteIO: - def __init__(self,fileName:str,fileType,data: Any = None) -> None: + def __init__(self,fileName:str,fileType = None,data: Any = None) -> None: '''简单的文件数据IO操作功能''' self.filename = fileName if not fileType is None: @@ -91,21 +91,12 @@ class uniteIO: with open (self.file, 'rb') as f: self._type = pickle - if self._type == json: - with open (self.filename, 'r', encoding='utf-8') as f: - self._rfile = f - with open (self.filename, 'w', encoding='utf-8') as f: - self._wfile = f - elif self._type == pickle: - with open (self.file, 'rb') as f: - self._rfile = f - with open (self.file, 'wb') as f: - self._wfile = f + if not data is None: self._data = data else: - self._data = self._type.load(self._rfile) + self._data = self.load() def __call__(self, *args: Any, **kwds: Any) -> Any: @@ -113,11 +104,19 @@ class uniteIO: def write(self): '''将数据写入文件''' + if self._type == json: + self._wfile = open(self.filename, 'w', encoding='utf-8') + elif self._type == pickle: + self._wfile = open(self.file, 'wb') self._type.dump(self._data, self._wfile) def load(self) -> Any: '''从文件读取数据''' + if self._type == json: + self._rfile = open(self.filename, 'r', encoding='utf-8') + elif self._type == pickle: + self._rfile = open(self.file, 'rb') self._data = self._type.load(self._rfile) return self.data @@ -131,4 +130,4 @@ if __name__ == '__main__': from sys import argv if argv[1]: - input(pickle(argv[1]).data) \ No newline at end of file + input(uniteIO(argv[1]).data) \ No newline at end of file diff --git a/msctLib/display.py b/msctLib/display.py new file mode 100644 index 0000000..7832026 --- /dev/null +++ b/msctLib/display.py @@ -0,0 +1,47 @@ +# -*- coding: utf-8 -*- +'''音·创的GUI界面显示库 +:若要使用其他界面显示,请详见: +:开发说明|指南''' + + +import tkinter as tk +import tkinter.simpledialog as sdialog +import tkinter.filedialog as fdialog + +root = tk.Tk() + +class disp: + + def __init__(self,root:tk.Tk = root,debug:bool = False,**kwgs) -> None: + '''传入root参数为窗口根,kwgs详见开发说明|指南''' + + self.root = root + + self.FUNCLIST = { + 'title' : self.setTitle, + 'geometry': self.setGeometry, + 'iconbitmap': self.setIcon, + } + '''注:此处为引导传参,若传参错误且debug模式关闭则不会有任何反馈''' + + def setTitle(self,title:str = '') -> None: + self.root.title = title + + def setGeometry(self,geometry) -> None: + self.root.geometry(geometry) + + def setIcon(self,*icon) -> None: + self.root.iconbitmap(*icon) + + def setMenu(self,**kwgs) -> None: + menus = [] + mainMenuBar = tk.Menu(self.root) + for menuName,menuCmd in kwgs.items(): + menu = tk.Menu(mainMenuBar,tearoff=0) + for cmdName,cmdFunc in menuCmd.items(): + if cmdName: + menu.add_command(label = cmdName, command = cmdFunc) + else: + menu.add_separator() + mainMenuBar.add_cascade(label=menuName,menu=menu) + menus.append(menu) \ No newline at end of file diff --git a/msctLib/开发说明兼指南.md b/msctLib/开发说明兼指南.md new file mode 100644 index 0000000..13bb56b --- /dev/null +++ b/msctLib/开发说明兼指南.md @@ -0,0 +1,41 @@ + +# 开发说明\|指南 + +此文件旨在使后期欲参与开发之人员减轻其开发负担,同时也为了我们正在开发的人员详细说明功能与用法 +掌握开发指南之后,在调用函数等的过程中将会更加方便 + +## 文件结构 + +从主文件调用display.py以实现显示,调用functions.py以使用功能 + +functions.py中会调取./addon/目录下的全部功能文件,这些功能文件必须先由./addon/addons.pkl来预先定义好 + +## 详细说明 + +### msctLib + +用于支持主要功能 + +#### display.py + +1. class disp + - 参数 + 1. `**kwgs`对窗口的基础设定 + `{ '组件名称' : 函数自设定 }` + 例如: + ```python + { + 'version': '0.0.1' # version指的是 + 'title': "音·创", + 'geometry': '1200x900', + 'iconbitmap': ('./resources/musicreater.ico', './resources/musicreater.ico'), + 'menu' : { #对setMenu有特殊说明 + '文件': { + '新建': lambda : x, + '打开': lambda : x, + }, + }, + } + ``` + - 函数 + 1. `setMenu`对菜单的基础设定 diff --git a/options/__init__.py b/options/__init__.py deleted file mode 100644 index e69de29..0000000 diff --git a/resources/myWords.txt b/resources/myWords.txt index 74e57ac..45d8687 100644 --- a/resources/myWords.txt +++ b/resources/myWords.txt @@ -41,3 +41,35 @@ 一切过程与结果都不重要 重要的是热爱与真情 给大家带来笑容 这就是我存在的使命 不忘本源 牢记故地 +一厢情愿即是真 心海浮沉即为灵 +听戏时要点最红的名伶,\n遛鸟时要买最名贵的画眉\n——此即人生 ——原神 +「精巧」是千年的积淀,而其背后皆存于「意义」 +世事无常,悲喜难料 ——原神 +金钱在死亡面前毫不重要 +风雨兄弟情 +微笑面对现实 +人于磨难中练就 +Long live the People's Republic of China. +There is NO heroes, only honors. +A man achieve with challenges. +种果得果,等的就是这份收获的喜悦 ——原神 +事了拂衣去,深藏功与名 +万事开头虽难,倾注的情感也多;\n而欲永恒,仍需重新审视自身\n不小心处理,灵魂便留下裂纹无法挽回。 +历经历史的沉淀,留下希望的继承 +身为凡民,血脉脆弱,却也坚强 +民为本,社稷次之,君为轻 ——孟子 +不如归去 +你完成了你的职责,现在,去休息吧。 +一场长梦,梦醒之后,人就学会了诀别。 +你们——会祝福下一个时代吗? ——原神 +任何旅途中的旅伴同行,都会有分别的一日。 ——原神 +「永恒」最接近于天理 ——原神 +等旅途到达了终点,再考虑停留于何处吧。 ——原神 +人海中相遇,本是缘分。 ——原神 +凡缘朦朦仙缘滔 +因果红尘渺渺,烟消 ——原神 +未入尘世,而心远之 +灵心而静,莫问归期 +美酒宜人,宜人的却不只是美酒。 ——原神 +戏会落幕,人生却不会。 ——原神 +历史越久远,土地上的每一件事物就会承载更多价值。 ——原神 diff --git a/测试用/1.msct b/测试用/1.msct deleted file mode 100644 index 8857f37..0000000 Binary files a/测试用/1.msct and /dev/null differ