batch.py 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271
  1. from tkinter import *
  2. import app
  3. import time
  4. import param
  5. import tkinter.messagebox
  6. class my_batch(Frame):
  7. def __init__(self, init_window_name):
  8. self.init_window_name = init_window_name
  9. self.user_var = app.user_var
  10. self.screen_width = self.user_var.screen_width
  11. self.screen_height = self.user_var.screen_height
  12. self.font_size_title = app.font_size_title
  13. self.font_size_text = app.font_size_text
  14. self.batchtitle_str = StringVar()
  15. self.batchtitle_str.set("年份批号选择")
  16. self.batch_timeout = 0
  17. self.batch_view = StringVar()
  18. self.batch_view.set("当前年份批号:"+self.user_var.batch_y)
  19. self.main_gui_init()
  20. self.title_canvas_init()
  21. self.button_canvas_init()
  22. self.user_frame_init()
  23. self.view_timeout = 180
  24. self.user_var.windows_idx = 'batch'
  25. self.fun_timer()
  26. def main_button_event(self):
  27. self.user_var.last_windows_idx = 'batch'
  28. self.init_window_name.after_cancel(self.task_user)
  29. self.main_frame.destroy()
  30. app.my_gui(self.init_window_name)
  31. def param_button_event(self):
  32. print("Enter Param Set!")
  33. self.user_var.last_windows_idx = 'batch'
  34. self.init_window_name.after_cancel(self.task_user)
  35. self.main_frame.destroy()
  36. param.my_param(self.init_window_name)
  37. def auth_exit(self):
  38. if self.user_var.auth_timeout > 0:
  39. self.user_var.auth_timeout = self.user_var.auth_timeout - 1
  40. else:
  41. self.user_var.auth_stat = False
  42. def view_exit(self):
  43. if self.view_timeout > 0:
  44. self.view_timeout = self.view_timeout - 1
  45. else:
  46. self.user_var.last_windows_idx = 'param'
  47. self.init_window_name.after_cancel(self.task_user)
  48. self.main_frame.destroy()
  49. app.my_gui(self.init_window_name)
  50. def windows_update(self):
  51. currentTime = time.strftime('%Y/%m/%d %H:%M:%S', time.localtime(time.time()))
  52. self.timelabel.config(text=currentTime)
  53. self.auth_exit()
  54. self.batch_timeout = self.batch_timeout + 1
  55. self.init_window_name.update()
  56. self.fun_timer()
  57. self.view_exit()
  58. def fun_timer(self):
  59. self.task_user=self.init_window_name.after(1000, self.windows_update)
  60. def main_gui_init(self):
  61. self.main_frame = Frame(self.init_window_name, width=self.screen_width, height=self.screen_height)
  62. self.main_frame.pack()
  63. # 标题栏
  64. def title_canvas_init(self):
  65. self.title_canvas = Canvas(self.main_frame, width=self.screen_width - 20, height=35, bg='SeaGreen')
  66. self.mainlabel = Label(self.title_canvas, text="年份批号选择", fg='yellow', font=("宋体", self.font_size_title),
  67. bg='SeaGreen', anchor='w')
  68. self.mainlabel.place(x=20, y=5)
  69. self.timelabel = Label(self.title_canvas, text=time.strftime('%Y/%m/%d %H:%M:%S', time.localtime(time.time())),
  70. fg='yellow', font=("宋体", self.font_size_title), bg='SeaGreen', anchor='e')
  71. self.timelabel.place(x=self.title_canvas.winfo_reqwidth() - self.timelabel.winfo_reqwidth() - 20, y=5)
  72. self.title_canvas.create_line(self.mainlabel.winfo_reqwidth() / 2 + 20, 32, self.title_canvas.winfo_reqwidth() -
  73. self.timelabel.winfo_reqwidth() / 2 - 20, 32, fill='white')
  74. self.title_canvas.place(x=10, y=10)
  75. def bitch_push_event(self, event):
  76. self.batch_timeout = 0
  77. def bitch_release_event(self, event, bitch):
  78. if self.batch_timeout >= 1:
  79. if self.user_var.batch_y != bitch:
  80. self.user_var.batch_y = bitch
  81. self.batch_view.set("当前年份批号:" + self.user_var.batch_y)
  82. self.user_var.order_year_str.set(self.user_var.batch_y)
  83. self.user_var.batch_str.set(self.user_var.batch_y + self.user_var.batch_m + self.user_var.batch_d)
  84. self.user_var.order_update_stat = True
  85. self.user_var.batch_update_stat = True
  86. # 控制栏
  87. def button_canvas_init(self):
  88. self.button_canvas = Canvas(self.main_frame, width=self.screen_width - 20, height=40)
  89. self.main_button = Button(self.button_canvas, text="主界面", fg='white', bg='DeepSkyBlue', width=8,
  90. activebackground='white', activeforeground='DeepSkyBlue',
  91. font=("宋体", self.font_size_title, "bold"), command=self.main_button_event)
  92. self.main_button.place(x=1, y=0)
  93. self.param_button = Button(self.button_canvas, text="参数设定", fg='white', bg='DeepSkyBlue', width=8,
  94. activebackground='white', activeforeground='DeepSkyBlue',
  95. font=("宋体", self.font_size_title, "bold"), command=self.param_button_event)
  96. self.param_button.place(x=110, y=0)
  97. self.button_canvas.place(x=10, y=self.screen_height - 60)
  98. # 输入栏
  99. def user_frame_init(self):
  100. self.order_frame = Frame(
  101. self.main_frame, width=self.screen_width - 20, relief=SUNKEN, borderwidth=2,
  102. height=self.screen_height - self.title_canvas.winfo_reqheight() - self.button_canvas.winfo_reqheight() - 35)
  103. # 工单栏展示
  104. self.order_frame.place(x=12, y=self.title_canvas.winfo_reqheight() + 15)
  105. bitch_button_x = self.order_frame.winfo_reqwidth() / 8
  106. bitch_button_x_ref = 60
  107. bitch_button_w = 8
  108. self.A_button = Button(self.order_frame, text="A", width=bitch_button_w,
  109. font=("宋体", self.font_size_title, "bold"))
  110. self.A_button.bind("<Button-1>", self.bitch_push_event)
  111. self.A_button.bind("<ButtonRelease-1>", lambda event: self.bitch_release_event(event, 'A'))
  112. self.A_button.place(x=bitch_button_x - bitch_button_x_ref, y=20)
  113. self.B_button = Button(self.order_frame, text="B", width=bitch_button_w,
  114. font=("宋体", self.font_size_title, "bold"))
  115. self.B_button.bind("<Button-1>", self.bitch_push_event)
  116. self.B_button.bind("<ButtonRelease-1>", lambda event: self.bitch_release_event(event, 'B'))
  117. self.B_button.place(x=bitch_button_x * 2 - bitch_button_x_ref, y=20)
  118. self.C_button = Button(self.order_frame, text="C", width=bitch_button_w,
  119. font=("宋体", self.font_size_title, "bold"))
  120. self.C_button.bind("<Button-1>", self.bitch_push_event)
  121. self.C_button.bind("<ButtonRelease-1>", lambda event: self.bitch_release_event(event, 'C'))
  122. self.C_button.place(x=bitch_button_x * 3 - bitch_button_x_ref, y=20)
  123. self.D_button = Button(self.order_frame, text="D", width=bitch_button_w,
  124. font=("宋体", self.font_size_title, "bold"))
  125. self.D_button.bind("<Button-1>", self.bitch_push_event)
  126. self.D_button.bind("<ButtonRelease-1>", lambda event: self.bitch_release_event(event, 'D'))
  127. self.D_button.place(x=bitch_button_x * 4 - bitch_button_x_ref, y=20)
  128. self.E_button = Button(self.order_frame, text="E", width=bitch_button_w,
  129. font=("宋体", self.font_size_title, "bold"))
  130. self.E_button.bind("<Button-1>", self.bitch_push_event)
  131. self.E_button.bind("<ButtonRelease-1>", lambda event: self.bitch_release_event(event, 'E'))
  132. self.E_button.place(x=bitch_button_x * 5 - bitch_button_x_ref, y=20)
  133. self.F_button = Button(self.order_frame, text="F", width=bitch_button_w,
  134. font=("宋体", self.font_size_title, "bold"))
  135. self.F_button.bind("<Button-1>", self.bitch_push_event)
  136. self.F_button.bind("<ButtonRelease-1>", lambda event: self.bitch_release_event(event, 'F'))
  137. self.F_button.place(x=bitch_button_x * 6 - bitch_button_x_ref, y=20)
  138. self.G_button = Button(self.order_frame, text="G", width=bitch_button_w,
  139. font=("宋体", self.font_size_title, "bold"))
  140. self.G_button.bind("<Button-1>", self.bitch_push_event)
  141. self.G_button.bind("<ButtonRelease-1>", lambda event: self.bitch_release_event(event, 'G'))
  142. self.G_button.place(x=bitch_button_x * 7 - bitch_button_x_ref, y=20)
  143. self.H_button = Button(self.order_frame, text="H", width=bitch_button_w,
  144. font=("宋体", self.font_size_title, "bold"))
  145. self.H_button.bind("<Button-1>", self.bitch_push_event)
  146. self.H_button.bind("<ButtonRelease-1>", lambda event: self.bitch_release_event(event, 'H'))
  147. self.H_button.place(x=bitch_button_x - bitch_button_x_ref, y=80)
  148. self.I_button = Button(self.order_frame, text="I", width=bitch_button_w,
  149. font=("宋体", self.font_size_title, "bold"))
  150. self.I_button.bind("<Button-1>", self.bitch_push_event)
  151. self.I_button.bind("<ButtonRelease-1>", lambda event: self.bitch_release_event(event, 'I'))
  152. self.I_button.place(x=bitch_button_x * 2 - bitch_button_x_ref, y=80)
  153. self.J_button = Button(self.order_frame, text="J", width=bitch_button_w,
  154. font=("宋体", self.font_size_title, "bold"))
  155. self.J_button.bind("<Button-1>", self.bitch_push_event)
  156. self.J_button.bind("<ButtonRelease-1>", lambda event: self.bitch_release_event(event, 'J'))
  157. self.J_button.place(x=bitch_button_x * 3 - bitch_button_x_ref, y=80)
  158. self.K_button = Button(self.order_frame, text="K", width=bitch_button_w,
  159. font=("宋体", self.font_size_title, "bold"))
  160. self.K_button.bind("<Button-1>", self.bitch_push_event)
  161. self.K_button.bind("<ButtonRelease-1>", lambda event: self.bitch_release_event(event, 'K'))
  162. self.K_button.place(x=bitch_button_x * 4 - bitch_button_x_ref, y=80)
  163. self.L_button = Button(self.order_frame, text="L", width=bitch_button_w,
  164. font=("宋体", self.font_size_title, "bold"))
  165. self.L_button.bind("<Button-1>", self.bitch_push_event)
  166. self.L_button.bind("<ButtonRelease-1>", lambda event: self.bitch_release_event(event, 'L'))
  167. self.L_button.place(x=bitch_button_x * 5 - bitch_button_x_ref, y=80)
  168. self.M_button = Button(self.order_frame, text="M", width=bitch_button_w,
  169. font=("宋体", self.font_size_title, "bold"))
  170. self.M_button.bind("<Button-1>", self.bitch_push_event)
  171. self.M_button.bind("<ButtonRelease-1>", lambda event: self.bitch_release_event(event, 'M'))
  172. self.M_button.place(x=bitch_button_x * 6 - bitch_button_x_ref, y=80)
  173. self.N_button = Button(self.order_frame, text="N", width=bitch_button_w,
  174. font=("宋体", self.font_size_title, "bold"))
  175. self.N_button.bind("<Button-1>", self.bitch_push_event)
  176. self.N_button.bind("<ButtonRelease-1>", lambda event: self.bitch_release_event(event, 'N'))
  177. self.N_button.place(x=bitch_button_x * 7 - bitch_button_x_ref, y=80)
  178. self.O_button = Button(self.order_frame, text="O", width=bitch_button_w,
  179. font=("宋体", self.font_size_title, "bold"))
  180. self.O_button.bind("<Button-1>", self.bitch_push_event)
  181. self.O_button.bind("<ButtonRelease-1>", lambda event: self.bitch_release_event(event, 'O'))
  182. self.O_button.place(x=bitch_button_x - bitch_button_x_ref, y=140)
  183. self.P_button = Button(self.order_frame, text="P", width=bitch_button_w,
  184. font=("宋体", self.font_size_title, "bold"))
  185. self.P_button.bind("<Button-1>", self.bitch_push_event)
  186. self.P_button.bind("<ButtonRelease-1>", lambda event: self.bitch_release_event(event, 'P'))
  187. self.P_button.place(x=bitch_button_x * 2 - bitch_button_x_ref, y=140)
  188. self.Q_button = Button(self.order_frame, text="Q", width=bitch_button_w,
  189. font=("宋体", self.font_size_title, "bold"))
  190. self.Q_button.bind("<Button-1>", self.bitch_push_event)
  191. self.Q_button.bind("<ButtonRelease-1>", lambda event: self.bitch_release_event(event, 'Q'))
  192. self.Q_button.place(x=bitch_button_x * 3 - bitch_button_x_ref, y=140)
  193. self.R_button = Button(self.order_frame, text="R", width=bitch_button_w,
  194. font=("宋体", self.font_size_title, "bold"))
  195. self.R_button.bind("<Button-1>", self.bitch_push_event)
  196. self.R_button.bind("<ButtonRelease-1>", lambda event: self.bitch_release_event(event, 'R'))
  197. self.R_button.place(x=bitch_button_x * 4 - bitch_button_x_ref, y=140)
  198. self.S_button = Button(self.order_frame, text="S", width=bitch_button_w,
  199. font=("宋体", self.font_size_title, "bold"))
  200. self.S_button.bind("<Button-1>", self.bitch_push_event)
  201. self.S_button.bind("<ButtonRelease-1>", lambda event: self.bitch_release_event(event, 'S'))
  202. self.S_button.place(x=bitch_button_x * 5 - bitch_button_x_ref, y=140)
  203. self.T_button = Button(self.order_frame, text="T", width=bitch_button_w,
  204. font=("宋体", self.font_size_title, "bold"))
  205. self.T_button.bind("<Button-1>", self.bitch_push_event)
  206. self.T_button.bind("<ButtonRelease-1>", lambda event: self.bitch_release_event(event, 'T'))
  207. self.T_button.place(x=bitch_button_x * 6 - bitch_button_x_ref, y=140)
  208. self.U_button = Button(self.order_frame, text="U", width=bitch_button_w,
  209. font=("宋体", self.font_size_title, "bold"))
  210. self.U_button.bind("<Button-1>", self.bitch_push_event)
  211. self.U_button.bind("<ButtonRelease-1>", lambda event: self.bitch_release_event(event, 'U'))
  212. self.U_button.place(x=bitch_button_x * 7 - bitch_button_x_ref, y=140)
  213. self.V_button = Button(self.order_frame, text="V", width=bitch_button_w,
  214. font=("宋体", self.font_size_title, "bold"))
  215. self.V_button.bind("<Button-1>", self.bitch_push_event)
  216. self.V_button.bind("<ButtonRelease-1>", lambda event: self.bitch_release_event(event, 'V'))
  217. self.V_button.place(x=bitch_button_x - bitch_button_x_ref, y=200)
  218. self.W_button = Button(self.order_frame, text="W", width=bitch_button_w,
  219. font=("宋体", self.font_size_title, "bold"))
  220. self.W_button.bind("<Button-1>", self.bitch_push_event)
  221. self.W_button.bind("<ButtonRelease-1>", lambda event: self.bitch_release_event(event, 'W'))
  222. self.W_button.place(x=bitch_button_x * 2 - bitch_button_x_ref, y=200)
  223. self.X_button = Button(self.order_frame, text="X", width=bitch_button_w,
  224. font=("宋体", self.font_size_title, "bold"))
  225. self.X_button.bind("<Button-1>", self.bitch_push_event)
  226. self.X_button.bind("<ButtonRelease-1>", lambda event: self.bitch_release_event(event, 'X'))
  227. self.X_button.place(x=bitch_button_x * 3 - bitch_button_x_ref, y=200)
  228. self.Y_button = Button(self.order_frame, text="Y", width=bitch_button_w,
  229. font=("宋体", self.font_size_title, "bold"))
  230. self.Y_button.bind("<Button-1>", self.bitch_push_event)
  231. self.Y_button.bind("<ButtonRelease-1>", lambda event: self.bitch_release_event(event, 'Y'))
  232. self.Y_button.place(x=bitch_button_x * 4 - bitch_button_x_ref, y=200)
  233. self.Z_button = Button(self.order_frame, text="Z", width=bitch_button_w,
  234. font=("宋体", self.font_size_title, "bold"))
  235. self.Z_button.bind("<Button-1>", self.bitch_push_event)
  236. self.Z_button.bind("<ButtonRelease-1>", lambda event: self.bitch_release_event(event, 'Z'))
  237. self.Z_button.place(x=bitch_button_x * 5 - bitch_button_x_ref, y=200)
  238. self.batchview_canvas = Canvas(self.order_frame, bg='white', relief=SOLID, borderwidth=1,
  239. width=160, height=30)
  240. self.batchviewlabel = Label(self.batchview_canvas, font=("宋体", self.font_size_title), textvariable=self.batch_view,
  241. relief=SOLID, borderwidth=1, anchor='center', bg="Skyblue",
  242. width=15, height=1)
  243. self.batchviewlabel.place(x=6, y=6)
  244. self.batchview_canvas.place(x=bitch_button_x - bitch_button_x_ref, y=260)
  245. self.noticelabel = Label(self.order_frame, font=("宋体", self.font_size_title), text="注:选择时需要长按1秒以上", anchor='center',
  246. width=30, height=1)
  247. self.noticelabel.place(x=self.order_frame.winfo_reqwidth() - 300, y=self.order_frame.winfo_reqheight() - 50)