正在修改,没改完

This commit is contained in:
2022-03-09 22:10:54 +08:00
parent ed28fc4866
commit 052142ac08
6 changed files with 151 additions and 15 deletions

View File

@ -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
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