Browse Source

feat: 管理界面新增菜单

SongZihuan 3 years ago
parent
commit
e8f5fa4f44
9 changed files with 425 additions and 118 deletions
  1. 3 0
      conf/__init__.py
  2. 87 37
      control/admin.py
  3. 0 9
      control/admin_event.py
  4. 115 31
      control/admin_menu.py
  5. 197 12
      control/admin_program.py
  6. 5 4
      control/event.py
  7. 14 17
      control/station.py
  8. 0 6
      control/station_event.py
  9. 4 2
      tool/tk.py

+ 3 - 0
conf/__init__.py

@@ -42,3 +42,6 @@ tk_refresh_delay = 50  # 延时任务的时间
 qr_show_uid_len = 12  # qr 码上展示uid的长度
 tk_show_uid_len = qr_show_uid_len  # tk 界面上展示uid的长度
 ranking_tk_show_uid_len = tk_show_uid_len  # tk ranking 界面上展示uid的长度
+
+tk_win_bg = "#fffffb"  # tkinter manager 窗口 按钮标准颜色
+tk_btn_bg = "#dcdcdc"  # tkinter 按钮 按钮标准颜色

+ 87 - 37
control/admin.py

@@ -98,6 +98,9 @@ class AdminStationBase(TkEventMain, metaclass=abc.ABCMeta):
         else:
             return False
 
+    def logout(self):
+        self._admin = None
+
     @abc.abstractmethod
     def show_loading(self, title: str):
         ...
@@ -110,6 +113,22 @@ class AdminStationBase(TkEventMain, metaclass=abc.ABCMeta):
     def set_after_run(self, ms, func, *args):
         ...
 
+    @abc.abstractmethod
+    def to_menu(self, name: str = "Main"):
+        ...
+
+    @abc.abstractmethod
+    def to_program(self, name: str = "Welcome"):
+        ...
+
+    @abc.abstractmethod
+    def show_msg(self, title, info, msg_type='info'):
+        ...
+
+    @abc.abstractmethod
+    def hide_msg(self):
+        ...
+
 
 import admin_program as tk_program
 import admin_menu as tk_menu
@@ -145,7 +164,8 @@ class AdminStation(AdminStationBase):
         self._full_screen = False
         self._is_loading = False
         self._disable_all_btn = False
-        self._now_program: Optional[Tuple[str, tk.Frame, tk_program.AdminProgram]] = None
+        self._menu_now: Optional[Tuple[str, tk.Frame, tk_menu.AdminMenu]] = None
+        self._program_now: Optional[Tuple[str, tk.Frame, tk_program.AdminProgram]] = None
 
         self.__conf_font_size()
         self.__conf_creak_tk()
@@ -210,40 +230,55 @@ class AdminStation(AdminStationBase):
 
         for bt in self._win_ctrl_button:
             bt: tk.Button
-            bt['bg'] = "#B0C4DE"  # 浅钢青
+            bt['bg'] = conf.tk_btn_bg
             bt['font'] = title_font
 
         rely = 0.02
-        bt_help: tk.Button = self._win_ctrl_button[0]
-        bt_help['text'] = 'Back'
-        bt_help['bg'] = '#DCDCDC'
-        bt_help.place(relx=0.69, rely=rely, relwidth=0.05, relheight=0.05)
+        bt_back: tk.Button = self._win_ctrl_button[0]
+        bt_back['text'] = 'Back'
+        bt_back['state'] = 'disable'
+        bt_back['command'] = lambda: self.__to_back_menu()
+        bt_back.place(relx=0.69, rely=rely, relwidth=0.05, relheight=0.05)
 
-        bt_about: tk.Button = self._win_ctrl_button[1]
-        bt_about['text'] = 'Main'
-        bt_about['bg'] = '#DCDCDC'
-        bt_about.place(relx=0.75, rely=rely, relwidth=0.05, relheight=0.05)
+        bt_main: tk.Button = self._win_ctrl_button[1]
+        bt_main['text'] = 'Main'
+        bt_main['command'] = lambda: self.__to_main_menu()
+        bt_main.place(relx=0.75, rely=rely, relwidth=0.05, relheight=0.05)
 
         bt_help: tk.Button = self._win_ctrl_button[2]
         bt_help['text'] = 'Help'
-        bt_help['bg'] = '#DCDCDC'
         bt_help.place(relx=0.81, rely=rely, relwidth=0.05, relheight=0.05)
 
         bt_about: tk.Button = self._win_ctrl_button[3]
         bt_about['text'] = 'About'
-        bt_about['bg'] = '#DCDCDC'
         bt_about.place(relx=0.87, rely=rely, relwidth=0.05, relheight=0.05)
 
         bt_exit: tk.Button = self._win_ctrl_button[4]
         bt_exit['text'] = 'Exit'
