batch.py 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268
  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. self.user_var.batch_y = bitch
  80. self.batch_view.set("当前年份批号:" + self.user_var.batch_y)
  81. self.user_var.order_year_str.set(self.user_var.batch_y)
  82. self.user_var.batch_str.set(self.user_var.batch_y + self.user_var.batch_m + self.user_var.batch_d)
  83. # 控制栏
  84. def button_canvas_init(self):
  85. self.button_canvas = Canvas(self.main_frame, width=self.screen_width - 20, height=40)
  86. self.main_button = Button(self.button_canvas, text="主界面", fg='white', bg='DeepSkyBlue', width=8,
  87. activebackground='white', activeforeground='DeepSkyBlue',
  88. font=("宋体", self.font_size_title, "bold"), command=self.main_button_event)
  89. self.main_button.place(x=1, y=0)
  90. self.param_button = Button(self.button_canvas, text="参数设定", fg='white', bg='DeepSkyBlue', width=8,
  91. activebackground='white', activeforeground='DeepSkyBlue',
  92. font=("宋体", self.font_size_title, "bold"), command=self.param_button_event)
  93. self.param_button.place(x=110, y=0)
  94. self.button_canvas.place(x=10, y=self.screen_height - 60)
  95. # 输入栏
  96. def user_frame_init(self):
  97. self.order_frame = Frame(
  98. self.main_frame, width=self.screen_width - 20, relief=SUNKEN, borderwidth=2,
  99. height=self.screen_height - self.title_canvas.winfo_reqheight() - self.button_canvas.winfo_reqheight() - 35)
  100. # 工单栏展示
  101. self.order_frame.place(x=12, y=self.title_canvas.winfo_reqheight() + 15)
  102. bitch_button_x = self.order_frame.winfo_reqwidth() / 8
  103. bitch_button_x_ref = 60
  104. bitch_button_w = 8
  105. self.A_button = Button(self.order_frame, text="A", width=bitch_button_w,
  106. font=("宋体", self.font_size_title, "bold"))
  107. self.A_button.bind("<Button-1>", self.bitch_push_event)
  108. self.A_button.bind("<ButtonRelease-1>", lambda event: self.bitch_release_event(event, 'A'))
  109. self.A_button.place(x=bitch_button_x - bitch_button_x_ref, y=20)
  110. self.B_button = Button(self.order_frame, text="B", width=bitch_button_w,
  111. font=("宋体", self.font_size_title, "bold"))
  112. self.B_button.bind("<Button-1>", self.bitch_push_event)
  113. self.B_button.bind("<ButtonRelease-1>", lambda event: self.bitch_release_event(event, 'B'))
  114. self.B_button.place(x=bitch_button_x * 2 - bitch_button_x_ref, y=20)
  115. self.C_button = Button(self.order_frame, text="C", width=bitch_button_w,
  116. font=("宋体", self.font_size_title, "bold"))
  117. self.C_button.bind("<Button-1>", self.bitch_push_event)
  118. self.C_button.bind("<ButtonRelease-1>", lambda event: self.bitch_release_event(event, 'C'))
  119. self.C_button.place(x=bitch_button_x * 3 - bitch_button_x_ref, y=20)
  120. self.D_button = Button(self.order_frame, text="D", width=bitch_button_w,
  121. font=("宋体", self.font_size_title, "bold"))
  122. self.D_button.bind("<Button-1>", self.bitch_push_event)
  123. self.D_button.bind("<ButtonRelease-1>", lambda event: self.bitch_release_event(event, 'D'))
  124. self.D_button.place(x=bitch_button_x * 4 - bitch_button_x_ref, y=20)
  125. self.E_button = Button(self.order_frame, text="E", width=bitch_button_w,
  126. font=("宋体", self.font_size_title, "bold"))
  127. self.E_button.bind("<Button-1>", self.bitch_push_event)
  128. self.E_button.bind("<ButtonRelease-1>", lambda event: self.bitch_release_event(event, 'E'))
  129. self.E_button.place(x=bitch_button_x * 5 - bitch_button_x_ref, y=20)
  130. self.F_button = Button(self.order_frame, text="F", width=bitch_button_w,
  131. font=("宋体", self.font_size_title, "bold"))
  132. self.F_button.bind("<Button-1>", self.bitch_push_event)
  133. self.F_button.bind("<ButtonRelease-1>", lambda event: self.bitch_release_event(event, 'F'))
  134. self.F_button.place(x=bitch_button_x * 6 - bitch_button_x_ref, y=20)
  135. self.G_button = Button(self.order_frame, text="G", width=bitch_button_w,
  136. font=("宋体", self.font_size_title, "bold"))
  137. self.G_button.bind("<Button-1>", self.bitch_push_event)
  138. self.G_button.bind("<ButtonRelease-1>", lambda event: self.bitch_release_event(event, 'G'))
  139. self.G_button.place(x=bitch_button_x * 7 - bitch_button_x_ref, y=20)
  140. self.H_button = Button(self.order_frame, text="H", width=bitch_button_w,
  141. font=("宋体", self.font_size_title, "bold"))
  142. self.H_button.bind("<Button-1>", self.bitch_push_event)
  143. self.H_button.bind("<ButtonRelease-1>", lambda event: self.bitch_release_event(event, 'H'))
  144. self.H_button.place(x=bitch_button_x - bitch_button_x_ref, y=80)
  145. self.I_button = Button(self.order_frame, text="I", width=bitch_button_w,
  146. font=("宋体", self.font_size_title, "bold"))
  147. self.I_button.bind("<Button-1>", self.bitch_push_event)
  148. self.I_button.bind("<ButtonRelease-1>", lambda event: self.bitch_release_event(event, 'I'))
  149. self.I_button.place(x=bitch_button_x * 2 - bitch_button_x_ref, y=80)
  150. self.J_button = Button(self.order_frame, text="J", width=bitch_button_w,
  151. font=("宋体", self.font_size_title, "bold"))
  152. self.J_button.bind("<Button-1>", self.bitch_push_event)
  153. self.J_button.bind("<ButtonRelease-1>", lambda event: self.bitch_release_event(event, 'J'))
  154. self.J_button.place(x=bitch_button_x * 3 - bitch_button_x_ref, y=80)
  155. self.K_button = Button(self.order_frame, text="K", width=bitch_button_w,
  156. font=("宋体", self.font_size_title, "bold"))
  157. self.K_button.bind("<Button-1>", self.bitch_push_event)
  158. self.K_button.bind("<ButtonRelease-1>", lambda event: self.bitch_release_event(event, 'K'))
  159. self.K_button.place(x=bitch_button_x * 4 - bitch_button_x_ref, y=80)
  160. self.L_button = Button(self.order_frame, text="L", width=bitch_button_w,
  161. font=("宋体", self.font_size_title, "bold"))
  162. self.L_button.bind("<Button-1>", self.bitch_push_event)
  163. self.L_button.bind("<ButtonRelease-1>", lambda event: self.bitch_release_event(event, 'L'))
  164. self.L_button.place(x=bitch_button_x * 5 - bitch_button_x_ref, y=80)
  165. self.M_button = Button(self.order_frame, text="M", width=bitch_button_w,
  166. font=("宋体", self.font_size_title, "bold"))
  167. self.M_button.bind("<Button-1>", self.bitch_push_event)
  168. self.M_button.bind("<ButtonRelease-1>", lambda event: self.bitch_release_event(event, 'M'))
  169. self.M_button.place(x=bitch_button_x * 6 - bitch_button_x_ref, y=80)
  170. self.N_button = Button(self.order_frame, text="N", width=bitch_button_w,
  171. font=("宋体", self.font_size_title, "bold"))
  172. self.N_button.bind("<Button-1>", self.bitch_push_event)
  173. self.N_button.bind("<ButtonRelease-1>", lambda event: self.bitch_release_event(event, 'N'))
  174. self.N_button.place(x=bitch_button_x * 7 - bitch_button_x_ref, y=80)
  175. self.O_button = Button(self.order_frame, text="O", width=bitch_button_w,
  176. font=("宋体", self.font_size_title, "bold"))
  177. self.O_button.bind("<Button-1>", self.bitch_push_event)
  178. self.O_button.bind("<ButtonRelease-1>", lambda event: self.bitch_release_event(event, 'O'))
  179. self.O_button.place(x=bitch_button_x - bitch_button_x_ref, y=140)
  180. self.P_button = Button(self.order_frame, text="P", width=bitch_button_w,
  181. font=("宋体", self.font_size_title, "bold"))
  182. self.P_button.bind("<Button-1>", self.bitch_push_event)
  183. self.P_button.bind("<ButtonRelease-1>", lambda event: self.bitch_release_event(event, 'P'))
  184. self.P_button.place(x=bitch_button_x * 2 - bitch_button_x_ref, y=140)
  185. self.Q_button = Button(self.order_frame, text="Q", width=bitch_button_w,
  186. font=("宋体", self.font_size_title, "bold"))
  187. self.Q_button.bind("<Button-1>", self.bitch_push_event)
  188. self.Q_button.bind("<ButtonRelease-1>", lambda event: self.bitch_release_event(event, 'Q'))
  189. self.Q_button.place(x=bitch_button_x * 3 - bitch_button_x_ref, y=140)
  190. self.R_button = Button(self.order_frame, text="R", width=bitch_button_w,
  191. font=("宋体", self.font_size_title, "bold"))
  192. self.R_button.bind("<Button-1>", self.bitch_push_event)
  193. self.R_button.bind("<ButtonRelease-1>", lambda event: self.bitch_release_event(event, 'R'))
  194. self.R_button.place(x=bitch_button_x * 4 - bitch_button_x_ref, y=140)
  195. self.S_button = Button(self.order_frame, text="S", width=bitch_button_w,
  196. font=("宋体", self.font_size_title, "bold"))
  197. self.S_button.bind("<Button-1>", self.bitch_push_event)
  198. self.S_button.bind("<ButtonRelease-1>", lambda event: self.bitch_release_event(event, 'S'))
  199. self.S_button.place(x=bitch_button_x * 5 - bitch_button_x_ref, y=140)
  200. self.T_button = Button(self.order_frame, text="T", width=bitch_button_w,
  201. font=("宋体", self.font_size_title, "bold"))
  202. self.T_button.bind("<Button-1>", self.bitch_push_event)
  203. self.T_button.bind("<ButtonRelease-1>", lambda event: self.bitch_release_event(event, 'T'))
  204. self.T_button.place(x=bitch_button_x * 6 - bitch_button_x_ref, y=140)
  205. self.U_button = Button(self.order_frame, text="U", width=bitch_button_w,
  206. font=("宋体", self.font_size_title, "bold"))
  207. self.U_button.bind("<Button-1>", self.bitch_push_event)
  208. self.U_button.bind("<ButtonRelease-1>", lambda event: self.bitch_release_event(event, 'U'))
  209. self.U_button.place(x=bitch_button_x * 7 - bitch_button_x_ref, y=140)
  210. self.V_button = Button(self.order_frame, text="V", width=bitch_button_w,
  211. font=("宋体", self.font_size_title, "bold"))
  212. self.V_button.bind("<Button-1>", self.bitch_push_event)
  213. self.V_button.bind("<ButtonRelease-1>", lambda event: self.bitch_release_event(event, 'V'))
  214. self.V_button.place(x=bitch_button_x - bitch_button_x_ref, y=200)
  215. self.W_button = Button(self.order_frame, text="W", width=bitch_button_w,
  216. font=("宋体", self.font_size_title, "bold"))
  217. self.W_button.bind("<Button-1>", self.bitch_push_event)
  218. self.W_button.bind("<ButtonRelease-1>", lambda event: self.bitch_release_event(event, 'W'))
  219. self.W_button.place(x=bitch_button_x * 2 - bitch_button_x_ref, y=200)
  220. self.X_button = Button(self.order_frame, text="X", width=bitch_button_w,
  221. font=("宋体", self.font_size_title, "bold"))
  222. self.X_button.bind("<Button-1>", self.bitch_push_event)
  223. self.X_button.bind("<ButtonRelease-1>", lambda event: self.bitch_release_event(event, 'X'))
  224. self.X_button.place(x=bitch_button_x * 3 - bitch_button_x_ref, y=200)
  225. self.Y_button = Button(self.order_frame, text="Y", width=bitch_button_w,
  226. font=("宋体", self.font_size_title, "bold"))
  227. self.Y_button.bind("<Button-1>", self.bitch_push_event)
  228. self.Y_button.bind("<ButtonRelease-1>", lambda event: self.bitch_release_event(event, 'Y'))
  229. self.Y_button.place(x=bitch_button_x * 4 - bitch_button_x_ref, y=200)
  230. self.Z_button = Button(self.order_frame, text="Z", width=bitch_button_w,
  231. font=("宋体", self.font_size_title, "bold"))
  232. self.Z_button.bind("<Button-1>", self.bitch_push_event)
  233. self.Z_button.bind("<ButtonRelease-1>", lambda event: self.bitch_release_event(event, 'Z'))
  234. self.Z_button.place(x=bitch_button_x * 5 - bitch_button_x_ref, y=200)
  235. self.batchview_canvas = Canvas(self.order_frame, bg='white', relief=SOLID, borderwidth=1,
  236. width=160, height=30)
  237. self.batchviewlabel = Label(self.batchview_canvas, font=("宋体", self.font_size_title), textvariable=self.batch_view,
  238. relief=SOLID, borderwidth=1, anchor='center', bg="Skyblue",
  239. width=15, height=1)
  240. self.batchviewlabel.place(x=6, y=6)
  241. self.batchview_canvas.place(x=bitch_button_x - bitch_button_x_ref, y=260)
  242. self.noticelabel = Label(self.order_frame, font=("宋体", self.font_size_title), text="注:选择时需要长按1秒以上", anchor='center',
  243. width=30, height=1)
  244. self.noticelabel.place(x=self.order_frame.winfo_reqwidth() - 300, y=self.order_frame.winfo_reqheight() - 50)