# -*- coding: utf-8 -*- import tkinter as tk import tkinter.ttk as ttk root = tk.Tk() root.title("tk30.py") root.geometry("300x250") ##################################### frame_left = tk.Frame(root) frame_left.pack(side = tk.LEFT, fill = tk.Y) sb = tk.Scrollbar(frame_left) sb.pack(side = tk.RIGHT, fill = tk.Y) var = tk.StringVar() alist = tk.Listbox(frame_left, yscrollcommand = sb.set) for line in range(100): alist.insert(tk.END, "Line Number: {}".format(line)) alist.pack(fill = tk.BOTH) sb.config(command = alist.yview) bt = tk.Button(frame_left, text = 'button', command = lambda: lb.config(text = str(alist.curselection()))) bt.pack() lb = tk.Label(frame_left, text = 'label') lb.pack() frame_right = ttk.Frame(root) frame_right.pack(side = tk.RIGHT, fill = tk.Y) tsb = ttk.Scrollbar(frame_right) tsb.pack(side = tk.RIGHT, fill = tk.Y) blist = tk.Listbox(frame_right, yscrollcommand = tsb.set, selectmode = tk.MULTIPLE) for line in range(100): blist.insert(tk.END, "Line Number: {}".format(line)) blist.pack(fill = tk.BOTH) tsb.config(command = blist.yview) tbt = ttk.Button(frame_right, text = 'button', command = lambda: tlb.config(text = str(blist.curselection()))) tbt.pack() tlb = ttk.Label(frame_right, text = 'label') tlb.pack() ##################################### root.mainloop()