-        bt_exit['bg'] = '#DCDCDC'
         bt_exit['command'] = lambda: self.main_exit()
         bt_exit.place(relx=0.93, rely=rely, relwidth=0.05, relheight=0.05)
 
+    def set_ctrl_back_button(self):
+        if len(self._menu_list) <= 1:
+            self._win_ctrl_button[0]['state'] = 'disable'
+        else:
+            self._win_ctrl_button[0]['state'] = 'normal'
+
+    def __to_main_menu(self):
+        self._menu_list = []
+        self.to_menu()
+        self.to_program()
+
+    def __to_back_menu(self):
+        assert len(self._menu_list) > 1
+        self._menu_list.pop()  # 弹出最后一个元素
+        self.to_menu(self._menu_list.pop())  # 再弹出一个元素
+
     def __conf_creak_menu(self):
-        frame_list = [
-            tk_menu.MainMenu(self, self._menu_back, '#fffffb')
-        ]
+        frame_list = []
+
+        for i in tk_menu.all_menu:
+            frame_list.append(i(self, self._menu_back, conf.tk_win_bg))
 
         for i in frame_list:
             name, _ = i.get_menu_frame()
@@ -252,15 +287,15 @@ class AdminStation(AdminStationBase):
     def __conf_menu(self, n: int = 1):
         for i in self._menu_dict:
             menu = self._menu_dict[i]
-            menu.conf_gui("#DCDCDC", n)
+            menu.conf_gui(conf.tk_btn_bg, n)
 
     def __conf_menu_title(self):
-        self._menu_back['bg'] = "#fffffb"
+        self._menu_back['bg'] = conf.tk_win_bg
         self._menu_back['bd'] = 5
         self._menu_back['relief'] = "ridge"
 
         title_font = make_font(size=self._menu_title_font_size, weight="bold")
-        self._menu_title[0]['bg'] = '#fffffb'
+        self._menu_title[0]['bg'] = conf.tk_win_bg
         self._menu_title[0]['font'] = title_font
         self._menu_title[0]['textvariable'] = self._menu_title[1]
 
@@ -268,9 +303,14 @@ class AdminStation(AdminStationBase):
         # 不立即显示
 
     def to_menu(self, name: str = "Main"):
+        if self._menu_now is not None:
+            self._menu_now[1].place_forget()
+
         menu = self._menu_dict.get(name)
         if menu is None:
-            ...
+            self.show_msg("Menu not found", f"System can not found menu:\n  {name}")
+            return
+
         name, frame = menu.get_menu_frame()
         self._menu_title[1].set(name)
 
@@ -280,9 +320,11 @@ class AdminStation(AdminStationBase):
         frame.place(relx=0.02, rely=0.07, relwidth=0.96, relheight=0.84)
 
         self._menu_list.append(name)
+        self._menu_now = name, frame, menu
+        self.set_ctrl_back_button()
 
     def __conf_program_title(self):
-        self._program_back['bg'] = "#fffffb"
+        self._program_back['bg'] = conf.tk_win_bg
         self._program_back['relief'] = "ridge"
         self._program_back['bd'] = 5
 
@@ -292,13 +334,12 @@ class AdminStation(AdminStationBase):
         self._program_title[0]['font'] = title_font
         self._program_title[0]['anchor'] = 'w'
         self._program_title[0]['textvariable'] = self._program_title[1]
-
         # 不立即显示
 
     def __conf_creak_program(self):
-        program_list = [
-            tk_program.WelcomeProgram(self, self._program_back, '#fffffb')
-        ]
+        program_list = []
+        for i in tk_program.all_program:
+            program_list.append(i(self, self._program_back, conf.tk_win_bg))
 
         for i in program_list:
             name, _ = i.get_program_frame()
@@ -310,9 +351,14 @@ class AdminStation(AdminStationBase):
             program.conf_gui(n)
 
     def to_program(self, name: str = "Welcome"):
+        if self._program_now is not None:
+            self._program_now[1].place_forget()
+
         program = self._program_dict.get(name)
         if program is None:
-            ...
+            self.show_msg("Program not found", f"System can not found program:\n  {name}")
+            return
+
         name, frame = program.get_program_frame()
 
         self.__show_program()
@@ -322,7 +368,7 @@ class AdminStation(AdminStationBase):
 
         frame.place(relx=0.02, rely=0.12, relwidth=0.96, relheight=0.86)
 
-        self._now_program = name, frame, program
+        self._program_now = name, frame, program
 
     def __show_program(self):
         self._program_back.place(relx=0.26, rely=0.1, relwidth=0.68, relheight=0.84)
@@ -352,18 +398,18 @@ class AdminStation(AdminStationBase):
         title_font = make_font(size=self._msg_font_size + 1, weight="bold")
         info_font = make_font(size=self._msg_font_size - 1)
 
