Free Python Code for Making a Scroll Bar

This is free Python 3x code that shows how to create a list-box with a scroll-bar in Python 3x. Just copy and paste the code into Python and run it:

import tkinter
s = tkinter.Scrollbar()
L = tkinter.Listbox()

s.pack(side=tkinter.RIGHT, fill=tkinter.Y)
L.pack(side=tkinter.LEFT, fill=tkinter.Y)

s.config(command=L.yview)
L.config(yscrollcommand=s.set)

for i in range(30):
      L.insert(tkinter.END, str(i)*3)

tkinter.mainloop()

#Get a value

import tkinter

F1 = tkinter.Frame()
s = tkinter.Scrollbar(F1)
L = tkinter.Listbox(F1)

s.pack(side=tkinter.RIGHT, fill=tkinter.Y)
L.pack(side=tkinter.LEFT, fill=tkinter.Y)

s['command'] = L.yview
L['yscrollcommand'] = s.set

for i in range(30):
      L.insert(tkinter.END, str(i))

F1.pack(side=tkinter.TOP)

F2 = tkinter.Frame()
lab = tkinter.Label(F2)

def poll():
      lab.after(200, poll)
      sel = L.curselection()
      lab.config(text=str(sel))

lab.pack()
F2.pack(side=tkinter.TOP)

poll()
tkinter.mainloop()

#instert item

from tkinter import *

root = Tk()
root.title('Listbox')
list = Listbox(root, width=15)
list.pack()

for item in range(10):
      list.insert(END, item)

root.mainloop()