#!/usr/bin/env python3 # coding: utf-8 from six.moves.tkinter import * class ScrollFrame(Frame): def __init__(self, *args, **params): Frame.__init__(*(self,) + args, **params) width = params.get("width", 80) height = params.get("height", 20) self.content = Text(self, height=height, width=width, selectbackground="lightgray") self.content.grid(column=1, row=1, sticky='nesw') self.vscrollbar = Scrollbar(self, name='vscrollbar', command=self.content.yview, orient='v') self.vscrollbar.grid(column=2, row=1, sticky='nesw') self.content['yscrollcommand'] = self.vscrollbar.set self.grid_rowconfigure (1, weight=1) self.grid_columnconfigure(1, weight=1) self.pack(side=TOP, fill=BOTH, expand=1) def focus(self): self.content.focus_set() if __name__ == "__main__": root = Tk() o = ScrollFrame(root) root.mainloop()