-        self._msg_frame['bg'] = "#fffffb"
+        self._msg_frame['bg'] = conf.tk_win_bg
         self._msg_frame['bd'] = 5
         self._msg_frame['relief'] = "ridge"
         # frame 不会立即显示
 
         self._msg_label[0]['font'] = title_font
-        self._msg_label[0]['bg'] = "#fffffb"
+        self._msg_label[0]['bg'] = conf.tk_win_bg
         self._msg_label[0]['anchor'] = 'w'
         self._msg_label[0]['textvariable'] = self._msg_label[2]
 
         self._msg_label[1]['font'] = info_font
-        self._msg_label[1]['bg'] = "#fffffb"
+        self._msg_label[1]['bg'] = conf.tk_win_bg
         self._msg_label[1]['anchor'] = 'nw'
         self._msg_label[1]['textvariable'] = self._msg_label[3]
         self._msg_label[1]['justify'] = 'left'
@@ -373,7 +419,7 @@ class AdminStation(AdminStationBase):
 
         self._msg_hide['font'] = info_font
         self._msg_hide['text'] = 'close'
-        self._msg_hide['bg'] = "#DCDCDC"
+        self._msg_hide['bg'] = conf.tk_btn_bg
         self._msg_hide['command'] = lambda: self.hide_msg()
         self._msg_hide.place(relx=0.375, rely=0.80, relwidth=0.25, relheight=0.13)
 
@@ -388,12 +434,11 @@ class AdminStation(AdminStationBase):
         self._msg_label[1]['wraplength'] = frame_width * 0.85 - 5  # 设定自动换行的像素
 
         self._msg_frame.place(relx=0.30, rely=0.25, relwidth=0.55, relheight=0.50)
-        self.__hide_program()
+        # 不隐藏元素, 隐藏后界面会显得单调
 
     def hide_msg(self):
         self.set_reset_all_btn()
         self._msg_frame.place_forget()
-        self.__show_program()
 
     def set_all_btn_disable(self):
         for btn in self._win_ctrl_button[:-1]:  # Exit 不设置disable
@@ -404,20 +449,21 @@ class AdminStation(AdminStationBase):
             assert menu is not None
             menu.set_disable()
 
-        if self._now_program is not None:
-            self._now_program[2].set_disable()
+        if self._program_now is not None:
+            self._program_now[2].set_disable()
 
     def set_reset_all_btn(self):
         for btn in self._win_ctrl_button[:-1]:
             btn['state'] = 'normal'
 
+        self.set_ctrl_back_button()
         if self._menu_list != 0:
             menu = self._menu_dict.get(self._menu_list[-1], None)
             assert menu is not None
             menu.reset_disable()
 
-        if self._now_program is not None:
-            self._now_program[2].reset_disable()
+        if self._program_now is not None:
+            self._program_now[2].reset_disable()
 
     def __show_login_window(self):
         self.login_window: Optional[tk.Toplevel] = tk.Toplevel()
@@ -488,6 +534,10 @@ class AdminStation(AdminStationBase):
             self._login_name[2].set('')
             self._login_passwd[2].set('')
 
+    def logout(self):
+        super(AdminStation, self).logout()
+        self.__show_login_window()
+
     def login_exit(self):
         if not msg.askokcancel('Sure?', 'Exit manager system.'):
             return

+ 0 - 9
control/admin_event.py

@@ -17,12 +17,6 @@ class AdminEventBase(TkEventBase):
     def get_title(self) -> str:
         return "AdminEvent"
 
-    def is_end(self) -> bool:
-        raise TkEventException
-
-    def done_after_event(self):
-        raise TkEventException
-
 
 class LoginEvent(AdminEventBase):
     def __init__(self, station):
@@ -54,6 +48,3 @@ class TestProgressEvent(AdminEventBase):
 
     def is_end(self) -> bool:
         return not self.thread.is_alive()
-
-    def done_after_event(self):
-        ...

+ 115 - 31
control/admin_menu.py

@@ -2,52 +2,39 @@ import abc
 import tkinter as tk
 
 from tool.type_ import *
-from tool.tk import make_font, set_button_disable_from_list
+from tool.tk import make_font, set_tk_disable_from_list
 
 import admin
 
 
 class AdminMenu(metaclass=abc.ABCMeta):
-    def __init__(self, station: admin.AdminStationBase, win: Union[tk.Frame, tk.Toplevel, tk.Tk], color: str):
+    def __init__(self, station: admin.AdminStationBase, win: Union[tk.Frame, tk.Toplevel, tk.Tk], color: str,
+                 title: str):
         self.station = station
         self.win = win
         self.color = color
