Guest User

Untitled

a guest
Jan 19th, 2019
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.98 KB | None | 0 0
  1. import Tkinter
  2. import re
  3. root=Tkinter.Tk()
  4.  
  5. E1=Tkinter.Entry(root)
  6. E1.pack()
  7.  
  8. E2=Tkinter.Entry(root)
  9. E2.pack()
  10.  
  11. L1=Tkinter.Label(root,text='Label1')
  12. L1.pack()
  13.  
  14. >> re.search(r'Entry',wlist[0])
  15. << No output >>
  16.  
  17. ## Assuming I have a function to to clear the entry
  18. ## How would I pass the object from the pattern match in #2 to this function?
  19. def clear_entry(objEntry):
  20. objEntry.delete(0,Tkinter.END)
  21.  
  22. >>> wlist[0].winfo_class()
  23. 'Entry'
  24.  
  25. >>> isinstance(wlist[0], Tkinter.Entry)
  26. True
  27.  
  28. for widget in root.winfo_children():
  29. if isinstance(widget, Tkinter.Entry):
  30. widget.delete(0, "end")
  31.  
  32. entry_list=[E1, E2]
  33.  
  34. def clear_entry():
  35. for id in entry_list:
  36. id.delete(0,Tkinter.END)
  37.  
  38. if type(wlist[0]) == Tkinter.Entry: # True/False
  39.  
  40. if isinstance(wlist[0], Tkinter.Entry): # True/False
  41.  
  42. wlist[0].delete(0,Tkinter.END)
  43.  
  44. clear_entry(wlist[0])
  45.  
  46. print str(wlist[0])
  47.  
  48. .353964488L
  49.  
  50. print repr(wlist[0])
  51.  
  52. <Tkinter.Entry instance at 0x00000000151911C8>
Add Comment
Please, Sign In to add comment