def __init__(self, master, **kwargs):
Frame.__init__(self, master)
textarea_frame = Frame(self, bd=1, relief=SOLID,**kwargs)
textarea_frame.pack(fill=X)
textarea_frame.pack_propagate(False)
self.textarea = Text(textarea_frame, height=1, pady=self.TAG_ENTRY_PADY, padx=self.TAG_ENTRY_PADX, highlightthickness =0, spacing1=0, spacing2=0, spacing3=0, borderwidth=0, wrap="none")
self.textarea.pack(expand=True, fill=BOTH, padx=2)
scrollbar = Scrollbar(self, orient=HORIZONTAL, command=self.textarea.xview)
scrollbar.pack(fill=X)
self.textarea.configure(xscrollcommand=scrollbar.set)
self.textarea.bind("<KeyPress>",self._on_keypress)
tag = Tag(self.textarea, "")
self.textarea.window_create("1.0", window=tag)
self.update_idletasks()
tag_reqheight = tag.winfo_reqheight()
textarea_frame.configure(height=tag_reqheight + 2*self.TAG_ENTRY_PADY+2*self.textarea["borderwidth"])
# I add a hidden frame because I want the cursor centered including when there is no tag
self.textarea.window_create("1.0", window=Frame(self.textarea, height=tag_reqheight, width=0, borderwidth=0))
tag.destroy()
评论列表
文章目录