-
-    @abc.abstractmethod
-    def set_disable(self):
-        ...
-
-    @abc.abstractmethod
-    def reset_disable(self):
-        ...
-
-    @abc.abstractmethod
-    def conf_gui(self, color: str, n: int = 1):
-        ...
-
-    @abc.abstractmethod
-    def get_menu_frame(self) -> Tuple[str, tk.Frame]:
-        ...
-
-
-class MainMenu(AdminMenu):
-    def __init__(self, station, win, color):
-        super(MainMenu, self).__init__(station, win, color)
         self.frame = tk.Frame(self.win)
         self.frame['bg'] = color
-
-        self.btn: List[tk.Button] = [tk.Button(self.frame) for _ in range(5)]
+        self.menu_title = title
+        self.btn: List[tk.Button] = []
+        self.btn_name: List[str] = []
         self.__conf_font()
 
     def __conf_font(self, n: int = 1):
         self.btn_font_size = int(16 * n)
 
+    def set_disable(self):
+        set_tk_disable_from_list(self.btn)
+
+    def reset_disable(self):
+        set_tk_disable_from_list(self.btn, flat='normal')
+
     def conf_gui(self, color: str, n: int = 1):
         self.__conf_font(n)
 
         btn_font = make_font(size=self.btn_font_size, weight="bold")
         height = 0.02
-        for btn, text in zip(self.btn, ["Creat", "Delete", "Search", "Update", "Logout"]):
+        for btn, text in zip(self.btn, self.btn_name):
             btn['font'] = btn_font
             btn['text'] = text
             btn['bg'] = color
@@ -55,10 +42,107 @@ class MainMenu(AdminMenu):
             height += 0.1 + 0.02
 
     def get_menu_frame(self) -> Tuple[str, tk.Frame]:
-        return "Main", self.frame
+        return self.menu_title, self.frame
 
-    def set_disable(self):
-        set_button_disable_from_list(self.btn)
 
-    def reset_disable(self):
-        set_button_disable_from_list(self.btn, flat='normal')
+class MainMenu(AdminMenu):
+    def __init__(self, station, win, color):
+        super().__init__(station, win, color, "Main")
+        self.btn: List[tk.Button] = [tk.Button(self.frame) for _ in range(5)]
+        self.btn_name = ["Creat", "Delete", "Search", "Update", "Logout"]
+
+    def conf_gui(self, color: str, n: int = 1):
+        super().conf_gui(color, n)
+        self.btn[0]['command'] = lambda: self.creat_command()
+        self.btn[1]['command'] = lambda: self.delete_command()
+        self.btn[2]['command'] = lambda: self.search_command()
+        self.btn[3]['command'] = lambda: self.update_command()
+        self.btn[4]['command'] = lambda: self.logout_command()
+
+    def creat_command(self):
+        self.station.to_menu("Creat")
+
+    def delete_command(self):
+        self.station.to_menu("Delete")
+
+    def search_command(self):
+        self.station.to_menu("Search")
+
+    def update_command(self):
+        self.station.to_menu("Update")
+
+    def logout_command(self):
+        self.station.logout()
+
+
+class CreatMenu(AdminMenu):
+    def __init__(self, station, win, color):
+        super().__init__(station, win, color, "Creat")
+        self.btn: List[tk.Button] = [tk.Button(self.frame) for _ in range(4)]
+        self.btn_name = ["NormalUser", "AutoNormalUser", "ManagerUser", "Garbage"]
+
+    def conf_gui(self, color: str, n: int = 1):
+        super().conf_gui(color, n)
+        self.btn[0]['command'] = lambda: self.creat_normal_user()
+        self.btn[1]['command'] = lambda: self.creat_auto_user()
+        self.btn[2]['command'] = lambda: self.creat_manager_user()
+        self.btn[3]['command'] = lambda: self.creat_garbage()
+
+    def creat_normal_user(self):
+        self.station.to_program("CreatNormalUser")
+
+    def creat_auto_user(self):
+        self.station.to_program("CreatAutoNormalUser")
+
+    def creat_manager_user(self):
+        self.station.to_program("CreatManagerUser")
+
+    def creat_garbage(self):
+        self.station.to_program("CreatGarbage")
+
+
+class DeleteMenu(AdminMenu):
+    def __init__(self, station, win, color):
+        super().__init__(station, win, color, "Delete")
+        self.btn: List[tk.Button] = [tk.Button(self.frame) for _ in range(4)]
+        self.btn_name = ["User", "Users", "Garbage", "AllGarbage"]
+
+    def conf_gui(self, color: str, n: int = 1):
+        super().conf_gui(color, n)
+
+
+class SearchMenu(AdminMenu):
+    def __init__(self, station, win, color):
+        super().__init__(station, win, color, "Search")
+        self.btn: List[tk.Button] = [tk.Button(self.frame) for _ in range(6)]
+        self.btn_name = ["User", "User's phone", "Garbage", "User's garbage", "Checker's garbage", "Statistics"]
+
+    def conf_gui(self, color: str, n: int = 1):
+        super().conf_gui(color, n)
+        self.btn[5]['command'] = lambda: self.statistics_command()
+
+    def statistics_command(self):
+        self.station.to_menu("Statistics")
+
+
+class UpdateMenu(AdminMenu):
+    def __init__(self, station, win, color):
+        super().__init__(station, win, color, "Update")
+        self.btn: List[tk.Button] = [tk.Button(self.frame) for _ in range(5)]
+        self.btn_name = ["User's score", "User's reputation", "Garbage's type", "Garbage's check"]
+
+    def conf_gui(self, color: str, n: int = 1):
+        super().conf_gui(color, n)
+
+
+class StatisticsMenu(AdminMenu):
+    def __init__(self, station, win, color):
+        super().__init__(station, win, color, "Statistics")
+        self.btn: List[tk.Button] = [tk.Button(self.frame) for _ in range(6)]
+        self.btn_name = ["System", "Time", "Score", "Reputation", "BlackUser", "PassingRate"]
+
+    def conf_gui(self, color: str, n: int = 1):
+        super().conf_gui(color, n)
+
+
+all_menu = [MainMenu, CreatMenu, DeleteMenu, SearchMenu, UpdateMenu, StatisticsMenu]

