diff --git a/msctLib/display.py b/msctLib/display.py index 266ff66..34406d0 100644 --- a/msctLib/display.py +++ b/msctLib/display.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -'''音·创的GUI界面显示库 +'''音·创的GUI窗口界面显示库 :若要使用其他界面显示,请详见: :开发说明|指南''' @@ -7,14 +7,27 @@ import tkinter as tk import tkinter.simpledialog as sdialog import tkinter.filedialog as fdialog +from msctLib.log import log + + +DEFAULTBLUE = (0, 137, 242) +WEAKBLUE = (0, 161, 231) +LIGHTBLUE = (38, 226, 255) +RED = (255, 52, 50) +PURPLE = (171, 112, 255) +GREEN = (0, 255, 33) +WHITE = (242, 244, 246) +BLACK = (18, 17, 16) + -from tkinter import * -root = tk.Tk() class disp: - def __init__(self,root:tk.Tk = root,debug:bool = False,**kwgs) -> None: + # 正在修改,没改完 + def __init__(self,root:tk.Tk = tk.Tk(),debug:bool = False,title:str = '', + geometry : str = '0x0', iconbitmap : tuple = ('',''), menuWidget:dict = {}, + wordView : str = '音·创 Musicreater', ) -> None: '''传入root参数为窗口根,kwgs详见开发说明|指南''' self.root = root @@ -39,29 +52,54 @@ class disp: elif debug: raise KeyError(f'无法定位函数{func}') - def setTitle(self,title:str = '') -> None: + def setTitle(self,title:str = '',debug : bool = False) -> None: '''设置窗口标题''' self.root.title = title + if debug: + 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) + '''设置根菜单''' + if not kwgs: + return self.RootMenu + self.RootMenu = {} + self.mainMenuBar = tk.Menu(self.root) for menuName,menuCmd in kwgs.items(): - menu = tk.Menu(mainMenuBar,tearoff=0) + menu = tk.Menu(self.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) + self.mainMenuBar.add_cascade(label=menuName,menu=menu) + self.RootMenu[menuName] = menu + self.root.config(menu=self.mainMenuBar) + + def addMenu(self,menuRoot:str = '',menuLabel:str = '',menuCommand:str = None): + '''增加一个菜单项''' + if menuRoot in self.RootMenu.keys: + if menuLabel: + self.RootMenu[menuRoot].add_command(label = menuLabel, command = menuCommand) + else: + self.RootMenu[menuRoot].add_separator() + else: + menu = tk.Menu(self.mainMenuBar,tearoff=False) + if menuLabel: + menu.add_command(label = menuLabel, command = menuCommand) + else: + menu.add_separator() + self.mainMenuBar.add_cascade(label=menuRoot,menu=menu) + self.RootMenu[menuRoot] = menu + + def setWidget(self,**kwgs) -> None: self._wordviewBar = tk.Label(self.root) @@ -76,5 +114,17 @@ class disp: class ProgressBar: - def __init__(self,root) -> None: - pass \ No newline at end of file + def __init__(self,root:tk.Tk = tk.Tk(),style:tuple = (DEFAULTBLUE,BLACK,WHITE), + type : bool = False, info : str = '', debug:bool = False) -> None: + '''建立一个进度条或者加载等待界面 + :param root : tk.Tk + 建立进度条的根窗口 + :param style : tuple + 设置主题颜色,第一个参数为进度条或者等待转圈圈的颜色,第二个参数为前景色,第三个是背景色 + :param type : bool + 类型,为 False 时为进度条,为 True 时为等待板 + :param info : str + 显示的附加信息 + :param debug : bool + 是否输出日志到控制台''' + self.root = root \ No newline at end of file diff --git a/msctLib/log.py b/msctLib/log.py new file mode 100644 index 0000000..7562ef3 --- /dev/null +++ b/msctLib/log.py @@ -0,0 +1,78 @@ +"""音·创的日志消息处理""" +# 诸葛亮与八卦阵帮忙修改语法 日期:---2022年1月19日 +# 统计:致命(三级)错误:0个;警告(二级)错误:0个;语法(一级)错误:9个 + +# 对开发者说的话: +# +# 请不要修改这里的日志,日志是给开发者和专业人士看的 +# 而不是给普通用户看的,因此,没必要使用开发者自己也 +# 不习惯的日志系统,比如说,之前诸葛亮与八卦阵 (bgArray) +# 用了 logging 库来改写我原来的日志支持,但是我反 +# 而找不到我想要的信息了,所以,日志系统给我们开发者 +# 自己看得好就可以了昂,真的别改了。而且,诸葛八卦改 +# 了之后并没有多好,喵喵喵,所以我就换回来了。我知道 +# logging 库比较常用,而且功能也好,但是我们毕竟没 +# 这个必要,就别用那个库了昂,球球了~ +# ——金羿 Eilles +# 2022 03 09 + +# To ALL the developers who will change this part: +# +# Please do NOT change anything in this file! +# The log file is only for developers or +# someone who knows a lot about our program +# to see, but not the common users. So it +# is NOT NECESSARY to use a logging system +# that we do not familiar or we do not like. +# Take bgAray “诸葛亮与八卦阵” as a example, +# he once change this `log.py` into +# logging-library-based log support system. +# But after the change had done, I could NOT +# find useful infomation according to the +# log file... So use this file but not to +# make changes PLEASE!!! I know some libraries +# like logging is usually better than the +# simple system in this file and it is normal +# to use but, I think it is not necessery, +# so PLEASE DO NOT USE OTHER LIBs TO +# OVERWRITE MY LIBRARY, THANKS. +# ——Eilles 金羿 +# 03/09/2022 + + + +import datetime,os + +#载入日志功能 +StrStartTime = str(datetime.datetime.now()).replace(':', '_')[:-7] +'''字符串型的程序开始时间''' + + +def log(info:str = '',level : str = 'INFO', isPrinted:bool = False): + '''将信息连同当前时间载入日志 + :param info : str + 日志信息 + :param level : str['INFO','WARRING','ERROR','CRASH'] + 信息等级 + :param isPrinted : bool + 是否在控制台打印 + + :return bool + 表示是否完成任务''' + + try: + + if not os.path.exists('./log/'): + os.makedirs('./log/') + + outputinfo = f'{str(datetime.datetime.now())[11:19]}-[{level}] {info}' + + with open('./log/'+StrStartTime+'.msct.log', 'a',encoding='UTF-8') as f: + f.write(outputinfo+'\n') + + if isPrinted: + print(outputinfo) + + return True + except: + return False diff --git a/msctLib/settings.py b/msctLib/settings.py index 59f6adf..ac9b306 100644 --- a/msctLib/settings.py +++ b/msctLib/settings.py @@ -1,7 +1,14 @@ # -*- coding:utf-8 -*- - +DEFAULTBLUE = (0, 137, 242) +WEAKBLUE = (0, 161, 231) +LIGHTBLUE = (38, 226, 255) +RED = (255, 52, 50) +PURPLE = (171, 112, 255) +GREEN = (0, 255, 33) +WHITE = (242, 244, 246) +BLACK = (18, 17, 16) settings = { 'language' : 'zh-CN', diff --git a/msctLib/开发说明兼指南.md b/msctLib/开发说明兼指南.md index 7ff22a3..1864c76 100644 --- a/msctLib/开发说明兼指南.md +++ b/msctLib/开发说明兼指南.md @@ -66,7 +66,7 @@ functions.py中会调取./addon/目录下的全部功能文件,这些功能文 `菜单名` : `str` 显示在菜单上的字符串 `选项名` : `str` 显示在菜单选项上的字符串 `选项函数` : `function` 菜单调取的函数(无返回值,无入参) - 当 `选项名` 的布尔值判定为 `False` 的时候,无论 `选项函数` 为何,皆插入一段分割线 + 当 `选项名` 的布尔值判定为 `False` 的时候,无论 `选项函数` 为何,皆插入一段分割线,但 `选项函数` 不得为空 2. `setWidget`对窗口部件的放置 ```python diff --git a/msctspt/__pycache__/bugReporter.cpython-38.pyc b/msctspt/__pycache__/bugReporter.cpython-38.pyc index 618156f..22addb3 100644 Binary files a/msctspt/__pycache__/bugReporter.cpython-38.pyc and b/msctspt/__pycache__/bugReporter.cpython-38.pyc differ diff --git a/resources/myWords.txt b/resources/myWords.txt index 16276f7..e09b800 100644 --- a/resources/myWords.txt +++ b/resources/myWords.txt @@ -1,4 +1,4 @@ -生命灵动 当用激情跃起奋发之力 +生命灵动 当用激情跃起奋发之力 奇偶数阵 学海无涯 应用爱意徜徉 在生命的起源寻找灵魂的慰藉 @@ -83,3 +83,4 @@ A man achieve with challenges. 现状越是难以置信,我们越是不能停下脚步。 ——原神 古老的文明孕育着最美丽的传说 ——原神 百川奔流 雨露不休 +梦,随着年月流逝而不断消散