Created
April 13, 2022 21:01
-
-
Save mrprogrammer2938/30fd8b47509a141ba0b1d2cd94e2d52c to your computer and use it in GitHub Desktop.
Tkinter Tutorial- Listbox
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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