部分代码示例如下:
calss test():
def __init__(self,cashback_policy)
self.cashback_policy=cashback_policy
#函数上包含参数时,需要加上event
def delete_text_1(self, num, event, CASH_TYPE, Upper_half):
if self.cashback_policy.get() == CASH_TYPE['cash_type']:
self.cashback_policy.config(state='readonly')
def test_1(self,Upper_half,CASH_TYPE):
tk.Label(Upper_half, text='政策类型:', bd=3, relief='groove', width=9, anchor='e').grid(row=0,column=2,padx=2)
self.cashback_policy = tk.Entry(Upper_half, bd='5', width=20)
self.cashback_policy.insert(0, CASH_TYPE['cash_type'])
self.cashback_policy.config(fg='grey')
#lambda event:函数名(event,参数)
self.cashback_policy.bind('<Button-1>', lambda event:self.delete_text_1(self,event,CASH_TYPE,Upper_half))
self.cashback_policy.grid(row=0, column=3)