from tkinter import * import app import time import param import tkinter.messagebox class my_batch(Frame): def __init__(self, init_window_name): self.init_window_name = init_window_name self.user_var = app.user_var self.screen_width = self.user_var.screen_width self.screen_height = self.user_var.screen_height self.font_size_title = app.font_size_title self.font_size_text = app.font_size_text self.batchtitle_str = StringVar() self.batchtitle_str.set("年份批号选择") self.batch_timeout = 0 self.batch_view = StringVar() self.batch_view.set("当前年份批号:"+self.user_var.batch_y) self.main_gui_init() self.title_canvas_init() self.button_canvas_init() self.user_frame_init() self.view_timeout = 180 self.user_var.windows_idx = 'batch' self.fun_timer() def main_button_event(self): self.user_var.last_windows_idx = 'batch' self.init_window_name.after_cancel(self.task_user) self.main_frame.destroy() app.my_gui(self.init_window_name) def param_button_event(self): print("Enter Param Set!") self.user_var.last_windows_idx = 'batch' self.init_window_name.after_cancel(self.task_user) self.main_frame.destroy() param.my_param(self.init_window_name) def auth_exit(self): if self.user_var.auth_timeout > 0: self.user_var.auth_timeout = self.user_var.auth_timeout - 1 else: self.user_var.auth_stat = False def view_exit(self): if self.view_timeout > 0: self.view_timeout = self.view_timeout - 1 else: self.user_var.last_windows_idx = 'param' self.init_window_name.after_cancel(self.task_user) self.main_frame.destroy() app.my_gui(self.init_window_name) def windows_update(self): currentTime = time.strftime('%Y/%m/%d %H:%M:%S', time.localtime(time.time())) self.timelabel.config(text=currentTime) self.auth_exit() self.batch_timeout = self.batch_timeout + 1 self.init_window_name.update() self.fun_timer() self.view_exit() def fun_timer(self): self.task_user=self.init_window_name.after(1000, self.windows_update) def main_gui_init(self): self.main_frame = Frame(self.init_window_name, width=self.screen_width, height=self.screen_height) self.main_frame.pack() # 标题栏 def title_canvas_init(self): self.title_canvas = Canvas(self.main_frame, width=self.screen_width - 20, height=35, bg='SeaGreen') self.mainlabel = Label(self.title_canvas, text="年份批号选择", fg='yellow', font=("宋体", self.font_size_title), bg='SeaGreen', anchor='w') self.mainlabel.place(x=20, y=5) self.timelabel = Label(self.title_canvas, text=time.strftime('%Y/%m/%d %H:%M:%S', time.localtime(time.time())), fg='yellow', font=("宋体", self.font_size_title), bg='SeaGreen', anchor='e') self.timelabel.place(x=self.title_canvas.winfo_reqwidth() - self.timelabel.winfo_reqwidth() - 20, y=5) self.title_canvas.create_line(self.mainlabel.winfo_reqwidth() / 2 + 20, 32, self.title_canvas.winfo_reqwidth() - self.timelabel.winfo_reqwidth() / 2 - 20, 32, fill='white') self.title_canvas.place(x=10, y=10) def bitch_push_event(self, event): self.batch_timeout = 0 def bitch_release_event(self, event, bitch): if self.batch_timeout >= 1: self.user_var.batch_y = bitch self.batch_view.set("当前年份批号:" + self.user_var.batch_y) self.user_var.order_year_str.set(self.user_var.batch_y) self.user_var.batch_str.set(self.user_var.batch_y + self.user_var.batch_m + self.user_var.batch_d) # 控制栏 def button_canvas_init(self): self.button_canvas = Canvas(self.main_frame, width=self.screen_width - 20, height=40) self.main_button = Button(self.button_canvas, text="主界面", fg='white', bg='DeepSkyBlue', width=8, activebackground='white', activeforeground='DeepSkyBlue', font=("宋体", self.font_size_title, "bold"), command=self.main_button_event) self.main_button.place(x=1, y=0) self.param_button = Button(self.button_canvas, text="参数设定", fg='white', bg='DeepSkyBlue', width=8, activebackground='white', activeforeground='DeepSkyBlue', font=("宋体", self.font_size_title, "bold"), command=self.param_button_event) self.param_button.place(x=110, y=0) self.button_canvas.place(x=10, y=self.screen_height - 60) # 输入栏 def user_frame_init(self): self.order_frame = Frame( self.main_frame, width=self.screen_width - 20, relief=SUNKEN, borderwidth=2, height=self.screen_height - self.title_canvas.winfo_reqheight() - self.button_canvas.winfo_reqheight() - 35) # 工单栏展示 self.order_frame.place(x=12, y=self.title_canvas.winfo_reqheight() + 15) bitch_button_x = self.order_frame.winfo_reqwidth() / 8 bitch_button_x_ref = 60 bitch_button_w = 8 self.A_button = Button(self.order_frame, text="A", width=bitch_button_w, font=("宋体", self.font_size_title, "bold")) self.A_button.bind("", self.bitch_push_event) self.A_button.bind("", lambda event: self.bitch_release_event(event, 'A')) self.A_button.place(x=bitch_button_x - bitch_button_x_ref, y=20) self.B_button = Button(self.order_frame, text="B", width=bitch_button_w, font=("宋体", self.font_size_title, "bold")) self.B_button.bind("", self.bitch_push_event) self.B_button.bind("", lambda event: self.bitch_release_event(event, 'B')) self.B_button.place(x=bitch_button_x * 2 - bitch_button_x_ref, y=20) self.C_button = Button(self.order_frame, text="C", width=bitch_button_w, font=("宋体", self.font_size_title, "bold")) self.C_button.bind("", self.bitch_push_event) self.C_button.bind("", lambda event: self.bitch_release_event(event, 'C')) self.C_button.place(x=bitch_button_x * 3 - bitch_button_x_ref, y=20) self.D_button = Button(self.order_frame, text="D", width=bitch_button_w, font=("宋体", self.font_size_title, "bold")) self.D_button.bind("", self.bitch_push_event) self.D_button.bind("", lambda event: self.bitch_release_event(event, 'D')) self.D_button.place(x=bitch_button_x * 4 - bitch_button_x_ref, y=20) self.E_button = Button(self.order_frame, text="E", width=bitch_button_w, font=("宋体", self.font_size_title, "bold")) self.E_button.bind("", self.bitch_push_event) self.E_button.bind("", lambda event: self.bitch_release_event(event, 'E')) self.E_button.place(x=bitch_button_x * 5 - bitch_button_x_ref, y=20) self.F_button = Button(self.order_frame, text="F", width=bitch_button_w, font=("宋体", self.font_size_title, "bold")) self.F_button.bind("", self.bitch_push_event) self.F_button.bind("", lambda event: self.bitch_release_event(event, 'F')) self.F_button.place(x=bitch_button_x * 6 - bitch_button_x_ref, y=20) self.G_button = Button(self.order_frame, text="G", width=bitch_button_w, font=("宋体", self.font_size_title, "bold")) self.G_button.bind("", self.bitch_push_event) self.G_button.bind("", lambda event: self.bitch_release_event(event, 'G')) self.G_button.place(x=bitch_button_x * 7 - bitch_button_x_ref, y=20) self.H_button = Button(self.order_frame, text="H", width=bitch_button_w, font=("宋体", self.font_size_title, "bold")) self.H_button.bind("", self.bitch_push_event) self.H_button.bind("", lambda event: self.bitch_release_event(event, 'H')) self.H_button.place(x=bitch_button_x - bitch_button_x_ref, y=80) self.I_button = Button(self.order_frame, text="I", width=bitch_button_w, font=("宋体", self.font_size_title, "bold")) self.I_button.bind("", self.bitch_push_event) self.I_button.bind("", lambda event: self.bitch_release_event(event, 'I')) self.I_button.place(x=bitch_button_x * 2 - bitch_button_x_ref, y=80) self.J_button = Button(self.order_frame, text="J", width=bitch_button_w, font=("宋体", self.font_size_title, "bold")) self.J_button.bind("", self.bitch_push_event) self.J_button.bind("", lambda event: self.bitch_release_event(event, 'J')) self.J_button.place(x=bitch_button_x * 3 - bitch_button_x_ref, y=80) self.K_button = Button(self.order_frame, text="K", width=bitch_button_w, font=("宋体", self.font_size_title, "bold")) self.K_button.bind("", self.bitch_push_event) self.K_button.bind("", lambda event: self.bitch_release_event(event, 'K')) self.K_button.place(x=bitch_button_x * 4 - bitch_button_x_ref, y=80) self.L_button = Button(self.order_frame, text="L", width=bitch_button_w, font=("宋体", self.font_size_title, "bold")) self.L_button.bind("", self.bitch_push_event) self.L_button.bind("", lambda event: self.bitch_release_event(event, 'L')) self.L_button.place(x=bitch_button_x * 5 - bitch_button_x_ref, y=80) self.M_button = Button(self.order_frame, text="M", width=bitch_button_w, font=("宋体", self.font_size_title, "bold")) self.M_button.bind("", self.bitch_push_event) self.M_button.bind("", lambda event: self.bitch_release_event(event, 'M')) self.M_button.place(x=bitch_button_x * 6 - bitch_button_x_ref, y=80) self.N_button = Button(self.order_frame, text="N", width=bitch_button_w, font=("宋体", self.font_size_title, "bold")) self.N_button.bind("", self.bitch_push_event) self.N_button.bind("", lambda event: self.bitch_release_event(event, 'N')) self.N_button.place(x=bitch_button_x * 7 - bitch_button_x_ref, y=80) self.O_button = Button(self.order_frame, text="O", width=bitch_button_w, font=("宋体", self.font_size_title, "bold")) self.O_button.bind("", self.bitch_push_event) self.O_button.bind("", lambda event: self.bitch_release_event(event, 'O')) self.O_button.place(x=bitch_button_x - bitch_button_x_ref, y=140) self.P_button = Button(self.order_frame, text="P", width=bitch_button_w, font=("宋体", self.font_size_title, "bold")) self.P_button.bind("", self.bitch_push_event) self.P_button.bind("", lambda event: self.bitch_release_event(event, 'P')) self.P_button.place(x=bitch_button_x * 2 - bitch_button_x_ref, y=140) self.Q_button = Button(self.order_frame, text="Q", width=bitch_button_w, font=("宋体", self.font_size_title, "bold")) self.Q_button.bind("", self.bitch_push_event) self.Q_button.bind("", lambda event: self.bitch_release_event(event, 'Q')) self.Q_button.place(x=bitch_button_x * 3 - bitch_button_x_ref, y=140) self.R_button = Button(self.order_frame, text="R", width=bitch_button_w, font=("宋体", self.font_size_title, "bold")) self.R_button.bind("", self.bitch_push_event) self.R_button.bind("", lambda event: self.bitch_release_event(event, 'R')) self.R_button.place(x=bitch_button_x * 4 - bitch_button_x_ref, y=140) self.S_button = Button(self.order_frame, text="S", width=bitch_button_w, font=("宋体", self.font_size_title, "bold")) self.S_button.bind("", self.bitch_push_event) self.S_button.bind("", lambda event: self.bitch_release_event(event, 'S')) self.S_button.place(x=bitch_button_x * 5 - bitch_button_x_ref, y=140) self.T_button = Button(self.order_frame, text="T", width=bitch_button_w, font=("宋体", self.font_size_title, "bold")) self.T_button.bind("", self.bitch_push_event) self.T_button.bind("", lambda event: self.bitch_release_event(event, 'T')) self.T_button.place(x=bitch_button_x * 6 - bitch_button_x_ref, y=140) self.U_button = Button(self.order_frame, text="U", width=bitch_button_w, font=("宋体", self.font_size_title, "bold")) self.U_button.bind("", self.bitch_push_event) self.U_button.bind("", lambda event: self.bitch_release_event(event, 'U')) self.U_button.place(x=bitch_button_x * 7 - bitch_button_x_ref, y=140) self.V_button = Button(self.order_frame, text="V", width=bitch_button_w, font=("宋体", self.font_size_title, "bold")) self.V_button.bind("", self.bitch_push_event) self.V_button.bind("", lambda event: self.bitch_release_event(event, 'V')) self.V_button.place(x=bitch_button_x - bitch_button_x_ref, y=200) self.W_button = Button(self.order_frame, text="W", width=bitch_button_w, font=("宋体", self.font_size_title, "bold")) self.W_button.bind("", self.bitch_push_event) self.W_button.bind("", lambda event: self.bitch_release_event(event, 'W')) self.W_button.place(x=bitch_button_x * 2 - bitch_button_x_ref, y=200) self.X_button = Button(self.order_frame, text="X", width=bitch_button_w, font=("宋体", self.font_size_title, "bold")) self.X_button.bind("", self.bitch_push_event) self.X_button.bind("", lambda event: self.bitch_release_event(event, 'X')) self.X_button.place(x=bitch_button_x * 3 - bitch_button_x_ref, y=200) self.Y_button = Button(self.order_frame, text="Y", width=bitch_button_w, font=("宋体", self.font_size_title, "bold")) self.Y_button.bind("", self.bitch_push_event) self.Y_button.bind("", lambda event: self.bitch_release_event(event, 'Y')) self.Y_button.place(x=bitch_button_x * 4 - bitch_button_x_ref, y=200) self.Z_button = Button(self.order_frame, text="Z", width=bitch_button_w, font=("宋体", self.font_size_title, "bold")) self.Z_button.bind("", self.bitch_push_event) self.Z_button.bind("", lambda event: self.bitch_release_event(event, 'Z')) self.Z_button.place(x=bitch_button_x * 5 - bitch_button_x_ref, y=200) self.batchview_canvas = Canvas(self.order_frame, bg='white', relief=SOLID, borderwidth=1, width=160, height=30) self.batchviewlabel = Label(self.batchview_canvas, font=("宋体", self.font_size_title), textvariable=self.batch_view, relief=SOLID, borderwidth=1, anchor='center', bg="Skyblue", width=15, height=1) self.batchviewlabel.place(x=6, y=6) self.batchview_canvas.place(x=bitch_button_x - bitch_button_x_ref, y=260) self.noticelabel = Label(self.order_frame, font=("宋体", self.font_size_title), text="注:选择时需要长按1秒以上", anchor='center', width=30, height=1) self.noticelabel.place(x=self.order_frame.winfo_reqwidth() - 300, y=self.order_frame.winfo_reqheight() - 50)