mirror of
https://github.com/TriM-Organization/Musicreater.git
synced 2025-09-05 11:56:23 +00:00
新增自动安装器
This commit is contained in:
@ -20,10 +20,6 @@ WHITE = (242, 244, 246)
|
||||
BLACK = (18, 17, 16)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
backgroundColor = WHITE
|
||||
frontgroundColor = BLACK
|
||||
loadingColor = DEFAULTBLUE
|
||||
@ -32,8 +28,7 @@ okColor = GREEN
|
||||
tipsColor = PURPLE
|
||||
|
||||
# 注:UI界面字体、代码字体
|
||||
fontPattern = ('DengXian Light','Fira Code')
|
||||
|
||||
fontPattern = ('DengXian Light', 'Fira Code')
|
||||
|
||||
|
||||
class disp:
|
||||
@ -68,49 +63,47 @@ class disp:
|
||||
|
||||
self.root = root
|
||||
|
||||
self.setTitle(title,debug)
|
||||
self.setGeometry(geometry,debug)
|
||||
self.setIcon(*iconbitmap,debug=debug)
|
||||
|
||||
self.setTitle(title, debug)
|
||||
self.setGeometry(geometry, debug)
|
||||
self.setIcon(*iconbitmap, debug=debug)
|
||||
|
||||
self.setMenu(menuWidget)
|
||||
|
||||
self.initWidget(wordView,buttons,settingBox,notemap)
|
||||
self.initWidget(wordView, buttons, settingBox, notemap)
|
||||
|
||||
def setTitle(self,title:str = '',debug : bool = False) -> None:
|
||||
def setTitle(self, title: str = '', debug: bool = False) -> None:
|
||||
'''设置窗口标题'''
|
||||
self.root.title = title
|
||||
if debug:
|
||||
log(f"设置窗口标题{title}")
|
||||
|
||||
|
||||
def setGeometry(self,geometry:str = '0x0',debug:bool = False) -> None:
|
||||
|
||||
def setGeometry(self, geometry: str = '0x0', debug: bool = False) -> None:
|
||||
'''设置窗口大小'''
|
||||
self.root.geometry(geometry)
|
||||
if debug:
|
||||
log(f"设置窗口大小{geometry}")
|
||||
|
||||
def setIcon(self,bitmap:str = './musicreater.ico',default:str = '',debug:bool = False) -> None:
|
||||
|
||||
def setIcon(self, bitmap: str = './musicreater.ico', default: str = '', debug: bool = False) -> None:
|
||||
'''设置窗口图标
|
||||
注意,default参数仅在Windows下有效,其意为将所有没有图标的窗口设置默认图标
|
||||
如果在非Windows环境使用default参数,一个Error将被升起'''
|
||||
if not debug:
|
||||
try:
|
||||
if default:
|
||||
self.root.iconbitmap(bitmap,default)
|
||||
self.root.iconbitmap(bitmap, default)
|
||||
log(f'设置图标为{bitmap},默认为{default}')
|
||||
else:
|
||||
self.root.iconbitmap(bitmap)
|
||||
log(f'设置图标为{bitmap}')
|
||||
return True
|
||||
except Exception as e:
|
||||
log(str(e),'ERROR')
|
||||
log(str(e), 'ERROR')
|
||||
return False
|
||||
else:
|
||||
self.root.iconbitmap(bitmap,default)
|
||||
return
|
||||
|
||||
def setMenu(self,menuWidgets: dict = {}) -> None:
|
||||
self.root.iconbitmap(bitmap, default)
|
||||
return
|
||||
|
||||
def setMenu(self, menuWidgets: dict = {}) -> None:
|
||||
'''设置根菜单'''
|
||||
if not menuWidgets:
|
||||
# 如果传入空参数则返回当前菜单
|
||||
@ -118,19 +111,19 @@ class disp:
|
||||
# 如果不是空参数则新建菜单
|
||||
self.RootMenu = {}
|
||||
self.mainMenuBar = tk.Menu(self.root)
|
||||
for menuName,menuCmd in menuWidgets.items():
|
||||
for menuName, menuCmd in menuWidgets.items():
|
||||
# 取得一个菜单名和一堆菜单函数及其显示名称
|
||||
menu = tk.Menu(self.mainMenuBar,tearoff=0)
|
||||
for cmdName,cmdFunc in menuCmd.items():
|
||||
menu = tk.Menu(self.mainMenuBar, tearoff=0)
|
||||
for cmdName, cmdFunc in menuCmd.items():
|
||||
if cmdName:
|
||||
menu.add_command(label = cmdName, command = cmdFunc)
|
||||
menu.add_command(label=cmdName, command=cmdFunc)
|
||||
else:
|
||||
menu.add_separator()
|
||||
self.mainMenuBar.add_cascade(label=menuName,menu=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:function = None):
|
||||
|
||||
def addMenu(self, menuRoot: str = '', menuLabel: str = '', menuCommand: function = None):
|
||||
'''增加一个菜单项
|
||||
:param menuRoot : str
|
||||
菜单的根菜单,即所属的菜单上的文字
|
||||
@ -142,21 +135,21 @@ class disp:
|
||||
# 如果已经有父菜单
|
||||
if menuLabel:
|
||||
# 增加菜单指令
|
||||
self.RootMenu[menuRoot].add_command(label = menuLabel, command = menuCommand)
|
||||
self.RootMenu[menuRoot].add_command(
|
||||
label=menuLabel, command=menuCommand)
|
||||
else:
|
||||
# 增加分隔栏
|
||||
self.RootMenu[menuRoot].add_separator()
|
||||
else:
|
||||
# 没有父菜单则新增一个父菜单
|
||||
menu = tk.Menu(self.mainMenuBar,tearoff=False)
|
||||
menu = tk.Menu(self.mainMenuBar, tearoff=False)
|
||||
if menuLabel:
|
||||
menu.add_command(label = menuLabel, command = menuCommand)
|
||||
menu.add_command(label=menuLabel, command=menuCommand)
|
||||
else:
|
||||
menu.add_separator()
|
||||
self.mainMenuBar.add_cascade(label=menuRoot,menu=menu)
|
||||
self.mainMenuBar.add_cascade(label=menuRoot, menu=menu)
|
||||
self.RootMenu[menuRoot] = menu
|
||||
|
||||
|
||||
def initWidget(self, wordView: str = '音·创 Musicreater', buttons: list = [],
|
||||
settingBox: list = [], notemap: list = []) -> None:
|
||||
'''设置窗口小部件,分为:
|
||||
@ -167,25 +160,25 @@ class disp:
|
||||
:各个音轨的显示框 TrackFrame
|
||||
:信息显示版 InfoBar
|
||||
'''
|
||||
self._wordviewBar = tk.Label(self.root,bg=frontgroundColor,fg=backgroundColor,text = wordView)
|
||||
self._wordviewBar = tk.Label(
|
||||
self.root, bg=frontgroundColor, fg=backgroundColor, text=wordView)
|
||||
|
||||
self.setWordView(wordView)
|
||||
|
||||
def setWordView(self, text:str) -> None:
|
||||
def setWordView(self, text: str) -> None:
|
||||
self._wordviewBar['text'] = text
|
||||
|
||||
|
||||
|
||||
|
||||
def authorMenu(authors:tuple = (('金羿','EillesWan@outlook.com'),('诸葛亮与八卦阵','474037765'))):
|
||||
def authorMenu(authors: tuple = (('金羿', 'EillesWan@outlook.com'), ('诸葛亮与八卦阵', '474037765'))):
|
||||
'''自定义作者界面'''
|
||||
from languages.lang import
|
||||
from languages.lang import _
|
||||
aabw = tk.Tk()
|
||||
aabw.title(READABLETEXT[9])
|
||||
aabw.title(_('关于'))
|
||||
aabw.geometry('550x600') # 像素
|
||||
tk.Label(aabw, text='', font=('', 15)).pack()
|
||||
tk.Label(aabw, text=READABLETEXT[10], font=('', 35)).pack()
|
||||
tk.Label(aabw, text=READABLETEXT[11].format(VER[1] + VER[0]), font=('', 15)).pack()
|
||||
tk.Label(aabw, text=READABLETEXT[11].format(
|
||||
VER[1] + VER[0]), font=('', 15)).pack()
|
||||
# pack 的side可以赋值为LEFT RTGHT TOP BOTTOM
|
||||
# grid 的row 是列数、column是行排,注意,这是针对空间控件本身大小来的,即是指向当前控件的第几个。
|
||||
# place的 x、y是(x,y)坐标
|
||||
@ -196,12 +189,14 @@ def authorMenu(authors:tuple = (('金羿','EillesWan@outlook.com'),('诸葛亮
|
||||
tk.Label(aabw, text=READABLETEXT[12], font=('', 20)).pack()
|
||||
tk.Label(aabw, text='', font=('', 15)).pack()
|
||||
for i in READABLETEXT[15]:
|
||||
tk.Label(aabw, text=i[0], font=('', 17 if i[1] else 15, 'bold' if i[1] else '')).pack()
|
||||
tk.Label(aabw, text=i[0], font=('', 17 if i[1]
|
||||
else 15, 'bold' if i[1] else '')).pack()
|
||||
tk.Label(aabw, text='', font=('', 5)).pack()
|
||||
if DEFAULTLANGUAGE != 'zh-CN':
|
||||
tk.Label(aabw, text=READABLETEXT[16], font=('', 15)).pack()
|
||||
for i in READABLETEXT['Translator']:
|
||||
tk.Label(aabw, text=i[0], font=('', 17 if i[1] else 15, 'bold' if i[1] else '')).pack()
|
||||
tk.Label(aabw, text=i[0], font=(
|
||||
'', 17 if i[1] else 15, 'bold' if i[1] else '')).pack()
|
||||
|
||||
def exitAboutWindow():
|
||||
aabw.destroy()
|
||||
@ -211,17 +206,10 @@ def authorMenu(authors:tuple = (('金羿','EillesWan@outlook.com'),('诸葛亮
|
||||
aabw.mainloop()
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
class ProgressBar:
|
||||
|
||||
def __init__(self,root:tk.Tk = tk.Tk(),style:tuple = (DEFAULTBLUE,BLACK,WHITE),
|
||||
type : bool = False, info : str = '', debug:bool = False) -> None:
|
||||
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
|
||||
建立进度条的根窗口
|
||||
@ -233,4 +221,4 @@ class ProgressBar:
|
||||
显示的附加信息
|
||||
:param debug : bool
|
||||
是否输出日志到控制台'''
|
||||
self.root = root
|
||||
self.root = root
|
||||
|
Reference in New Issue
Block a user