inquire.py 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538
  1. from tkinter import *
  2. from tkinter import filedialog
  3. from tkinter.ttk import Treeview
  4. from tkcalendar import Calendar, DateEntry
  5. import app
  6. import time
  7. import param
  8. import tkinter.messagebox
  9. import sql
  10. import output_file
  11. import datetime
  12. import _thread
  13. class my_inquire(Frame):
  14. def __init__(self, init_window_name):
  15. self.init_window_name = init_window_name
  16. self.user_var = app.user_var
  17. self.screen_width = self.user_var.screen_width
  18. self.screen_height = self.user_var.screen_height
  19. self.font_size_title = app.font_size_title
  20. self.font_size_text = app.font_size_text
  21. self.sqlclient = sql.sqlclient
  22. self.main_gui_init()
  23. self.title_canvas_init()
  24. self.button_canvas_init()
  25. self.user_frame_init()
  26. self.view_timeout = 180
  27. self.user_var.windows_idx = 'inquire'
  28. self.fun_timer()
  29. def main_button_event(self):
  30. self.user_var.last_windows_idx = 'inquire'
  31. self.init_window_name.after_cancel(self.task_user)
  32. self.main_frame.destroy()
  33. app.my_gui(self.init_window_name)
  34. def param_button_event(self):
  35. print("Enter Param Set!")
  36. self.user_var.last_windows_idx = 'inquire'
  37. self.init_window_name.after_cancel(self.task_user)
  38. self.main_frame.destroy()
  39. param.my_param(self.init_window_name)
  40. def authstatlabel_value(self):
  41. if self.user_var.auth_stat == False:
  42. self.param_button.configure(state="disabled")
  43. else:
  44. self.param_button.configure(state="normal")
  45. def auth_exit(self):
  46. if self.user_var.auth_timeout > 0:
  47. self.user_var.auth_timeout = self.user_var.auth_timeout - 1
  48. else:
  49. self.user_var.auth_stat = False
  50. def view_exit(self):
  51. if self.view_timeout > 0:
  52. self.view_timeout = self.view_timeout - 1
  53. else:
  54. self.user_var.last_windows_idx = 'param'
  55. self.init_window_name.after_cancel(self.task_user)
  56. self.main_frame.destroy()
  57. app.my_gui(self.init_window_name)
  58. def listview_update(self):
  59. if self.user_var.listview_stat == True:
  60. self.user_var.listview_stat = False
  61. if self.user_var.listview_content == "DATA":
  62. self.set_data_listview()
  63. elif self.user_var.listview_content == "PARAM":
  64. self.set_param_listview()
  65. self.user_var.listview_lock = False
  66. self.read_data_delay_label("数据已生成。。。", 'green')
  67. def windows_update(self):
  68. currentTime = time.strftime('%Y/%m/%d %H:%M:%S', time.localtime(time.time()))
  69. self.timelabel.config(text=currentTime)
  70. self.auth_exit()
  71. self.init_window_name.update()
  72. self.fun_timer()
  73. self.authstatlabel_value()
  74. self.view_exit()
  75. self.listview_update()
  76. def fun_timer(self):
  77. self.task_user=self.init_window_name.after(1000, self.windows_update)
  78. def main_gui_init(self):
  79. self.main_frame = Frame(self.init_window_name, width=self.screen_width, height=self.screen_height)
  80. self.main_frame.pack()
  81. # 标题栏
  82. def title_canvas_init(self):
  83. self.title_canvas = Canvas(self.main_frame, width=self.screen_width - 20, height=35, bg='SeaGreen')
  84. self.mainlabel = Label(self.title_canvas, text="气密检查记录查询", fg='SkyBlue', font=("宋体", self.font_size_title),
  85. bg='SeaGreen', anchor='c')
  86. self.mainlabel.place(x=self.title_canvas.winfo_reqwidth()/2-self.mainlabel.winfo_reqwidth()/2, y=5)
  87. self.timelabel = Label(self.title_canvas, text=time.strftime('%Y/%m/%d %H:%M:%S', time.localtime(time.time())),
  88. fg='yellow', font=("宋体", self.font_size_title), bg='SeaGreen', anchor='e')
  89. self.timelabel.place(x=self.title_canvas.winfo_reqwidth() - self.timelabel.winfo_reqwidth() - 20, y=5)
  90. self.title_canvas.create_line(self.mainlabel.winfo_reqwidth() / 2 + 20, 32, self.title_canvas.winfo_reqwidth() -
  91. self.timelabel.winfo_reqwidth() / 2 - 20, 32, fill='white')
  92. self.title_canvas.place(x=10, y=10)
  93. # 控制栏
  94. def button_canvas_init(self):
  95. self.button_canvas = Canvas(self.main_frame, width=self.screen_width - 20, height=40)
  96. self.main_button = Button(self.button_canvas, text="主界面", fg='white', bg='DeepSkyBlue', width=8,
  97. activebackground='white', activeforeground='DeepSkyBlue',
  98. font=("宋体", self.font_size_title, "bold"), command=self.main_button_event)
  99. self.main_button.place(x=1, y=0)
  100. self.param_button = Button(self.button_canvas, text="参数设定", fg='white', bg='DeepSkyBlue', width=8,
  101. activebackground='white', activeforeground='DeepSkyBlue', state="disabled",
  102. font=("宋体", self.font_size_title, "bold"), command=self.param_button_event)
  103. self.param_button.place(x=110, y=0)
  104. self.delaylabel = Label(self.button_canvas, fg='green', font=("宋体", self.font_size_title, "bold"),
  105. text="无数据。。。", anchor='w', )
  106. self.delaylabel.place(x=self.button_canvas.winfo_reqwidth() - 200, y=10)
  107. self.button_canvas.place(x=10, y=self.screen_height - 60)
  108. def return_button_event(self):
  109. if self.user_var.last_windows_idx == 'param':
  110. self.user_var.last_windows_idx = 'production'
  111. self.init_window_name.after_cancel(self.task_user)
  112. self.main_frame.destroy()
  113. param.my_param(self.init_window_name)
  114. else:
  115. self.user_var.last_windows_idx = 'production'
  116. self.init_window_name.after_cancel(self.task_user)
  117. self.main_frame.destroy()
  118. app.my_gui(self.init_window_name)
  119. def get_begin_data_event(self, event):
  120. if self.cal_begin.get_date() <= self.cal_end.get_date():
  121. self.user_var.inquire_begin_data = self.cal_begin.get_date()
  122. print(self.user_var.inquire_begin_data)
  123. else:
  124. tkinter.messagebox.showwarning(title='提示', message='开始日期大于结束日子!')
  125. self.cal_begin.set_date(self.user_var.inquire_begin_data)
  126. def get_end_data_event(self, event):
  127. if self.cal_begin.get_date() <= self.cal_end.get_date():
  128. self.user_var.inquire_end_data = self.cal_end.get_date()
  129. print(self.user_var.inquire_end_data)
  130. else:
  131. tkinter.messagebox.showwarning(title='提示', message='开始日期大于结束日子!')
  132. self.cal_end.set_date(self.user_var.inquire_end_data)
  133. def airparam_button_event(self):
  134. print("气密参数查询!")
  135. if self.user_var.listview_lock == False:
  136. self.user_var.file_name = "气密参数"
  137. self.user_var.listview_content = "PARAM"
  138. self.excel_button.configure(state="normal")
  139. self.pdf_button.configure(state="normal")
  140. self.clear_listview()
  141. thread_savefile = output_file.output_file(10, "Thread-output", 3, 'inquire_param')
  142. thread_savefile.start()
  143. self.read_data_delay_label("数据生成中。。。", 'red')
  144. self.user_var.listview_lock = True
  145. else:
  146. tkinter.messagebox.showwarning(title='提示', message='数据查询中。。。')
  147. def thatday_button_event(self):
  148. print("当天数据查询!")
  149. if self.user_var.listview_lock == False:
  150. self.user_var.file_name = "当天数据{0}".format(datetime.datetime.now().strftime('%Y%m%d%H%M%S'))
  151. self.user_var.listview_content = "DATA"
  152. self.excel_button.configure(state="normal")
  153. self.pdf_button.configure(state="normal")
  154. self.clear_listview()
  155. now_time = int(time.time())
  156. day_time = now_time - now_time % 86400
  157. wherestr = "WHERE end_time >= {0} and end_time <= {1}".format(day_time, day_time + 86400)
  158. thread_savefile = output_file.output_file(10, "Thread-output", 3, 'inquire_data', datastr=wherestr)
  159. thread_savefile.start()
  160. self.read_data_delay_label("数据生成中。。。", 'red')
  161. self.user_var.listview_lock = True
  162. else:
  163. tkinter.messagebox.showwarning(title='提示', message='数据查询中。。。')
  164. def excel_button_event(self):
  165. print("导出excel!")
  166. if self.user_var.file_save_stat == True:
  167. fn = filedialog.asksaveasfilename(title='另存为', initialfile=self.user_var.file_name, defaultextension=".xls",
  168. filetypes=[('xls文件', '.xls')])
  169. if fn:
  170. content = self.user_var.product_data.copy()
  171. if self.user_var.listview_content == "DATA":
  172. content.insert(0, self.user_var.data_headers)
  173. elif self.user_var.listview_content == "PARAM":
  174. content.insert(0, self.user_var.param_headers)
  175. self.user_var.file_save_stat = False
  176. thread_savefile = output_file.output_file(10, "Thread-output", 3, 'save_excel', filepath=fn,
  177. content=content)
  178. thread_savefile.start()
  179. else:
  180. tkinter.messagebox.showwarning(title='提示', message='文件生成中!')
  181. def clear_button_event(self):
  182. print("清除显示!")
  183. if self.user_var.listview_lock == False:
  184. self.user_var.listview_content = "NULL"
  185. self.clear_listview()
  186. self.excel_button.configure(state="disable")
  187. self.pdf_button.configure(state="disable")
  188. self.read_data_delay_label("无数据。。。", 'green')
  189. def days_button_event(self):
  190. print("多天数据!")
  191. if self.user_var.listview_lock == False:
  192. self.user_var.listview_content = "DATA"
  193. self.excel_button.configure(state="normal")
  194. self.pdf_button.configure(state="normal")
  195. self.clear_listview()
  196. begintime = int(time.mktime(time.strptime("{0} 00:00:00".format(
  197. self.user_var.inquire_begin_data), "%Y-%m-%d %H:%M:%S")))
  198. endtime = int(time.mktime(time.strptime("{0} 23:59:59".format(
  199. self.user_var.inquire_end_data), "%Y-%m-%d %H:%M:%S")))
  200. self.user_var.file_name = "多天数据{0}-{1}".format(time.strftime("%Y%m%d", time.localtime(begintime)),
  201. time.strftime("%Y%m%d", time.localtime(endtime)))
  202. wherestr = "WHERE end_time >= {0} and end_time <= {1}".format(begintime, endtime)
  203. thread_savefile = output_file.output_file(10, "Thread-output", 3, 'inquire_data', datastr=wherestr)
  204. thread_savefile.start()
  205. self.read_data_delay_label("数据生成中。。。", 'red')
  206. self.user_var.listview_lock = True
  207. else:
  208. tkinter.messagebox.showwarning(title='提示', message='数据查询中。。。')
  209. def all_button_event(self):
  210. print("全部数据!")
  211. if self.user_var.listview_lock == False:
  212. self.user_var.file_name = "全部数据{0}".format(datetime.datetime.now().strftime('%Y%m%d%H%M%S'))
  213. self.user_var.listview_content = "DATA"
  214. self.excel_button.configure(state="normal")
  215. self.pdf_button.configure(state="normal")
  216. self.clear_listview()
  217. thread_savefile = output_file.output_file(10, "Thread-output", 3, 'inquire_data')
  218. thread_savefile.start()
  219. self.read_data_delay_label("数据生成中。。。", 'red')
  220. self.user_var.listview_lock = True
  221. else:
  222. tkinter.messagebox.showwarning(title='提示', message='数据查询中。。。')
  223. def pdf_button_event(self):
  224. print("导出pdf!")
  225. if self.user_var.file_save_stat == True:
  226. fn = filedialog.asksaveasfilename(title='另存为', initialfile=self.user_var.file_name, defaultextension=".pdf",
  227. filetypes=[('pdf文件', '.pdf')])
  228. if fn:
  229. content = self.user_var.product_data.copy()
  230. if self.user_var.listview_content == "DATA":
  231. content.insert(0, self.user_var.data_headers)
  232. elif self.user_var.listview_content == "PARAM":
  233. content.insert(0, self.user_var.param_headers)
  234. self.user_var.file_save_stat = False
  235. thread_savefile = output_file.output_file(10, "Thread-output", 3, 'save_pdf', filepath=fn,
  236. content=content)
  237. thread_savefile.start()
  238. else:
  239. tkinter.messagebox.showwarning(title='提示', message='文件生成中!')
  240. def label_button_event(self):
  241. print("标签查询!")
  242. if self.user_var.listview_lock == False:
  243. self.user_var.listview_content = "DATA"
  244. txt = self.labeltext.get().strip()
  245. self.labeltext.config(text=txt)
  246. if txt != '' and len(txt) == 12:
  247. self.excel_button.configure(state="normal")
  248. self.pdf_button.configure(state="normal")
  249. self.clear_listview()
  250. wherestr = "WHERE batch = '{0}'".format(txt)
  251. thread_savefile = output_file.output_file(10, "Thread-output", 3, 'inquire_data', datastr=wherestr)
  252. thread_savefile.start()
  253. self.user_var.listview_lock = True
  254. self.user_var.file_name = "标签数据txt"
  255. else:
  256. tkinter.messagebox.showwarning(title='提示', message='请输入12位标签号!')
  257. else:
  258. tkinter.messagebox.showwarning(title='提示', message='数据查询中。。。')
  259. def read_data_delay_label(self, txt, color):
  260. self.delaylabel.configure(text=txt)
  261. self.delaylabel.configure(fg=color)
  262. def clear_listview(self):
  263. for widget in self.treeview_frame.winfo_children():
  264. widget.destroy()
  265. def set_param_listview(self):
  266. widths = (100, 130, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80)
  267. # 构建控件
  268. data_listview = Treeview(self.treeview_frame, columns=self.user_var.param_columns, show='headings')
  269. data_listview.column("#0", width=2, minwidth=1, stretch=YES)
  270. idx =1
  271. for column in self.user_var.param_columns:
  272. data_listview.column('#{0}'.format(idx), width=widths[idx - 1], minwidth=widths[idx - 1],
  273. stretch=YES, anchor=CENTER)
  274. idx = idx + 1
  275. idx = 1
  276. for header in self.user_var.param_headers:
  277. data_listview.heading('#{0}'.format(idx), text='{0}'.format(header), anchor=CENTER)
  278. idx = idx + 1
  279. for i, person in enumerate(self.user_var.product_data):
  280. data_listview.insert('', i, values=person)
  281. # 构建垂直Scrollbar
  282. scroll_y = Scrollbar(self.treeview_frame, orient=VERTICAL, command=data_listview.yview)
  283. # 设定控件布局
  284. scroll_y.pack(side='right', fill='y', padx=1, pady=1, ipadx=1, ipady=1)
  285. # 绑定滚动动作
  286. data_listview.configure(yscrollcommand=scroll_y.set)
  287. # 构建水平Scrollbar
  288. scroll_x = Scrollbar(self.treeview_frame, orient=HORIZONTAL, command=data_listview.xview)
  289. # 设定控件布局
  290. scroll_x.pack(side='bottom', fill='x', padx=1, pady=1, ipadx=1, ipady=1)
  291. # 绑定滚动动作
  292. data_listview.configure(xscrollcommand=scroll_x.set)
  293. # 设定控件布局
  294. data_listview.pack(side='left', fill='both', padx=1, pady=1, ipadx=1, ipady=1)
  295. def set_data_listview(self):
  296. widths = (80, 60, 100, 100, 60, 250, 50, 130, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80)
  297. # 构建控件
  298. data_listview = Treeview(self.treeview_frame, columns=self.user_var.data_columns, show='headings')
  299. data_listview.column("#0", width=2, minwidth=1, stretch=YES)
  300. idx =1
  301. for column in self.user_var.data_columns:
  302. data_listview.column('#{0}'.format(idx), width=widths[idx - 1], minwidth=widths[idx - 1],
  303. stretch=YES, anchor=CENTER)
  304. idx = idx + 1
  305. idx = 1
  306. for header in self.user_var.data_headers:
  307. data_listview.heading('#{0}'.format(idx), text='{0}'.format(header), anchor=CENTER)
  308. idx = idx + 1
  309. for i, person in enumerate(self.user_var.product_data):
  310. data_listview.insert('', i, values=person)
  311. # 构建垂直Scrollbar
  312. scroll_y = Scrollbar(self.treeview_frame, orient=VERTICAL, command=data_listview.yview)
  313. # 设定控件布局
  314. scroll_y.pack(side='right', fill='y', padx=1, pady=1, ipadx=1, ipady=1)
  315. # 绑定滚动动作
  316. data_listview.configure(yscrollcommand=scroll_y.set)
  317. # 构建水平Scrollbar
  318. scroll_x = Scrollbar(self.treeview_frame, orient=HORIZONTAL, command=data_listview.xview)
  319. # 设定控件布局
  320. scroll_x.pack(side='bottom', fill='x', padx=1, pady=1, ipadx=1, ipady=1)
  321. # 绑定滚动动作
  322. data_listview.configure(xscrollcommand=scroll_x.set)
  323. # 设定控件布局
  324. data_listview.pack(side='left', fill='both', padx=1, pady=1, ipadx=1, ipady=1)
  325. # 输入栏
  326. def user_frame_init(self):
  327. self.order_frame = Frame(
  328. self.main_frame, width=self.screen_width - 20, relief=SUNKEN, borderwidth=2,
  329. height=self.screen_height - self.title_canvas.winfo_reqheight() - self.button_canvas.winfo_reqheight() - 35)
  330. # 工单栏展示
  331. self.order_frame.place(x=12, y=self.title_canvas.winfo_reqheight() + 15)
  332. self.operate_frame = Frame(
  333. self.order_frame, width=990, borderwidth=0,
  334. height=110)
  335. self.operate_frame.pack(side='top', padx=1, pady=1, ipadx=2, ipady=2)
  336. self.return_button_canvas = Canvas(self.operate_frame, bg='DarkGray', relief=SOLID, borderwidth=1,
  337. width=117, height=33)
  338. self.return_button = Button(self.return_button_canvas, text="返回", fg='black', bg='white', width=11,
  339. activebackground='black', activeforeground='white',
  340. font=("宋体", self.font_size_text, "bold"), command=self.return_button_event)
  341. self.return_button.place(x=7, y=7)
  342. self.return_button_canvas.place(x=50, y=5)
  343. self.airparam_button_canvas = Canvas(self.operate_frame, bg='DarkGray', relief=SOLID, borderwidth=1,
  344. width=117, height=33)
  345. self.airparam_button = Button(self.airparam_button_canvas, text="气密参数查询", fg='black', bg='white', width=11,
  346. activebackground='black', activeforeground='white',
  347. font=("宋体", self.font_size_text, "bold"), command=self.airparam_button_event)
  348. self.airparam_button.place(x=7, y=7)
  349. self.airparam_button_canvas.place(x=170, y=5)
  350. self.thatday_button_canvas = Canvas(self.operate_frame, bg='DarkGray', relief=SOLID, borderwidth=1,
  351. width=117, height=33)
  352. self.thatday_button = Button(self.thatday_button_canvas, text="当天数据", fg='black', bg='white', width=11,
  353. activebackground='black', activeforeground='white',
  354. font=("宋体", self.font_size_text, "bold"), command=self.thatday_button_event)
  355. self.thatday_button.place(x=7, y=7)
  356. self.thatday_button_canvas.place(x=290, y=5)
  357. self.excel_button_canvas = Canvas(self.operate_frame, bg='DarkGray', relief=SOLID, borderwidth=1,
  358. width=117, height=33)
  359. self.excel_button = Button(self.excel_button_canvas, text="导出数据", fg='black', bg='white', width=11,
  360. activebackground='black', activeforeground='white', state="disabled",
  361. font=("宋体", self.font_size_text, "bold"), command=self.excel_button_event)
  362. self.excel_button.place(x=7, y=7)
  363. self.excel_button_canvas.place(x=410, y=5)
  364. self.clear_button_canvas = Canvas(self.operate_frame, bg='DarkGray', relief=SOLID, borderwidth=1,
  365. width=117, height=33)
  366. self.clear_button = Button(self.clear_button_canvas, text="清除显示", fg='black', bg='white', width=11,
  367. activebackground='black', activeforeground='white',
  368. font=("宋体", self.font_size_text, "bold"), command=self.clear_button_event)
  369. self.clear_button.place(x=7, y=7)
  370. self.clear_button_canvas.place(x=50, y=40)
  371. self.days_button_canvas = Canvas(self.operate_frame, bg='DarkGray', relief=SOLID, borderwidth=1,
  372. width=117, height=33)
  373. self.days_button = Button(self.days_button_canvas, text="多天数据", fg='black', bg='white', width=11,
  374. activebackground='black', activeforeground='white',
  375. font=("宋体", self.font_size_text, "bold"), command=self.days_button_event)
  376. self.days_button.place(x=7, y=7)
  377. self.days_button_canvas.place(x=170, y=40)
  378. self.all_button_canvas = Canvas(self.operate_frame, bg='DarkGray', relief=SOLID, borderwidth=1,
  379. width=117, height=33)
  380. self.all_button = Button(self.all_button_canvas, text="全部数据", fg='black', bg='white', width=11,
  381. activebackground='black', activeforeground='white',
  382. font=("宋体", self.font_size_text, "bold"), command=self.all_button_event)
  383. self.all_button.place(x=7, y=7)
  384. self.all_button_canvas.place(x=290, y=40)
  385. self.pdf_button_canvas = Canvas(self.operate_frame, bg='DarkGray', relief=SOLID, borderwidth=1,
  386. width=117, height=33)
  387. self.pdf_button = Button(self.pdf_button_canvas, text="导出pdf", fg='black', bg='white', width=11,
  388. activebackground='black', activeforeground='white', state="disabled",
  389. font=("宋体", self.font_size_text, "bold"), command=self.pdf_button_event)
  390. self.pdf_button.place(x=7, y=7)
  391. self.pdf_button_canvas.place(x=410, y=40)
  392. self.labeltitle = Label(self.operate_frame, text="输入查询的标签", font=("宋体", self.font_size_text), anchor='e')
  393. self.labeltitle.place(x=self.operate_frame.winfo_reqwidth() - self.labeltitle.winfo_reqwidth() - 50, y=5)
  394. self.labeltext = Entry(self.operate_frame, font=("宋体", self.font_size_text), fg="darkgoldenrod", bg="SkyBlue",
  395. width=20, justify='center')
  396. self.labeltext.place(x=self.operate_frame.winfo_reqwidth() - self.labeltext.winfo_reqwidth() - 28, y=30)
  397. self.label_button_canvas = Canvas(self.operate_frame, bg='DarkGray', relief=SOLID, borderwidth=1,
  398. width=117, height=33)
  399. self.label_button = Button(self.label_button_canvas, text="查看label", fg='black', bg='white', width=11,
  400. activebackground='black', activeforeground='white',
  401. font=("宋体", self.font_size_text, "bold"), command=self.label_button_event)
  402. self.label_button.place(x=7, y=7)
  403. self.label_button_canvas.place(
  404. x=self.operate_frame.winfo_reqwidth() - self.label_button_canvas.winfo_reqwidth() - 40, y=55)
  405. self.datatitlelabel = Label(self.operate_frame, text="气密数据查询列表", fg='dodgerblue',
  406. font=("宋体", self.font_size_text),
  407. anchor='w')
  408. self.datatitlelabel.place(x=self.operate_frame.winfo_reqwidth() / 2 - self.datatitlelabel.winfo_reqwidth() / 2,
  409. y=80)
  410. self.calbegin_canvas = Canvas(self.operate_frame, bg='white', relief=SOLID, borderwidth=1,
  411. width=180, height=33)
  412. self.calbegintitlelabel = Label(self.calbegin_canvas, text="起始:", fg='dodgerblue', bg='white',
  413. font=("宋体", self.font_size_text),
  414. anchor='w')
  415. self.calbegintitlelabel.place(x=10, y=10)
  416. self.cal_begin = DateEntry(self.calbegin_canvas, locale='zh_CN', width=12, background='darkblue',
  417. foreground='white', borderwidth=2)
  418. self.cal_begin.place(x=65, y=8)
  419. self.cal_begin.bind("<<DateEntrySelected>>", self.get_begin_data_event)
  420. self.calbegin_canvas.place(
  421. x=550, y=5)
  422. self.calend_canvas = Canvas(self.operate_frame, bg='white', relief=SOLID, borderwidth=1,
  423. width=180, height=33)
  424. self.calendtitlelabel = Label(self.calend_canvas, text="结束:", fg='dodgerblue', bg='white',
  425. font=("宋体", self.font_size_text),
  426. anchor='w')
  427. self.calendtitlelabel.place(x=10, y=10)
  428. self.cal_end = DateEntry(self.calend_canvas, locale='zh_CN', width=12, background='darkblue',
  429. foreground='white', borderwidth=2)
  430. self.cal_end.place(x=65, y=8)
  431. self.cal_end.bind("<<DateEntrySelected>>", self.get_end_data_event)
  432. self.calend_canvas.place(
  433. x=550, y=40)
  434. self.treeview_frame = Frame(self.order_frame, bg='white', relief=SOLID, borderwidth=1,
  435. width=990, height=350)
  436. self.treeview_frame.pack(side='bottom', padx=2, pady=2, ipadx=2, ipady=2)
  437. self.treeview_frame.pack_propagate(0)
  438. if self.user_var.listview_content == "DATA":
  439. self.excel_button.configure(state="normal")
  440. self.pdf_button.configure(state="normal")
  441. self.set_data_listview()
  442. self.read_data_delay_label("数据已生成。。。", 'green')
  443. elif self.user_var.listview_content == "PARAM":
  444. self.excel_button.configure(state="normal")
  445. self.pdf_button.configure(state="normal")
  446. self.set_param_listview()
  447. self.read_data_delay_label("数据已生成。。。", 'green')
  448. # t = time.time()
  449. #
  450. # print (t) #原始时间数据
  451. # print (int(t)) #秒级时间戳
  452. # print (int(round(t * 1000))) #毫秒级时间戳
  453. # print (int(round(t * 1000000))) #微秒级时间戳
  454. # dt = '2018-01-01 10:40:30'
  455. # ts = int(time.mktime(time.strptime(dt, "%Y-%m-%d %H:%M:%S")))
  456. # print (ts)
  457. # ts = 1515774430
  458. # dt = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime(ts))
  459. # print(dt)