+ 197 - 12
control/admin_program.py

@@ -2,17 +2,21 @@ import abc
 import tkinter as tk
 
 from tool.type_ import *
-from tool.tk import make_font, set_button_disable_from_list
+from tool.tk import make_font, set_tk_disable_from_list
 
+import conf
 import admin
 import admin_event as tk_event
 
 
 class AdminProgram(metaclass=abc.ABCMeta):
-    def __init__(self, station: admin.AdminStation, win: Union[tk.Frame, tk.Toplevel, tk.Tk], color: str):
+    def __init__(self, station: admin.AdminStation, win: Union[tk.Frame, tk.Toplevel, tk.Tk], color: str, title: str):
         self.station = station
         self.win = win
         self.color = color
+        self.frame = tk.Frame(self.win)
+        self.frame['bg'] = color
+        self.program_title = title
 
     @abc.abstractmethod
     def set_disable(self):
@@ -26,16 +30,13 @@ class AdminProgram(metaclass=abc.ABCMeta):
     def conf_gui(self, n: int = 1):
         ...
 
-    @abc.abstractmethod
-    def get_program_frame(self) -> tk.Frame:
-        ...
+    def get_program_frame(self) -> Tuple[str, tk.Frame]:
+        return self.program_title, self.frame
 
 
 class WelcomeProgram(AdminProgram):
     def __init__(self, station, win, color):
-        super(WelcomeProgram, self).__init__(station, win, color)
-        self.frame = tk.Frame(self.win)
-        self.frame['bg'] = color
+        super().__init__(station, win, color, "Welcome")
 
         self.title = tk.Label(self.frame)
         self.btn: List[tk.Button] = [tk.Button(self.frame) for _ in range(2)]
@@ -74,11 +75,195 @@ class WelcomeProgram(AdminProgram):
     def test_msg(self):
         self.station.show_msg("Test Msg", "test msg")
 
-    def get_program_frame(self) -> Tuple[str, tk.Frame]:
-        return "Welcome", self.frame
+    def set_disable(self):
+        set_tk_disable_from_list(self.btn)
+
+    def reset_disable(self):
+        set_tk_disable_from_list(self.btn, flat='normal')
+
+
+class CreatUserProgramBase(AdminProgram):
+    def __init__(self, station, win, color, title: str):
+        super().__init__(station, win, color, title)
+
+        self.enter_frame = tk.Frame(self.frame)
+        self.title: List[tk.Label] = [tk.Label(self.enter_frame) for _ in range(3)]
+        self.enter: List[tk.Entry] = [tk.Entry(self.enter_frame) for _ in range(3)]
+        self.var: List[tk.Variable] = [tk.StringVar() for _ in range(3)]
+        self.btn: List[tk.Button] = [tk.Button(self.frame) for _ in range(2)]  # creat(生成用户) try(计算uid)
+
+        self._conf("#FA8072")  # 默认颜色
+        self.__conf_font()
+
+    def _conf(self, bg_color):
+        self.bg_color = bg_color
+        return self
+
+    def __conf_font(self, n: int = 1):
+        self.title_font_size = int(16 * n)
+        self.btn_font_size = int(14 * n)
+
+    def conf_gui(self, n: int = 1):
+        self.__conf_font(n)
+
+        title_font = make_font(size=self.title_font_size)
+        btn_font = make_font(size=self.btn_font_size)
+
+        self.enter_frame['bg'] = self.bg_color
+        self.enter_frame['bd'] = 5
+        self.enter_frame['relief'] = "ridge"
+        self.enter_frame.place(relx=0.2, rely=0.3, relwidth=0.6, relheight=0.30)
+
+        height = 0.1
+        for lb, text, enter, var in zip(self.title, ["UserName:", "PassWord:", "Phone:"], self.enter, self.var):
+            lb['font'] = title_font
+            lb['text'] = text
+            lb['bg'] = self.bg_color
+            lb['anchor'] = 'e'
+
+            enter['font'] = title_font
+            enter['textvariable'] = var
+
+            lb.place(relx=0.01, rely=height, relwidth=0.30, relheight=0.17)
+            enter.place(relx=0.35, rely=height, relwidth=0.60, relheight=0.17)
+            height += 0.30
+
+        for btn, text, x in zip(self.btn, ["Creat", "GetUID"], [0.2, 0.6]):
+            btn['font'] = btn_font
+            btn['text'] = text
+            btn['bg'] = conf.tk_btn_bg
+            btn.place(relx=x, rely=0.7, relwidth=0.2, relheight=0.08)
 
     def set_disable(self):
