Skip to content

Instantly share code, notes, and snippets.

@mrprogrammer2938
Created April 13, 2022 21:01
Show Gist options
  • Save mrprogrammer2938/30fd8b47509a141ba0b1d2cd94e2d52c to your computer and use it in GitHub Desktop.
Save mrprogrammer2938/30fd8b47509a141ba0b1d2cd94e2d52c to your computer and use it in GitHub Desktop.
Tkinter Tutorial- Listbox
from tkinter import *
from tkinter.ttk import Button
from tkinter.messagebox import showinfo
root = Tk()
root.title("Window")
def sub_value():
value = str(inp.get())
li.insert(END,value)
def get_value():
showinfo(title="Information",message=f"You Click The: {li.get(li.curselection())}")
def clear_list():
li.delete(0,END)
l = Label(root,text="Enter Value: ").pack()
inp = Entry(root)
inp.pack(padx=5,pady=5)
li = Listbox(root)
li.pack(side='right',expand=True)
sub_btn = Button(root,text="Submit Value",command=sub_value).pack()
btn = Button(root,text="Get Value",command=get_value).pack()
clear_btn = Button(root,text="Clear List",command=clear_list).pack()
exit_btn = Button(root,text="Exit",command=root.quit).pack()
root.geometry("500x400+500+80")
root.resizable(0,0)
root.mainloop()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment