batch.py 17 KB

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