tk3_entry_text.py 789 B

1234567891011121314151617181920212223242526272829303132
  1. # View more python learning tutorial on my Youtube and Youku channel!!!
  2. # Youtube video tutorial: https://www.youtube.com/channel/UCdyjiB5H8Pu7aDTNVXTTpcg
  3. # Youku video tutorial: http://i.youku.com/pythontutorial
  4. import tkinter as tk
  5. window = tk.Tk()
  6. window.title('my window')
  7. window.geometry('200x200')
  8. # e = tk.Entry(window, show="*")
  9. e = tk.Entry(window, show="1")
  10. e.pack()
  11. def insert_point():
  12. var = e.get()
  13. t.insert('insert', var)
  14. def insert_end():
  15. var = e.get()
  16. # t.insert('end', var)
  17. t.insert(2.2, var)
  18. b1 = tk.Button(window, text='insert point', width=15,
  19. height=2, command=insert_point)
  20. b1.pack()
  21. b2 = tk.Button(window, text='insert end',
  22. command=insert_end)
  23. b2.pack()
  24. t = tk.Text(window, height=2)
  25. t.pack()
  26. window.mainloop()