-        set_button_disable_from_list(self.btn)
+        set_tk_disable_from_list(self.btn)
+        set_tk_disable_from_list(self.enter)
 
     def reset_disable(self):
-        set_button_disable_from_list(self.btn, flat='normal')
+        set_tk_disable_from_list(self.btn, flat='normal')
+        set_tk_disable_from_list(self.enter, flat='normal')
+
+
+class CreatNormalUserProgram(CreatUserProgramBase):
+    def __init__(self, station, win, color):
+        super(CreatNormalUserProgram, self).__init__(station, win, color, "CreatNormalUser")
+
+
+class CreatManagerUserProgram(CreatUserProgramBase):
+    def __init__(self, station, win, color):
+        super(CreatManagerUserProgram, self).__init__(station, win, color, "CreatManagerUser")
+        self._conf("#4b5cc4")
+
+
+class CreatAutoNormalUserProgram(AdminProgram):
+    def __init__(self, station, win, color):
+        super().__init__(station, win, color, "CreatAutoNormalUser")
+
+        self.enter_frame = tk.Frame(self.frame)
+        self.title: tk.Label = tk.Label(self.enter_frame)
+        self.enter: tk.Entry = tk.Entry(self.enter_frame)
+        self.var: tk.Variable = tk.StringVar()
+        self.btn: tk.Button = tk.Button(self.frame)  # creat(生成用户) try(计算uid)
+
+        self.__conf_font()
+
+    def __conf_font(self, n: int = 1):
+        self.title_font_size = int(16 * n)
+        self.btn_font_size = int(14 * n)
+
+    def conf_gui(self, n: int = 1):
+        self.__conf_font(n)
+
+        title_font = make_font(size=self.title_font_size)
+        btn_font = make_font(size=self.btn_font_size)
+
+        self.enter_frame['bg'] = "#bce672"
+        self.enter_frame['bd'] = 5
+        self.enter_frame['relief'] = "ridge"
+        self.enter_frame.place(relx=0.2, rely=0.3, relwidth=0.6, relheight=0.10)
+
+        self.title['font'] = title_font
+        self.title['text'] = "Phone:"
+        self.title['bg'] = "#bce672"
+        self.title['anchor'] = 'e'
+
+        self.enter['font'] = title_font
+        self.enter['textvariable'] = self.var
+
+        self.title.place(relx=0.02, rely=0.2, relwidth=0.25, relheight=0.48)
+        self.enter.place(relx=0.30, rely=0.2, relwidth=0.60, relheight=0.48)
+
+        self.btn['font'] = btn_font
+        self.btn['text'] = "Creat"
+        self.btn['bg'] = conf.tk_btn_bg
+        self.btn.place(relx=0.4, rely=0.7, relwidth=0.2, relheight=0.08)
+
+    def set_disable(self):
+        self.btn['state'] = 'disable'
+        self.enter['state'] = 'disable'
+
+    def reset_disable(self):
+        self.btn['state'] = 'normal'
+        self.enter['state'] = 'normal'
+
+
+class CreatGarbageProgram(AdminProgram):
+    def __init__(self, station, win, color):
+        super().__init__(station, win, color, "CreatGarbage")
+
+        self.enter_frame = tk.Frame(self.frame)
+        self.title: List[tk.Label] = [tk.Label(self.enter_frame), tk.Label(self.enter_frame)]
+        self.enter: List[tk.Entry] = [tk.Entry(self.enter_frame), tk.Entry(self.enter_frame)]
+        self.var: List[tk.Variable] = [tk.StringVar(), tk.StringVar()]
+        self.creat_btn: tk.Button = tk.Button(self.frame)
+        self.file_btn: tk.Button = tk.Button(self.frame)
+
+        self.__conf_font()
+
+    def __conf_font(self, n: int = 1):
+        self.title_font_size = int(16 * n)
+        self.btn_font_size = int(14 * n)
+
+    def conf_gui(self, n: int = 1):
+        self.__conf_font(n)
+
+        title_font = make_font(size=self.title_font_size)
+        btn_font = make_font(size=self.btn_font_size)
+
+        self.enter_frame['bg'] = "#b69968"
+        self.enter_frame['bd'] = 5
+        self.enter_frame['relief'] = "ridge"
+        self.enter_frame.place(relx=0.2, rely=0.3, relwidth=0.6, relheight=0.17)
+
+        height = 0.1
+        for lb, text, enter, var in zip(self.title, ["Count:", "Export:"], self.enter, self.var):
+            lb['font'] = title_font
+            lb['text'] = text
+            lb['bg'] = "#b69968"
+            lb['anchor'] = 'e'
+
+            enter['font'] = title_font
+            enter['textvariable'] = var
+
+            lb.place(relx=0.01, rely=height, relwidth=0.30, relheight=0.35)
+            enter.place(relx=0.35, rely=height, relwidth=0.60, relheight=0.35)
+            height += 0.43
+
+        for btn, text, x in zip([self.creat_btn, self.file_btn], ["Creat", "ChoosePath"], [0.2, 0.6]):
+            btn['font'] = btn_font
+            btn['text'] = text
+            btn['bg'] = conf.tk_btn_bg
+            btn.place(relx=x, rely=0.7, relwidth=0.2, relheight=0.08)
+
+    def set_disable(self):
+        self.creat_btn['state'] = 'disable'
+        self.file_btn['state'] = 'disable'
+        set_tk_disable_from_list(self.enter)
+
+    def reset_disable(self):
+        self.creat_btn['state'] = 'normal'
+        self.file_btn['state'] = 'normal'
+        set_tk_disable_from_list(self.enter, flat='normal')
+
+
+all_program = [WelcomeProgram, CreatNormalUserProgram, CreatManagerUserProgram, CreatAutoNormalUserProgram,
+               CreatGarbageProgram]

