Есть такой код:
#!/usr/bin/python3 # -*- coding: UTF-8 -*- import tkinter as tk x = 1024 y = 768 root = tk.Tk() root.geometry('{}x{}'.format(x,y)) frm_prm = tk.Frame(root) frm_prm.pack(expand=1,fill='both') frm_ver = tk.Frame(frm_prm) frm_ver.pack (expand = 0 ,fill = 'y' ,side = 'right' ) cvs_prm = tk.Canvas(frm_prm) cvs_prm.pack(expand=1,fill='both') frm_emb = tk.Frame(frm_prm) frm_emb.pack(expand=1,fill='both') cvs_prm.create_window(0,0,window=frm_emb) txt_prm = tk.Text(frm_emb) txt_prm.pack(expand=1,fill='both') txt_prm.insert('1.0','hello') scrollbar = tk.Scrollbar (master = frm_ver ,orient = 'vertical' ) scrollbar.pack (expand = 1 ,fill = 'y' ,side = 'right' ) cvs_prm.configure (scrollregion = (-x/2,-y/2,x/2,y/2) ) cvs_prm.xview_moveto(0) cvs_prm.yview_moveto(0) txt_prm.config(yscrollcommand=scrollbar.set) scrollbar.config(command=cvs_prm.yview) root.mainloop()
.