Home > other >  Python tkinter
Python tkinter

Time:11-17

About python tkinter text content clear problem, I have two text interface control, I hope, after I clicked the button to clear the content of the text first, then to insert again, use text. The delete (1.0, END), but it's very strange, the first to delete text1 doesn't work, the second to delete text2 but effective

The class application (Frame) :
Def __init__ (self, master) :
Super () __init__ (master)
The self. The master=master
The self. The pack ()
The self. The init ()

Def getpassword (self) :
Global password
self. Text1. Delete (# 1.0, END) not the
Self. Text2. Delete (# 1.0, END) this can

Password=self. Entry. The get ()
If the password==":
Messagebox. Showinfo (title='tip' message='password cannot be empty)
The else:
Passwordcheck (password, 1)
Self. Text1. Insert (insert, result)
While passwordcheck (password, 0)!=100:
Passwordenhancement ()
The self. The text2. Insert (insert, password)

Def init (self) :
Self. Label1=Label (self, text="password:")
Self. Label1. The grid (row=0, sticky=W)

Self. Entry=entry (self, width=49)
Self. Entry. The grid (row=1, sticky=W)

Self. Label2=Label (self, text="analysis results:")
Self. Label2. The grid (row=2, sticky=W)

The self. The button=button (self, text="test", width=5, height=1, the command=self. Getpassword)
The self. The button. The grid (row=1, the column=2, sticky=E)

Self. Text1=Text (self, width=50, height=25)
Self. Text1. The grid (row=4, sticky=E)

Self. Label3=Label (self, text="enhanced password:")
Self. Label3. The grid (row=5, sticky=W)

Self. Text2=Text (self, width=49, height=1)
Self. Text2. The grid (row=6, sticky=W)


If __name__=="__main__ ':
Win=Tk ()
Win the title (' weak passwords)
Win. Geometry (' 500 x500 ')
App=application (win)
Win the mainloop ()

CodePudding user response:

Self. Text1. Delete (' 1.0 'END)
Self. Text2. Delete (' 1.0 'END)
Before the index value to quotes, is a string,
  • Related