from tkinter import * import app import time import sql import param import tkinter.messagebox class my_production(Frame): def __init__(self, init_window_name): self.init_window_name = init_window_name self.sqlclient = sql.sqlclient self.user_var = app.user_var self.opc_value = app.opc_value 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.main_gui_init() self.title_canvas_init() self.button_canvas_init() self.user_frame_init() self.input_lock = False self.view_timeout = 180 self.user_var.windows_idx = 'production' self.fun_timer() def return_button_event(self): if self.user_var.last_windows_idx == 'param': self.user_var.last_windows_idx = 'production' self.init_window_name.after_cancel(self.task_user) self.main_frame.destroy() param.my_param(self.init_window_name) else: self.user_var.last_windows_idx = 'production' self.init_window_name.after_cancel(self.task_user) self.main_frame.destroy() app.my_gui(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.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 button_canvas_init(self): self.button_canvas = Canvas(self.main_frame, width=self.screen_width - 20, height=40) self.return_button = Button(self.button_canvas, text="返回", fg='white', bg='DeepSkyBlue', width=8, activebackground='white', activeforeground='DeepSkyBlue', font=("宋体", self.font_size_title, "bold"), command=self.return_button_event) self.return_button.place(x=1, y=0) self.button_canvas.place(x=10, y=self.screen_height - 60) def product_sel_button_event(self, idx): # tkinter.messagebox.showwarning(title='提示', message='品番切换为{}!'.format(self.user_var.product_list[idx])) # exec('self.product_sel_label_{0:02d}.config(fg="PaleGreen")'.format(self.user_var.product_idx+1)) # exec('self.product_sel_label_{0:02d}.config(fg="purple")'.format(idx+1)) # self.user_var.product_idx = idx # self.user_var.product_idx_str.set(idx+1) # self.user_var.product_str.set(self.user_var.product_list[idx]) # self.opc_value.set_Product_idx(self.user_var.product_idx) # self.opc_value.set_Product_name(self.user_var.product_list[idx]) if self.user_var.auth_stat == True: self.input_param(idx) else: self.input_frame.wm_attributes('-topmost', 0) tkinter.messagebox.showwarning(title='提示', message='请登录后操作!') self.input_frame.wm_attributes('-topmost', 1) def input_exit(self): self.input_lock = False self.input_frame.destroy() def input_on_closing(self): self.input_lock = False def get_sel_product_idx_value(self, idx): self.sel_idx = idx self.product_isset = False sqlstr = "SELECT product_name,17700_name,17720_name FROM product_tbl " sqlstr = sqlstr + "WHERE stat=True and product_idx={0}".format(idx) paramresult = self.sqlclient.sql_inquire_all(sqlstr) if paramresult != None and len(paramresult) > 0: for paramrow in paramresult: self.sel_product_name = paramrow[0] self.sel_name_17700 = paramrow[1] self.sel_name_17720 = paramrow[2] self.product_isset = True break else: self.sel_product_name = '' self.sel_name_17700 = '' self.sel_name_17720 = '' if self.product_isset == True: sqlstr = "SELECT startuptime,airtime,presstime, testtime, exhaust, maxpress, minpress, setpress, capacity, \ posthreshold, pnegthreshold FROM product_param_tbl WHERE product_name='{0}' and \ param_type = 17700".format(self.sel_product_name) paramresult = self.sqlclient.sql_inquire_all(sqlstr) if paramresult != None and len(paramresult) > 0: for paramrow in paramresult: self.sel_startuptime_17700 = paramrow[0] self.sel_airtime_17700 = paramrow[1] self.sel_presstime_17700 = paramrow[2] self.sel_testtime_17700 = paramrow[3] self.sel_exhaust_17700 = paramrow[4] self.sel_maxpress_17700 = paramrow[5] self.sel_minpress_17700 = paramrow[6] self.sel_setpress_17700 = paramrow[7] self.sel_capacity_17700 = paramrow[8] self.sel_posthreshold_17700 = paramrow[9] self.sel_pnegthreshold_17700 = paramrow[10] else: self.sel_startuptime_17700 = '0' self.sel_airtime_17700 = '0' self.sel_presstime_17700 = '0' self.sel_testtime_17700 = '0' self.sel_exhaust_17700 = '0' self.sel_maxpress_17700 = '0' self.sel_minpress_17700 = '0' self.sel_setpress_17700 = '0' self.sel_capacity_17700 = '0' self.sel_posthreshold_17700 = '0' self.sel_pnegthreshold_17700 = '0' sqlstr = "SELECT startuptime, airtime,presstime, testtime, exhaust, maxpress, minpress, setpress, capacity, \ posthreshold, pnegthreshold FROM product_param_tbl WHERE product_name='{0}' and \ param_type = 17720".format(self.sel_product_name) paramresult = self.sqlclient.sql_inquire_all(sqlstr) if paramresult != None and len(paramresult) > 0: for paramrow in paramresult: self.sel_startuptime_17720 = paramrow[0] self.sel_airtime_17720 = paramrow[1] self.sel_presstime_17720 = paramrow[2] self.sel_testtime_17720 = paramrow[3] self.sel_exhaust_17720 = paramrow[4] self.sel_maxpress_17720 = paramrow[5] self.sel_minpress_17720 = paramrow[6] self.sel_setpress_17720 = paramrow[7] self.sel_capacity_17720 = paramrow[8] self.sel_posthreshold_17720 = paramrow[9] self.sel_pnegthreshold_17720 = paramrow[10] else: self.sel_startuptime_17720 = '0' self.sel_airtime_17720 = '0' self.sel_presstime_17720 = '0' self.sel_testtime_17720 = '0' self.sel_exhaust_17720 = '0' self.sel_maxpress_17720 = '0' self.sel_minpress_17720 = '0' self.sel_setpress_17720 = '0' self.sel_capacity_17720 = '0' self.sel_posthreshold_17720 = '0' self.sel_pnegthreshold_17720 = '0' else: self.sel_startuptime_17700 = '0' self.sel_airtime_17700 = '0' self.sel_presstime_17700 = '0' self.sel_testtime_17700 = '0' self.sel_exhaust_17700 = '0' self.sel_maxpress_17700 = '0' self.sel_minpress_17700 = '0' self.sel_setpress_17700 = '0' self.sel_capacity_17700 = '0' self.sel_posthreshold_17700 = '0' self.sel_pnegthreshold_17700 = '0' self.sel_startuptime_17720 = '0' self.sel_airtime_17720 = '0' self.sel_presstime_17720 = '0' self.sel_testtime_17720 = '0' self.sel_exhaust_17720 = '0' self.sel_maxpress_17720 = '0' self.sel_minpress_17720 = '0' self.sel_setpress_17720 = '0' self.sel_capacity_17720 = '0' self.sel_posthreshold_17720 = '0' self.sel_pnegthreshold_17720 = '0' def insert_param_tbl(self, ttype): sqlstr = "INSERT INTO product_param_tbl " sqlstr = sqlstr + "(product_idx,product_name,param_type,startuptime,airtime,presstime, testtime, \ exhaust, maxpress, minpress, setpress, capacity, \ posthreshold, pnegthreshold)" if ttype == 17700: sqlstr = sqlstr + " VALUES ({0}, '{1}', {2}, '{3}', '{4}', '{5}', '{6}', '{7}', '{8}', '{9}', '{10}', '{11}', '{12}', '{13}')".format( self.sel_idx, self.sel_product_name, 17700, self.sel_startuptime_17700, self.sel_airtime_17700, self.sel_presstime_17700, self.sel_testtime_17700, self.sel_exhaust_17700, self.sel_maxpress_17700, self.sel_minpress_17700, self.sel_setpress_17700, self.sel_capacity_17700, self.sel_posthreshold_17700, self.sel_pnegthreshold_17700 ) else: sqlstr = sqlstr + " VALUES ({0}, '{1}', {2}, '{3}', '{4}', '{5}', '{6}', '{7}', '{8}', '{9}', '{10}', '{11}', '{12}', '{13}')".format( self.sel_idx, self.sel_product_name, 17720, self.sel_startuptime_17720, self.sel_airtime_17720, self.sel_presstime_17720, self.sel_testtime_17720, self.sel_exhaust_17720, self.sel_maxpress_17720, self.sel_minpress_17720, self.sel_setpress_17720, self.sel_capacity_17720, self.sel_posthreshold_17720, self.sel_pnegthreshold_17720 ) self.sqlclient.sql_action_all(sqlstr) def update_param_tbl(self, ttype): sqlstr = "UPDATE product_param_tbl SET " if ttype == 17700: sqlstr = sqlstr + "startuptime='{0}',".format(self.sel_startuptime_17700) sqlstr = sqlstr + "airtime='{0}',".format(self.sel_airtime_17700) sqlstr = sqlstr + "presstime='{0}',".format(self.sel_presstime_17700) sqlstr = sqlstr + "testtime='{0}',".format(self.sel_testtime_17700) sqlstr = sqlstr + "exhaust='{0}',".format(self.sel_exhaust_17700) sqlstr = sqlstr + "maxpress='{0}',".format(self.sel_maxpress_17700) sqlstr = sqlstr + "minpress='{0}',".format(self.sel_minpress_17700) sqlstr = sqlstr + "setpress='{0}',".format(self.sel_setpress_17700) sqlstr = sqlstr + "capacity='{0}',".format(self.sel_capacity_17700) sqlstr = sqlstr + "posthreshold='{0}',".format(self.sel_posthreshold_17700) sqlstr = sqlstr + "pnegthreshold='{0}'".format(self.sel_pnegthreshold_17700) sqlstr = sqlstr + "WHERE param_type=17700 and product_name='{0}'".format(self.sel_product_name) else: sqlstr = sqlstr + "startuptime='{0}',".format(self.sel_startuptime_17720) sqlstr = sqlstr + "airtime='{0}',".format(self.sel_airtime_17720) sqlstr = sqlstr + "presstime='{0}',".format(self.sel_presstime_17720) sqlstr = sqlstr + "testtime='{0}',".format(self.sel_testtime_17720) sqlstr = sqlstr + "exhaust='{0}',".format(self.sel_exhaust_17720) sqlstr = sqlstr + "maxpress='{0}',".format(self.sel_maxpress_17720) sqlstr = sqlstr + "minpress='{0}',".format(self.sel_minpress_17720) sqlstr = sqlstr + "setpress='{0}',".format(self.sel_setpress_17720) sqlstr = sqlstr + "capacity='{0}',".format(self.sel_capacity_17720) sqlstr = sqlstr + "posthreshold='{0}',".format(self.sel_posthreshold_17720) sqlstr = sqlstr + "pnegthreshold='{0}'".format(self.sel_pnegthreshold_17720) sqlstr = sqlstr + "WHERE param_type=17720 and product_name='{0}'".format(self.sel_product_name) self.sqlclient.sql_action_all(sqlstr) def input_enter(self): stat = False product_name = self.sel_product_name_entry.get() name_17700 = self.sel_name_17700_entry.get() name_17720 = self.sel_name_17720_entry.get() sel_startuptime_17700 = self.sel_startuptime_17700_entry.get() sel_airtime_17700 = self.sel_airtime_17700_entry.get() sel_presstime_17700 = self.sel_presstime_17700_entry.get() sel_testtime_17700 = self.sel_testtime_17700_entry.get() sel_exhaust_17700 = self.sel_exhaust_17700_entry.get() sel_maxpress_17700 = self.sel_maxpress_17700_entry.get() sel_minpress_17700 = self.sel_minpress_17700_entry.get() sel_setpress_17700 = self.sel_setpress_17700_entry.get() sel_capacity_17700 = self.sel_capacity_17700_entry.get() sel_posthreshold_17700 = self.sel_posthreshold_17700_entry.get() sel_pnegthreshold_17700 = self.sel_pnegthreshold_17700_entry.get() sel_startuptime_17720 = self.sel_startuptime_17720_entry.get() sel_airtime_17720 = self.sel_airtime_17720_entry.get() sel_presstime_17720 = self.sel_presstime_17720_entry.get() sel_testtime_17720 = self.sel_testtime_17720_entry.get() sel_exhaust_17720 = self.sel_exhaust_17720_entry.get() sel_maxpress_17720 = self.sel_maxpress_17720_entry.get() sel_minpress_17720 = self.sel_minpress_17720_entry.get() sel_setpress_17720 = self.sel_setpress_17720_entry.get() sel_capacity_17720 = self.sel_capacity_17720_entry.get() sel_posthreshold_17720 = self.sel_posthreshold_17720_entry.get() sel_pnegthreshold_17720 = self.sel_pnegthreshold_17720_entry.get() if len(product_name) == 0 or len(name_17700) == 0 or len(name_17720) == 0: self.input_frame.wm_attributes('-topmost', 0) tkinter.messagebox.showwarning(title='提示', message='品番未输入!') self.input_frame.wm_attributes('-topmost', 1) return if len(sel_startuptime_17700) == 0 or len(sel_airtime_17700) == 0 or len(sel_presstime_17700) == 0 or len( sel_testtime_17700) == 0 or len(sel_exhaust_17700) == 0 or len(sel_maxpress_17700) == 0 or len( sel_minpress_17700) == 0 or len(sel_setpress_17700) == 0 or len(sel_capacity_17700) == 0 or len( sel_posthreshold_17700) == 0 or len(sel_pnegthreshold_17700) == 0: self.input_frame.wm_attributes('-topmost', 0) tkinter.messagebox.showwarning(title='提示', message='17700参数输入为空!') self.input_frame.wm_attributes('-topmost', 1) return if len(sel_startuptime_17720) == 0 or len(sel_airtime_17720) == 0 or len(sel_presstime_17720) == 0 or len( sel_testtime_17720) == 0 or len(sel_exhaust_17720) == 0 or len(sel_maxpress_17720) == 0 or len( sel_minpress_17720) == 0 or len(sel_setpress_17720) == 0 or len(sel_capacity_17720) == 0 or len( sel_posthreshold_17720) == 0 or len(sel_pnegthreshold_17720) == 0: self.input_frame.wm_attributes('-topmost', 0) tkinter.messagebox.showwarning(title='提示', message='17720参数输入为空!') self.input_frame.wm_attributes('-topmost', 1) return if self.sel_product_name != '': if product_name != self.sel_product_name: self.input_frame.wm_attributes('-topmost', 0) message = tkinter.messagebox.askokcancel(title='提示', message='是否确定品番{0}修改为{1}'.format( self.sel_product_name, product_name)) self.input_frame.wm_attributes('-topmost', 1) if (message == False): self.sel_product_name_entry.delete(0, "end") self.sel_product_name_entry.insert(0, self.sel_product_name) return else: sqlstr = "UPDATE product_tbl SET stat=False WHERE product_name='{0}' and stat=True".format( self.sel_product_name ) self.sqlclient.sql_action_all(sqlstr) stat = True else: stat = True self.sel_name_17700 = name_17700 self.sel_name_17720 = name_17720 if stat == True: self.sel_product_name = product_name # self.user_var.product_list[self.sel_idx] = self.sel_product_name # self.user_var.product_list_str[self.sel_idx].set(self.sel_product_name) sqlstr = "INSERT INTO product_tbl " sqlstr = sqlstr + "(product_idx, product_name, 17700_name, 17720_name, stat)" sqlstr = sqlstr + " VALUES ('{0}', '{1}', '{2}', '{3}', True)".format( self.sel_idx, self.sel_product_name, self.sel_name_17700, self.sel_name_17720 ) else: sqlstr = "UPDATE product_tbl SET 17700_name='{0}',17720_name='{1}' WHERE product_name='{2}' and stat=True".format( self.sel_name_17700, self.sel_name_17720, self.sel_product_name ) self.sqlclient.sql_action_all(sqlstr) # self.user_var.product_17700_list[self.sel_idx] = self.sel_name_17700 # self.user_var.product_17720_list[self.sel_idx] = self.sel_name_17720 self.sel_startuptime_17700 = sel_startuptime_17700 self.sel_airtime_17700 = sel_airtime_17700 self.sel_presstime_17700 = sel_presstime_17700 self.sel_testtime_17700 = sel_testtime_17700 self.sel_exhaust_17700 = sel_exhaust_17700 self.sel_maxpress_17700 = sel_maxpress_17700 self.sel_minpress_17700 = sel_minpress_17700 self.sel_setpress_17700 = sel_setpress_17700 self.sel_capacity_17700 = sel_capacity_17700 self.sel_posthreshold_17700 = sel_posthreshold_17700 self.sel_pnegthreshold_17700 = sel_pnegthreshold_17700 if stat == True: self.insert_param_tbl(17700) else: self.update_param_tbl(17700) self.sel_startuptime_17720 = sel_startuptime_17720 self.sel_airtime_17720 = sel_airtime_17720 self.sel_presstime_17720 = sel_presstime_17720 self.sel_testtime_17720 = sel_testtime_17720 self.sel_exhaust_17720 = sel_exhaust_17720 self.sel_maxpress_17720 = sel_maxpress_17720 self.sel_minpress_17720 = sel_minpress_17720 self.sel_setpress_17720 = sel_setpress_17720 self.sel_capacity_17720 = sel_capacity_17720 self.sel_posthreshold_17720 = sel_posthreshold_17720 self.sel_pnegthreshold_17720 = sel_pnegthreshold_17720 if stat == True: self.insert_param_tbl(17720) else: self.update_param_tbl(17720) self.user_var.product_load = True self.input_lock = False self.input_frame.destroy() def input_param(self, idx): if self.input_lock == False: self.get_sel_product_idx_value(idx) self.input_frame = tkinter.Tk(className='请输入值') # 弹出框框名 self.input_frame.geometry('800x500+50+50') # 设置弹出框的大小 w x h self.sel_product_name_label = Label(self.input_frame, font=("宋体", self.font_size_text), text='总品番:', anchor='w') self.sel_product_name_label.place(x=20, y=20) self.sel_product_name_entry = tkinter.Entry(self.input_frame, width=30) # 设置"文本变量"为var self.sel_product_name_entry.place(x=150, y=20) self.sel_product_name_entry.insert(0, self.sel_product_name) self.sel_name_17700_label = Label(self.input_frame, font=("宋体", self.font_size_text), text='17700品番:', anchor='w') self.sel_name_17700_label.place(x=20, y=50) self.sel_name_17700_entry = tkinter.Entry(self.input_frame, width=30) # 设置"文本变量"为var self.sel_name_17700_entry.place(x=150, y=50) self.sel_name_17700_entry.insert(0, self.sel_name_17700) self.sel_name_17720_label = Label(self.input_frame, font=("宋体", self.font_size_text), text='17720品番:', anchor='w') self.sel_name_17720_label.place(x=400, y=50) self.sel_name_17720_entry = tkinter.Entry(self.input_frame, width=30) # 设置"文本变量"为var self.sel_name_17720_entry.place(x=530, y=50) self.sel_name_17720_entry.insert(0, self.sel_name_17720) self.sel_startuptime_17700_label = Label(self.input_frame, font=("宋体", self.font_size_text), text='17700启动延时:', anchor='w') self.sel_startuptime_17700_label.place(x=20, y=80) self.sel_startuptime_17700_entry = tkinter.Entry(self.input_frame, width=24) # 设置"文本变量"为var self.sel_startuptime_17700_entry.place(x=150, y=80) self.sel_startuptime_17700_entry.insert(0, self.sel_startuptime_17700) self.sel_startuptime_17700_unit = Label(self.input_frame, text="sec", font=("宋体", self.font_size_text), anchor='w') self.sel_startuptime_17700_unit.place(x=330, y=80) self.sel_startuptime_17720_label = Label(self.input_frame, font=("宋体", self.font_size_text), text='17720启动延时:', anchor='w') self.sel_startuptime_17720_label.place(x=400, y=80) self.sel_startuptime_17720_entry = tkinter.Entry(self.input_frame, width=24) # 设置"文本变量"为var self.sel_startuptime_17720_entry.place(x=530, y=80) self.sel_startuptime_17720_entry.insert(0, self.sel_startuptime_17720) self.sel_startuptime_17720_unit = Label(self.input_frame, text="sec", font=("宋体", self.font_size_text), anchor='w') self.sel_startuptime_17720_unit.place(x=710, y=80) self.sel_airtime_17700_label = Label(self.input_frame, font=("宋体", self.font_size_text), text='17700充气时间:', anchor='w') self.sel_airtime_17700_label.place(x=20, y=110) self.sel_airtime_17700_entry = tkinter.Entry(self.input_frame, width=28) # 设置"文本变量"为var self.sel_airtime_17700_entry.place(x=150, y=110) self.sel_airtime_17700_entry.insert(0, self.sel_airtime_17700) self.sel_airtime_17700_unit = Label(self.input_frame, text="sec", font=("宋体", self.font_size_text), anchor='w') self.sel_airtime_17700_unit.place(x=330, y=110) self.sel_airtime_17720_label = Label(self.input_frame, font=("宋体", self.font_size_text), text='17720充气时间:', anchor='w') self.sel_airtime_17720_label.place(x=400, y=110) self.sel_airtime_17720_entry = tkinter.Entry(self.input_frame, width=28) # 设置"文本变量"为var self.sel_airtime_17720_entry.place(x=530, y=110) self.sel_airtime_17720_entry.insert(0, self.sel_airtime_17720) self.sel_airtime_17720_unit = Label(self.input_frame, text="sec", font=("宋体", self.font_size_text), anchor='w') self.sel_airtime_17720_unit.place(x=710, y=110) self.sel_presstime_17700_label = Label(self.input_frame, font=("宋体", self.font_size_text), text='17700保压时间:', anchor='w') self.sel_presstime_17700_label.place(x=20, y=140) self.sel_presstime_17700_entry = tkinter.Entry(self.input_frame, width=28) # 设置"文本变量"为var self.sel_presstime_17700_entry.place(x=150, y=140) self.sel_presstime_17700_entry.insert(0, self.sel_presstime_17700) self.sel_presstime_17700_unit = Label(self.input_frame, text="sec", font=("宋体", self.font_size_text), anchor='w') self.sel_presstime_17700_unit.place(x=330, y=140) self.sel_presstime_17720_label = Label(self.input_frame, font=("宋体", self.font_size_text), text='17720保压时间:', anchor='w') self.sel_presstime_17720_label.place(x=400, y=140) self.sel_presstime_17720_entry = tkinter.Entry(self.input_frame, width=28) # 设置"文本变量"为var self.sel_presstime_17720_entry.place(x=530, y=140) self.sel_presstime_17720_entry.insert(0, self.sel_presstime_17720) self.sel_presstime_17720_unit = Label(self.input_frame, text="sec", font=("宋体", self.font_size_text), anchor='w') self.sel_presstime_17720_unit.place(x=710, y=140) self.sel_testtime_17700_label = Label(self.input_frame, font=("宋体", self.font_size_text), text='17700测试时间:', anchor='w') self.sel_testtime_17700_label.place(x=20, y=170) self.sel_testtime_17700_entry = tkinter.Entry(self.input_frame, width=28) # 设置"文本变量"为var self.sel_testtime_17700_entry.place(x=150, y=170) self.sel_testtime_17700_entry.insert(0, self.sel_testtime_17700) self.sel_testtime_17700_unit = Label(self.input_frame, text="sec", font=("宋体", self.font_size_text), anchor='w') self.sel_testtime_17700_unit.place(x=330, y=170) self.sel_testtime_17720_label = Label(self.input_frame, font=("宋体", self.font_size_text), text='17720测试时间:', anchor='w') self.sel_testtime_17720_label.place(x=400, y=170) self.sel_testtime_17720_entry = tkinter.Entry(self.input_frame, width=28) # 设置"文本变量"为var self.sel_testtime_17720_entry.place(x=530, y=170) self.sel_testtime_17720_entry.insert(0, self.sel_testtime_17720) self.sel_testtime_17720_unit = Label(self.input_frame, text="sec", font=("宋体", self.font_size_text), anchor='w') self.sel_testtime_17720_unit.place(x=710, y=170) self.sel_exhaust_17700_label = Label(self.input_frame, font=("宋体", self.font_size_text), text='17700排气时间:', anchor='w') self.sel_exhaust_17700_label.place(x=20, y=200) self.sel_exhaust_17700_entry = tkinter.Entry(self.input_frame, width=28) # 设置"文本变量"为var self.sel_exhaust_17700_entry.place(x=150, y=200) self.sel_exhaust_17700_entry.insert(0, self.sel_exhaust_17700) self.sel_exhaust_17700_unit = Label(self.input_frame, text="sec", font=("宋体", self.font_size_text), anchor='w') self.sel_exhaust_17700_unit.place(x=330, y=200) self.sel_exhaust_17720_label = Label(self.input_frame, font=("宋体", self.font_size_text), text='17720排气时间:', anchor='w') self.sel_exhaust_17720_label.place(x=400, y=200) self.sel_exhaust_17720_entry = tkinter.Entry(self.input_frame, width=28) # 设置"文本变量"为var self.sel_exhaust_17720_entry.place(x=530, y=200) self.sel_exhaust_17720_entry.insert(0, self.sel_exhaust_17720) self.sel_exhaust_17720_unit = Label(self.input_frame, text="sec", font=("宋体", self.font_size_text), anchor='w') self.sel_exhaust_17720_unit.place(x=710, y=200) self.sel_maxpress_17700_label = Label(self.input_frame, font=("宋体", self.font_size_text), text='17700最大压力:', anchor='w') self.sel_maxpress_17700_label.place(x=20, y=230) self.sel_maxpress_17700_entry = tkinter.Entry(self.input_frame, width=28) # 设置"文本变量"为var self.sel_maxpress_17700_entry.place(x=150, y=230) self.sel_maxpress_17700_entry.insert(0, self.sel_maxpress_17700) self.sel_maxpress_17700_unit = Label(self.input_frame, text="Kpa", font=("宋体", self.font_size_text), anchor='w') self.sel_maxpress_17700_unit.place(x=330, y=230) self.sel_maxpress_17720_label = Label(self.input_frame, font=("宋体", self.font_size_text), text='17720最大压力:', anchor='w') self.sel_maxpress_17720_label.place(x=400, y=230) self.sel_maxpress_17720_entry = tkinter.Entry(self.input_frame, width=28) # 设置"文本变量"为var self.sel_maxpress_17720_entry.place(x=530, y=230) self.sel_maxpress_17720_entry.insert(0, self.sel_maxpress_17720) self.sel_maxpress_17720_unit = Label(self.input_frame, text="Kpa", font=("宋体", self.font_size_text), anchor='w') self.sel_maxpress_17720_unit.place(x=710, y=230) self.sel_minpress_17700_label = Label(self.input_frame, font=("宋体", self.font_size_text), text='17700最小压力:', anchor='w') self.sel_minpress_17700_label.place(x=20, y=260) self.sel_minpress_17700_entry = tkinter.Entry(self.input_frame, width=28) # 设置"文本变量"为var self.sel_minpress_17700_entry.place(x=150, y=260) self.sel_minpress_17700_entry.insert(0, self.sel_minpress_17700) self.sel_minpress_17700_unit = Label(self.input_frame, text="Kpa", font=("宋体", self.font_size_text), anchor='w') self.sel_minpress_17700_unit.place(x=330, y=260) self.sel_minpress_17720_label = Label(self.input_frame, font=("宋体", self.font_size_text), text='17720最小压力:', anchor='w') self.sel_minpress_17720_label.place(x=400, y=260) self.sel_minpress_17720_entry = tkinter.Entry(self.input_frame, width=28) # 设置"文本变量"为var self.sel_minpress_17720_entry.place(x=530, y=260) self.sel_minpress_17720_entry.insert(0, self.sel_minpress_17720) self.sel_minpress_17720_unit = Label(self.input_frame, text="Kpa", font=("宋体", self.font_size_text), anchor='w') self.sel_minpress_17720_unit.place(x=710, y=260) self.sel_setpress_17700_label = Label(self.input_frame, font=("宋体", self.font_size_text), text='17700设定压力:', anchor='w') self.sel_setpress_17700_label.place(x=20, y=290) self.sel_setpress_17700_entry = tkinter.Entry(self.input_frame, width=28) # 设置"文本变量"为var self.sel_setpress_17700_entry.place(x=150, y=290) self.sel_setpress_17700_entry.insert(0, self.sel_setpress_17700) self.sel_setpress_17700_unit = Label(self.input_frame, text="Kpa", font=("宋体", self.font_size_text), anchor='w') self.sel_setpress_17700_unit.place(x=330, y=290) self.sel_setpress_17720_label = Label(self.input_frame, font=("宋体", self.font_size_text), text='17720设定压力:', anchor='w') self.sel_setpress_17720_label.place(x=400, y=290) self.sel_setpress_17720_entry = tkinter.Entry(self.input_frame, width=28) # 设置"文本变量"为var self.sel_setpress_17720_entry.place(x=530, y=290) self.sel_setpress_17720_entry.insert(0, self.sel_setpress_17720) self.sel_setpress_17720_unit = Label(self.input_frame, text="Kpa", font=("宋体", self.font_size_text), anchor='w') self.sel_setpress_17720_unit.place(x=710, y=290) self.sel_capacity_17700_label = Label(self.input_frame, font=("宋体", self.font_size_text), text='17700容积:', anchor='w') self.sel_capacity_17700_label.place(x=20, y=320) self.sel_capacity_17700_entry = tkinter.Entry(self.input_frame, width=28) # 设置"文本变量"为var self.sel_capacity_17700_entry.place(x=150, y=320) self.sel_capacity_17700_entry.insert(0, self.sel_capacity_17700) self.sel_capacity_17700_unit = Label(self.input_frame, text="ml", font=("宋体", self.font_size_text), anchor='w') self.sel_capacity_17700_unit.place(x=330, y=320) self.sel_capacity_17720_label = Label(self.input_frame, font=("宋体", self.font_size_text), text='17720容积:', anchor='w') self.sel_capacity_17720_label.place(x=400, y=320) self.sel_capacity_17720_entry = tkinter.Entry(self.input_frame, width=28) # 设置"文本变量"为var self.sel_capacity_17720_entry.place(x=530, y=320) self.sel_capacity_17720_entry.insert(0, self.sel_capacity_17720) self.sel_capacity_17720_unit = Label(self.input_frame, text="ml", font=("宋体", self.font_size_text), anchor='w') self.sel_capacity_17720_unit.place(x=710, y=320) self.sel_posthreshold_17700_label = Label(self.input_frame, font=("宋体", self.font_size_text), text='17700正阈值:', anchor='w') self.sel_posthreshold_17700_label.place(x=20, y=350) self.sel_posthreshold_17700_entry = tkinter.Entry(self.input_frame, width=28) # 设置"文本变量"为var self.sel_posthreshold_17700_entry.place(x=150, y=350) self.sel_posthreshold_17700_entry.insert(0, self.sel_posthreshold_17700) self.sel_posthreshold_17700_unit = Label(self.input_frame, text="ml/min", font=("宋体", self.font_size_text), anchor='w') self.sel_posthreshold_17700_unit.place(x=330, y=350) self.sel_posthreshold_17720_label = Label(self.input_frame, font=("宋体", self.font_size_text), text='17720正阈值:', anchor='w') self.sel_posthreshold_17720_label.place(x=400, y=350) self.sel_posthreshold_17720_entry = tkinter.Entry(self.input_frame, width=28) # 设置"文本变量"为var self.sel_posthreshold_17720_entry.place(x=530, y=350) self.sel_posthreshold_17720_entry.insert(0, self.sel_posthreshold_17720) self.sel_posthreshold_17720_unit = Label(self.input_frame, text="ml/min", font=("宋体", self.font_size_text), anchor='w') self.sel_posthreshold_17720_unit.place(x=710, y=350) self.sel_pnegthreshold_17700_label = Label(self.input_frame, font=("宋体", self.font_size_text), text='17700负阈值:', anchor='w') self.sel_pnegthreshold_17700_label.place(x=20, y=380) self.sel_pnegthreshold_17700_entry = tkinter.Entry(self.input_frame, width=28) # 设置"文本变量"为var self.sel_pnegthreshold_17700_entry.place(x=150, y=380) self.sel_pnegthreshold_17700_entry.insert(0, self.sel_pnegthreshold_17700) self.sel_pnegthreshold_17700_unit = Label(self.input_frame, text="ml/min", font=("宋体", self.font_size_text), anchor='w') self.sel_pnegthreshold_17700_unit.place(x=330, y=380) self.sel_pnegthreshold_17720_label = Label(self.input_frame, font=("宋体", self.font_size_text), text='17720负阈值:', anchor='w') self.sel_pnegthreshold_17720_label.place(x=400, y=380) self.sel_pnegthreshold_17720_entry = tkinter.Entry(self.input_frame, width=28) # 设置"文本变量"为var self.sel_pnegthreshold_17720_entry.place(x=530, y=380) self.sel_pnegthreshold_17720_entry.insert(0, self.sel_pnegthreshold_17720) self.sel_pnegthreshold_17720_unit = Label(self.input_frame, text="ml/min", font=("宋体", self.font_size_text), anchor='w') self.sel_pnegthreshold_17720_unit.place(x=710, y=380) self.input_enterbtn = tkinter.Button(self.input_frame, text='确定', width=10, command=self.input_enter) # 按下此按钮(Input), 触发inputint函数 self.input_cancelbtn = tkinter.Button(self.input_frame, text='取消', width=10, command=self.input_exit) # 按下此按钮(Clear), 触发inputclear函数 self.input_enterbtn.place(x=150, y=430) self.input_cancelbtn.place(x=500, y=430) self.sel_product_name_entry.focus() self.sel_product_name_entry.xview("end") self.input_frame.resizable(width=False, height=False) self.input_frame.wm_attributes('-topmost', 1) self.input_frame.attributes("-toolwindow", 2) self.input_frame.focus_force() self.input_frame.protocol("WM_DELETE_WINDOW", self.input_on_closing) self.input_lock = True self.input_frame.mainloop() def product_double_event(self, event, idx): print("Product Name Double Event!") # if self.user_var.auth_stat == True: # self.input_param(idx) # else: # tkinter.messagebox.showwarning(title='提示', message='请登录后操作!') # 输入栏 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) self.product_sel_button_01 = Button(self.order_frame, text="{0:02d}".format(1), width=6, font=("宋体", self.font_size_title, "bold"), command=lambda: self.product_sel_button_event(0)) self.product_sel_button_01.place(x=20, y=0*60 + 20) # if self.user_var.product_list[0] == '': # self.product_sel_button_01.configure(state="disabled") self.product_sel_label_01 = Label(self.order_frame, textvariable=self.user_var.product_list_str[0], fg='PaleGreen', font=("宋体", self.font_size_title), bg="black", anchor='c', width=35, height=2) # self.product_sel_label_01.bind("", # lambda event: self.product_double_event(event, 0)) self.product_sel_label_01.place(x=120, y=0*60 + 15) self.product_sel_button_02 = Button(self.order_frame, text="{0:02d}".format(2), width=6, font=("宋体", self.font_size_title, "bold"), command=lambda: self.product_sel_button_event(1)) self.product_sel_button_02.place(x=20, y=1 * 60 + 20) # if self.user_var.product_list[1] == '': # self.product_sel_button_02.configure(state="disabled") self.product_sel_label_02 = Label(self.order_frame, textvariable=self.user_var.product_list_str[1], fg='PaleGreen', font=("宋体", self.font_size_title), bg="black", anchor='c', width=35, height=2) # self.product_sel_label_02.bind("", # lambda event: self.product_double_event(event, 1)) self.product_sel_label_02.place(x=120, y=1 * 60 + 15) self.product_sel_button_03 = Button(self.order_frame, text="{0:02d}".format(3), width=6, font=("宋体", self.font_size_title, "bold"), command=lambda: self.product_sel_button_event(2)) self.product_sel_button_03.place(x=20, y=2 * 60 + 20) # if self.user_var.product_list[2] == '': # self.product_sel_button_03.configure(state="disabled") self.product_sel_label_03 = Label(self.order_frame, textvariable=self.user_var.product_list_str[2], fg='PaleGreen', font=("宋体", self.font_size_title), bg="black", anchor='c', width=35, height=2) # self.product_sel_label_03.bind("", # lambda event: self.product_double_event(event, 2)) self.product_sel_label_03.place(x=120, y=2 * 60 + 15) self.product_sel_button_04 = Button(self.order_frame, text="{0:02d}".format(4), width=6, font=("宋体", self.font_size_title, "bold"), command=lambda: self.product_sel_button_event(3)) self.product_sel_button_04.place(x=20, y=3 * 60 + 20) # if self.user_var.product_list[3] == '': # self.product_sel_button_04.configure(state="disabled") self.product_sel_label_04 = Label(self.order_frame, textvariable=self.user_var.product_list_str[3], fg='PaleGreen', font=("宋体", self.font_size_title), bg="black", anchor='c', width=35, height=2) # self.product_sel_label_04.bind("", # lambda event: self.product_double_event(event, 3)) self.product_sel_label_04.place(x=120, y=3 * 60 + 15) self.product_sel_button_05 = Button(self.order_frame, text="{0:02d}".format(5), width=6, font=("宋体", self.font_size_title, "bold"), command=lambda: self.product_sel_button_event(4)) self.product_sel_button_05.place(x=20, y=4 * 60 + 20) # if self.user_var.product_list[4] == '': # self.product_sel_button_05.configure(state="disabled") self.product_sel_label_05 = Label(self.order_frame, textvariable=self.user_var.product_list_str[4], fg='PaleGreen', font=("宋体", self.font_size_title), bg="black", anchor='c', width=35, height=2) # self.product_sel_label_05.bind("", # lambda event: self.product_double_event(event, 4)) self.product_sel_label_05.place(x=120, y=4 * 60 + 15) self.product_sel_button_06 = Button(self.order_frame, text="{0:02d}".format(6), width=6, font=("宋体", self.font_size_title, "bold"), command=lambda: self.product_sel_button_event(5)) self.product_sel_button_06.place(x=20, y=5 * 60 + 20) # if self.user_var.product_list[5] == '': # self.product_sel_button_06.configure(state="disabled") self.product_sel_label_06 = Label(self.order_frame, textvariable=self.user_var.product_list_str[5], fg='PaleGreen', font=("宋体", self.font_size_title), bg="black", anchor='c', width=35, height=2) # self.product_sel_label_06.bind("", # lambda event: self.product_double_event(event, 5)) self.product_sel_label_06.place(x=120, y=5 * 60 + 15) self.product_sel_button_07 = Button(self.order_frame, text="{0:02d}".format(7), width=6, font=("宋体", self.font_size_title, "bold"), command=lambda: self.product_sel_button_event(6)) self.product_sel_button_07.place(x=20, y=6 * 60 + 20) # if self.user_var.product_list[6] == '': # self.product_sel_button_07.configure(state="disabled") self.product_sel_label_07 = Label(self.order_frame, textvariable=self.user_var.product_list_str[6], fg='PaleGreen', font=("宋体", self.font_size_title), bg="black", anchor='c', width=35, height=2) # self.product_sel_label_07.bind("", # lambda event: self.product_double_event(event, 6)) self.product_sel_label_07.place(x=120, y=6 * 60 + 15) self.product_sel_button_08 = Button(self.order_frame, text="{0:02d}".format(8), width=6, font=("宋体", self.font_size_title, "bold"), command=lambda: self.product_sel_button_event(7)) self.product_sel_button_08.place(x=520, y=0 * 60 + 20) # if self.user_var.product_list[7] == '': # self.product_sel_button_08.configure(state="disabled") self.product_sel_label_08 = Label(self.order_frame, textvariable=self.user_var.product_list_str[7], fg='PaleGreen', font=("宋体", self.font_size_title), bg="black", anchor='c', width=35, height=2) # self.product_sel_label_08.bind("", # lambda event: self.product_double_event(event, 7)) self.product_sel_label_08.place(x=620, y=0 * 60 + 15) self.product_sel_button_09 = Button(self.order_frame, text="{0:02d}".format(9), width=6, font=("宋体", self.font_size_title, "bold"), command=lambda: self.product_sel_button_event(8)) self.product_sel_button_09.place(x=520, y=1 * 60 + 20) # if self.user_var.product_list[8] == '': # self.product_sel_button_09.configure(state="disabled") self.product_sel_label_09 = Label(self.order_frame, textvariable=self.user_var.product_list_str[8], fg='PaleGreen', font=("宋体", self.font_size_title), bg="black", anchor='c', width=35, height=2) # self.product_sel_label_09.bind("", # lambda event: self.product_double_event(event, 8)) self.product_sel_label_09.place(x=620, y=1 * 60 + 15) self.product_sel_button_10 = Button(self.order_frame, text="{0:02d}".format(10), width=6, font=("宋体", self.font_size_title, "bold"), command=lambda: self.product_sel_button_event(9)) self.product_sel_button_10.place(x=520, y=2 * 60 + 20) # if self.user_var.product_list[9] == '': # self.product_sel_button_10.configure(state="disabled") self.product_sel_label_10 = Label(self.order_frame, textvariable=self.user_var.product_list_str[9], fg='PaleGreen', font=("宋体", self.font_size_title), bg="black", anchor='c', width=35, height=2) # self.product_sel_label_10.bind("", # lambda event: self.product_double_event(event, 9)) self.product_sel_label_10.place(x=620, y=2 * 60 + 15) self.product_sel_button_11 = Button(self.order_frame, text="{0:02d}".format(11), width=6, font=("宋体", self.font_size_title, "bold"), command=lambda: self.product_sel_button_event(10)) self.product_sel_button_11.place(x=520, y=3 * 60 + 20) # if self.user_var.product_list[10] == '': # self.product_sel_button_11.configure(state="disabled") self.product_sel_label_11 = Label(self.order_frame, textvariable=self.user_var.product_list_str[10], fg='PaleGreen', font=("宋体", self.font_size_title), bg="black", anchor='c', width=35, height=2) # self.product_sel_label_11.bind("", # lambda event: self.product_double_event(event, 10)) self.product_sel_label_11.place(x=620, y=3 * 60 + 15) self.product_sel_button_12 = Button(self.order_frame, text="{0:02d}".format(12), width=6, font=("宋体", self.font_size_title, "bold"), command=lambda: self.product_sel_button_event(11)) self.product_sel_button_12.place(x=520, y=4 * 60 + 20) # if self.user_var.product_list[11] == '': # self.product_sel_button_12.configure(state="disabled") self.product_sel_label_12 = Label(self.order_frame, textvariable=self.user_var.product_list_str[11], fg='PaleGreen', font=("宋体", self.font_size_title), bg="black", anchor='c', width=35, height=2) # self.product_sel_label_12.bind("", # lambda event: self.product_double_event(event, 11)) self.product_sel_label_12.place(x=620, y=4 * 60 + 15) self.product_sel_button_13 = Button(self.order_frame, text="{0:02d}".format(13), width=6, font=("宋体", self.font_size_title, "bold"), command=lambda: self.product_sel_button_event(12)) self.product_sel_button_13.place(x=520, y=5 * 60 + 20) # if self.user_var.product_list[12] == '': # self.product_sel_button_13.configure(state="disabled") self.product_sel_label_13 = Label(self.order_frame, textvariable=self.user_var.product_list_str[12], fg='PaleGreen', font=("宋体", self.font_size_title), bg="black", anchor='c', width=35, height=2) # self.product_sel_label_13.bind("", # lambda event: self.product_double_event(event, 12)) self.product_sel_label_13.place(x=620, y=5 * 60 + 15) self.product_sel_button_14 = Button(self.order_frame, text="{0:02d}".format(14), width=6, font=("宋体", self.font_size_title, "bold"), command=lambda: self.product_sel_button_event(13)) self.product_sel_button_14.place(x=520, y=6 * 60 + 20) # if self.user_var.product_list[13] == '': # self.product_sel_button_14.configure(state="disabled") self.product_sel_label_14 = Label(self.order_frame, textvariable=self.user_var.product_list_str[13], fg='PaleGreen', font=("宋体", self.font_size_title), bg="black", anchor='c', width=35, height=2) # self.product_sel_label_14.bind("", # lambda event: self.product_double_event(event, 13)) self.product_sel_label_14.place(x=620, y=6 * 60 + 15) # for i in range(14): # exec('self.product_sel_button_{0:02d} = Button(self.order_frame, text="{1:02d}", width=6,\ # font=("宋体", self.font_size_title, "bold"),\ # command=lambda:self.product_sel_button_event({2}))'.format(i, i+1, i)) # exec('self.product_sel_button_{0:02d}.place(x=20, y={1} * 60 + 20)'.format(i, i)) # exec('if self.user_var.product_list[{0}] == "":\ # self.product_sel_button_{1:02d}.configure(state="disabled")'.format(i, i)) # exec('self.product_sel_label_{0:02d} = Label(self.order_frame, textvariable=self.user_var.product_list_str[{1}],\ # fg="PaleGreen", font=("宋体", self.font_size_title), bg="black", anchor="c",\ # width=35, height=2)'.format(i, i)) # exec('self.product_sel_label_{0:02d}.bind("",\ # lambda event:self.product_double_event(event, {1}))'.format(i, i)) # exec('self.product_sel_label_{0:02d}.place(x=120, y={1} * 60 + 15)'.format(i, i)) exec('self.product_sel_label_{0:02d}.config(fg="yellow")'.format(self.user_var.product_idx+1))