+ 5 - 4
control/event.py

@@ -14,17 +14,18 @@ class TkEventBase(metaclass=abc.ABCMeta):
     def __init__(self):
         self.thread: Optional[TkThreading] = None
 
-    @abc.abstractmethod
     def is_end(self) -> bool:
-        ...
+        if self.thread is not None and self.thread.is_alive():
+            return True
+        return False
 
     @abc.abstractmethod
     def get_title(self) -> str:
         ...
 
-    @abc.abstractmethod
     def done_after_event(self):
-        ...
+        if self.thread is not None:
+            self.thread.wait_event()
 
 
 class TkEventMain(metaclass=abc.ABCMeta):

+ 14 - 17
control/station.py

@@ -11,7 +11,7 @@ import datetime
 from PIL import Image, ImageTk
 
 from tool.type_ import *
-from tool.tk import set_button_disable_from_list, make_font
+from tool.tk import set_tk_disable_from_list, make_font
 
 from core.user import User, UserNotSupportError
 from core.garbage import GarbageBag, GarbageType, GarbageBagNotUse
@@ -504,9 +504,9 @@ class GarbageStation(GarbageStationBase):
 
         self._sys_info_frame = tk.Frame(self._window)
         self._garbage_id: win_info_type = (tk.Label(self._sys_info_frame), tk.Label(self._sys_info_frame),
-                                           tk.StringVar(), "GID")
+                                           tk.StringVar(), "GarbageID")
         self._sys_date: win_info_type = (tk.Label(self._sys_info_frame), tk.Label(self._sys_info_frame),
-                                         tk.StringVar(), "Date")
+                                         tk.StringVar(), "SystemDate")
 
         self._cap_label = tk.Label(self._window)
 
@@ -634,23 +634,20 @@ class GarbageStation(GarbageStationBase):
         for bt in self._win_ctrl_button:
             bt: tk.Button
             bt['font'] = title_font
-            bt['bg'] = "#B0C4DE"  # 浅钢青
+            bt['bg'] = conf.tk_btn_bg
 
         bt_help: tk.Button = self._win_ctrl_button[0]
         bt_help['text'] = 'Help'
-        bt_help['bg'] = '#A9A9A9'
         bt_help['command'] = lambda: self.show_help_info()
         bt_help.place(relx=0.81, rely=0.01, relwidth=0.05, relheight=0.05)
 
         bt_about: tk.Button = self._win_ctrl_button[1]
         bt_about['text'] = 'About'
-        bt_about['bg'] = '#A9A9A9'
         bt_about['command'] = lambda: self.show_about_info()
         bt_about.place(relx=0.87, rely=0.01, relwidth=0.05, relheight=0.05)
 
         bt_exit: tk.Button = self._win_ctrl_button[2]
         bt_exit['text'] = 'Exit'
-        bt_exit['bg'] = '#A9A9A9'
         bt_exit['command'] = lambda: self.show_exit()
         bt_exit.place(relx=0.93, rely=0.01, relwidth=0.05, relheight=0.05)
 
@@ -676,7 +673,7 @@ class GarbageStation(GarbageStationBase):
             lb_list[0]['font'] = title_font
             lb_list[0]['bg'] = "#FA8072"
             lb_list[0]['fg'] = "#FFB6C1"
-            lb_list[0]['text'] = lb_list[3] + " " * (10 - len(lb_list[3])) + " :"
+            lb_list[0]['text'] = lb_list[3] + ":"
             lb_list[0]['anchor'] = 'e'
             lb_list[0].place(relx=0.0, rely=height, relwidth=0.35, relheight=height_label)
             height += height_label + h_label_s / height_count
@@ -771,7 +768,7 @@ class GarbageStation(GarbageStationBase):
             info_list[0]['font'] = title_font
             info_list[0]['bg'] = "#F0F8FF"
             info_list[0]['anchor'] = 'e'
-            info_list[0]['text'] = info_list[3] + " " * (10 - len(info_list[3])) + " :"
+            info_list[0]['text'] = info_list[3] + ":"
             info_list[0].place(relx=0.0, rely=height, relwidth=0.35, relheight=height_label)
             height += height_label + h_label_s / height_count
 
@@ -1112,31 +1109,31 @@ class GarbageStation(GarbageStationBase):
         self._user_btn[0]['state'] = 'disable'
 
     def normal_user_disable(self):
-        set_button_disable_from_list(self._check_ctrl_btn, flat='disable')
+        set_tk_disable_from_list(self._check_ctrl_btn, flat='disable')
         self._user_btn[0]['state'] = 'normal'
         self._user_btn[0]['command'] = lambda: self.show_user_info()
 
     def manager_user_disable(self):
-        set_button_disable_from_list(self._throw_ctrl_btn, flat='disable')
+        set_tk_disable_from_list(self._throw_ctrl_btn, flat='disable')
         self._user_btn[0]['state'] = 'normal'
         self._user_btn[0]['command'] = lambda: self.show_garbage_info()
 
     def normal_user_able(self):
-        set_button_disable_from_list(self._throw_ctrl_btn, flat='normal')
+        set_tk_disable_from_list(self._throw_ctrl_btn, flat='normal')
 
     def manager_user_able(self):
-        set_button_disable_from_list(self._check_ctrl_btn, flat='normal')
+        set_tk_disable_from_list(self._check_ctrl_btn, flat='normal')
 
     def set_all_btn_disable(self):
         self.__switch_to_no_user()  # 禁用所有操作性按钮
         self.hide_msg_rank()
-        set_button_disable_from_list(self._user_btn, flat='disable')
-        set_button_disable_from_list(self._win_ctrl_button, flat='disable')
+        set_tk_disable_from_list(self._user_btn, flat='disable')
+        set_tk_disable_from_list(self._win_ctrl_button, flat='disable')
         self._disable_all_btn = True
 
     def set_reset_all_btn(self):
-        set_button_disable_from_list(self._user_btn, flat='normal')
-        set_button_disable_from_list(self._win_ctrl_button, flat='normal')
+        set_tk_disable_from_list(self._user_btn, flat='normal')
+        set_tk_disable_from_list(self._win_ctrl_button, flat='normal')
         self.update_control()  # 位于_user_btn之后, 会自动设定detail按钮
         self._disable_all_btn = False
 

+ 0 - 6
control/station_event.py

@@ -23,12 +23,6 @@ class StationEventBase(TkEventBase):
     def get_title(self) -> str:
         return self._title
 
-    def is_end(self) -> bool:
-        raise tk_station.GarbageStationException
-
-    def done_after_event(self):
-        raise tk_station.GarbageStationException
-
 
 class ScanUserEvent(StationEventBase):
     @staticmethod

+ 4 - 2
tool/tk.py

@@ -1,14 +1,16 @@
 import tkinter as tk
 from tkinter import font
-from typing import List
+from typing import List, Union
 
 import conf
 
+Disable_type = Union[tk.Button, tk.Entry]
+
 
 def make_font(family: str = 'noto', **kwargs):
     return font.Font(family=conf.font_d[family], **kwargs)
 
 
-def set_button_disable_from_list(btn_list: List[tk.Button], flat: str = 'disable'):
+def set_tk_disable_from_list(btn_list: List[Disable_type], flat: str = 'disable'):
     for btn in btn_list:
         btn['state'] = flat