Tkinter
Showing a Window
It's easy to create a desktop application with Tkinter.
- Import tkinter
- Create a window instance,
- Set the title of the window,
- Run the window in a mainloop.
python
import tkinter
window = tkinter.Tk()
window.title = "My Special App"
# widgets are added here
window.mainloop()
Button Commands
python
import tkinter as tk
window = tk.Tk()
window.title('Counting Seconds')
button = tk.Button(window, text='Stop', width=25, command=window.destroy)
button.pack()
window.mainloop()
Draw on a Canvas
python
from tkinter import *
master = Tk()
w = Canvas(master, width=40, height=60)
w.pack()
canvas_height=20
canvas_width=200
y = int(canvas_height / 2)
w.create_line(0, y, canvas_width, y )
mainloop()
Check A Button
python
from tkinter import *
master = Tk()
var1 = IntVar()
Checkbutton(master, text='male', variable=var1).grid(row=0, sticky=W)
var2 = IntVar()
Checkbutton(master, text='female', variable=var2).grid(row=1, sticky=W)
mainloop()
Entering Text
You can enter text in an Entry field.
python
from tkinter import *
master = Tk()
Label(master, text='First Name').grid(row=0)
Label(master, text='Last Name').grid(row=1)
e1 = Entry(master)
e2 = Entry(master)
e1.grid(row=0, column=1)
e2.grid(row=1, column=1)
mainloop()
List Box
python
from tkinter import *
top = Tk()
Lb = Listbox(top)
Lb.insert(1, 'Python')
Lb.insert(2, 'Java')
Lb.insert(3, 'C++')
Lb.insert(4, 'Any other')
Lb.pack()
top.mainloop()
Menu
python
from tkinter import *
root = Tk()
menu = Menu(root)
root.config(menu=menu)
filemenu = Menu(menu)
menu.add_cascade(label='File', menu=filemenu)
filemenu.add_command(label='New')
filemenu.add_command(label='Open...')
filemenu.add_separator()
filemenu.add_command(label='Exit', command=root.quit)
helpmenu = Menu(menu)
menu.add_cascade(label='Help', menu=helpmenu)
helpmenu.add_command(label='About')
mainloop()
Text
python
from tkinter import *
root = Tk()
T = Text(root, height=2, width=30)
T.pack()
T.insert(END, 'GeeksforGeeks\nBEST WEBSITE\n')
mainloop()
Top Level
python
from tkinter import *
root = Tk()
root.title('GfG')
top = Toplevel()
top.title('Python')
top.mainloop()
Geometry
python
# Importing tkinter module
from tkinter import *
from tkinter.ttk import *
# creating Tk window
master = Tk()
# setting geometry of tk window
master.geometry("200x200")
# button widget
b1 = Button(master, text = "Click me !")
b1.place(relx = 1, x =-2, y = 2, anchor = NE)
# label widget
l = Label(master, text = "I'm a Label")
l.place(anchor = NW)
# button widget
b2 = Button(master, text = "GFG")
b2.place(relx = 0.5, rely = 0.5, anchor = CENTER)
# infinite loop which is required to
# run tkinter program infinitely
# until an interrupt occurs
mainloop()
Grid
python
# import tkinter module
from tkinter import *
from tkinter.ttk import *
# creating main tkinter window/toplevel
master = Tk()
# this will create a label widget
l1 = Label(master, text = "First:")
l2 = Label(master, text = "Second:")
# grid method to arrange labels in respective
# rows and columns as specified
l1.grid(row = 0, column = 0, sticky = W, pady = 2)
l2.grid(row = 1, column = 0, sticky = W, pady = 2)
# entry widgets, used to take entry from user
e1 = Entry(master)
e2 = Entry(master)
# this will arrange entry widgets
e1.grid(row = 0, column = 1, pady = 2)
e2.grid(row = 1, column = 1, pady = 2)
# infinite loop which can be terminated by keyboard
# or mouse interrupt
mainloop()
Pack
python
# Importing tkinter module
from tkinter import * from tkinter.ttk import *
# creating Tk window
master = Tk()
# creating a Fra, e which can expand according
# to the size of the window
pane = Frame(master)
pane.pack(fill = BOTH, expand = True)
# button widgets which can also expand and fill
# in the parent widget entirely
# Button 1
b1 = Button(pane, text = "Click me !")
b1.pack(fill = BOTH, expand = True)
# Button 2
b2 = Button(pane, text = "Click me too")
b2.pack(fill = BOTH, expand = True)
# Execute Tkinter
master.mainloop()
Functions
python
# Import all files from
# tkinter and overwrite
# all the tkinter files
# by tkinter.ttk
from tkinter import *
from tkinter.ttk import *
# creates tkinter window or root window
root = Tk()
root.geometry('200x100')
# function to be called when mouse enters in a frame
def enter(event):
print('Button-2 pressed at x = % d, y = % d'%(event.x, event.y))
# function to be called when mouse exits the frame
def exit_(event):
print('Button-3 pressed at x = % d, y = % d'%(event.x, event.y))
# frame with fixed geometry
frame1 = Frame(root, height = 100, width = 200)
# these lines are showing the
# working of bind function
# it is universal widget method
frame1.bind('<Enter>', enter)
frame1.bind('<Leave>', exit_)
frame1.pack()
mainloop()
Double CLick
python
from tkinter import *
def go(event):
cs = Lb.curselection()
# Updating label text to selected option
w.config(text=Lb.get(cs))
# Setting Background Colour
for list in cs:
if list == 0:
top.configure(background='red')
elif list == 1:
top.configure(background='green')
elif list == 2:
top.configure(background='yellow')
elif list == 3:
top.configure(background='white')
top = Tk()
top.geometry('250x275')
top.title('Double Click')
# Creating Listbox
Lb = Listbox(top, height=6)
# Inserting items in Listbox
Lb.insert(0, 'Red')
Lb.insert(1, 'Green')
Lb.insert(2, 'Yellow')
Lb.insert(3, 'White')
# Binding double click with left mouse
# button with go function
Lb.bind('<Double-1>', go)
Lb.pack()
# Creating Edit box to show selected option
w = Label(top, text='Default')
w.pack()
top.mainloop()
Right Click
python
import tkinter
from tkinter import *
root = Tk()
L = Label(root, text ="Right-click to display menu",
width = 40, height = 20)
L.pack()
m = Menu(root, tearoff = 0)
m.add_command(label ="Cut")
m.add_command(label ="Copy")
m.add_command(label ="Paste")
m.add_command(label ="Reload")
m.add_separator()
m.add_command(label ="Rename")
def do_popup(event):
try:
m.tk_popup(event.x_root, event.y_root)
finally:
m.grab_release()
L.bind("<Button-3>", do_popup)
mainloop()
Images
python
import tkinter
from tkinter import *
root = Tk()
L = Label(root, text ="Right-click to display menu",
width = 40, height = 20)
L.pack()
m = Menu(root, tearoff = 0)
m.add_command(label ="Cut")
m.add_command(label ="Copy")
m.add_command(label ="Paste")
m.add_command(label ="Reload")
m.add_separator()
m.add_command(label ="Rename")
def do_popup(event):
try:
m.tk_popup(event.x_root, event.y_root)
finally:
m.grab_release()
L.bind("<Button-3>", do_popup)
mainloop()
CustomTKinter
CustomTkinter is an updated version of Tkinter that focuses on the look and feel of Tkinter, making the application look more modern.
python
pip3 install customtkinter
python
import customtkinter
customtkinter.set_appearance_mode("System") # Modes: system (default), light, dark
customtkinter.set_default_color_theme("blue") # Themes: blue (default), dark-blue, green
app = customtkinter.CTk() # create CTk window like you do with the Tk window
app.geometry("400x240")
def button_function():
print("button pressed")
# Use CTkButton instead of tkinter Button
button = customtkinter.CTkButton(master=app, text="CTkButton", command=button_function)
button.place(relx=0.5, rely=0.5, anchor=customtkinter.CENTER)
app.mainloop()
Advanced Example
python
import tkinter
import tkinter.messagebox
import customtkinter
from tkinter import ttk
from customtkinter import *
import os
import re
from PIL import Image, ImageTk
import random
# Modes: "System" (standard), "Dark", "Light"
customtkinter.set_appearance_mode("dark")
# Themes: "blue" (standard), "green", "dark-blue"
customtkinter.set_default_color_theme("green")
class App(customtkinter.CTk):
def __init__(self):
super().__init__()
self.current_prompts = []
# configure window
self.title("Sample App")
self.geometry(f"{1100}x{820}")
# configure grid layout (4x4)
self.grid_columnconfigure(1, weight=1)
self.grid_columnconfigure((2, 3), weight=0)
self.grid_rowconfigure((0, 1, 2), weight=1)
# image_path = os.path.join(os.path.dirname(
# os.path.realpath(__file__)), "test_images")
# self.logo_image = CTkImage(Image.open(
# os.path.join(image_path, "star.png")), size=(20, 20))
# self.bg_image_label = customtkinter.CTkLabel(
# self, image=self.logo_image)
# create sidebar frame with widgets
self.sidebar_frame = CTkFrame(self,
width=140,
height=300,
corner_radius=0)
self.sidebar_frame.grid(row=0,
column=0,
rowspan=4,
sticky="nsew")
self.sidebar_frame.grid_rowconfigure(4, weight=1)
self.logo_label = CTkLabel(self.sidebar_frame,
text="Sample App",
font=CTkFont(size=20, weight="bold"))
self.logo_label.grid(row=0,
column=0,
padx=20,
pady=(20, 10))
self.string_input_button_generate = CTkButton(
self.sidebar_frame, text="Generate", command=self.generate_prompt)
self.string_input_button_generate.grid(
row=1, column=0, padx=20, pady=10)
self.button_clear = CTkButton(
self.sidebar_frame, text="Clear", command=self.clear_prompts)
self.button_clear.grid(row=2, column=0, padx=20, pady=10)
self.button_new_chat = CTkButton(
self.sidebar_frame, command=self.sidebar_button_event, text="+ New chat")
self.button_new_chat.grid(row=3, column=0, padx=20, pady=10)
# self.button_marketing = CTkButton(self.sidebar_frame,
# command=self.sidebar_button_event,
# text="Specials",
# image=self.logo_image)
# self.button_marketing.grid(row=4, column=0, padx=20, pady=10)
self.button_side_bar_disabled = CTkButton(self.sidebar_frame, command=self.sidebar_button_event)
self.button_side_bar_disabled.grid(row=5,
column=0,
padx=20,
pady=10)
self.appearance_mode_label = CTkLabel(
self.sidebar_frame, text="Appearance Mode:", anchor="w")
self.appearance_mode_label.grid(row=6, column=0, padx=20, pady=(10, 0))
self.appearance_mode_optionemenu = CTkOptionMenu(self.sidebar_frame,
values=["Light", "Dark", "System"],
command=self.change_appearance_mode_event)
self.appearance_mode_optionemenu.grid(row=6,
column=0,
padx=20,
pady=(10, 10))
self.scaling_label = CTkLabel(
self.sidebar_frame, text="UI Scaling:", anchor="w")
self.scaling_label.grid(row=7, column=0, padx=20, pady=(10, 0))
self.scaling_optionemenu = CTkOptionMenu(self.sidebar_frame,
values=["80%", "90%", "100%", "110%", "120%"],
command=self.change_scaling_event)
self.scaling_optionemenu.grid(row=8,
column=0,
padx=20,
pady=(10, 20))
# create main entry and button
self.entry = CTkEntry(
self, placeholder_text="Send a message")
self.entry.grid(row=3, column=1, columnspan=2, padx=(
20, 0), pady=(20, 20), sticky="nsew")
self.main_button_1 = CTkButton(master=self,
fg_color="transparent",
text="Send",
border_width=2,
text_color=("gray10", "#DCE4EE"))
self.main_button_1.grid(row=3,
column=3,
padx=(20, 20),
pady=(20, 20),
sticky="nsew")
# create textbox
self.textbox = CTkTextbox(self,
width=250,
font=CTkFont(size=20, weight="normal"))
self.textbox.grid(row=0,
column=1,
padx=(20, 0),
pady=(20, 0),
sticky="nsew")
self.textbox_prompts = CTkTextbox(self,
width=250,
font=CTkFont(size=16, weight="normal"))
self.textbox_prompts.grid(row=2,
column=1,
padx=(20, 0),
pady=(20, 0),
sticky="nsew")
with open("prompts.txt", 'a+', encoding='utf-8') as f:
contents = f.read().splitlines()
self.textbox_prompts.insert('0.0', contents)
# self.textbox_2 = CTkTextbox(self, width=250)
# self.textbox_2.grid(row=0, column=1, padx=(20, 0), pady=(90, 0), sticky="nsew")
# create tabview
self.tabview = CTkTabview(self, width=250)
self.tabview.grid(row=0, column=2, padx=(
20, 0), pady=(20, 0), sticky="nsew")
self.tabview.add("Main")
self.tabview.add("L&C")
self.tabview.add("Action")
self.tabview.tab("Main").grid_columnconfigure(
0, weight=1) # configure grid of individual tabs
self.tabview.tab("L&C").grid_columnconfigure(0, weight=1)
# option = StringVar(value="Select an option")
# options = ["a", "b", "c"]
self.menu_persona = CTkOptionMenu(self.tabview.tab("Main"), dynamic_resizing=False,
values=["Man", "Woman"])
self.menu_persona.grid(row=0, column=0, padx=20, pady=(20, 10))
self.label_media = CTkLabel(self.tabview.tab(
"Main"), text="Media", anchor="w")
self.label_media.grid(row=1, column=0, padx=20, pady=(10, 0))
self.menu_media = CTkComboBox(self.tabview.tab(
"Main"), values=['one'])
self.menu_media.grid(row=2, column=0, padx=20, pady=(10, 10))
self.label_media = CTkLabel(self.tabview.tab(
"Main"), text="Location", anchor="w")
self.label_media.grid(row=3, column=0, padx=20, pady=(10, 0))
self.menu_location = CTkComboBox(self.tabview.tab(
"Main"), values=['again'])
self.menu_location.grid(row=4, column=0, padx=20, pady=(10, 10))
self.string_input_button_generate = CTkButton(
self.tabview.tab("Main"), text="Generate", command=self.generate_prompt)
self.string_input_button_generate.grid(
row=5, column=0, padx=20, pady=(10, 10))
self.string_input_button = CTkButton(self.tabview.tab(
"Main"), text="Open CTkInputDialog", command=self.open_input_dialog_event)
self.string_input_button.grid(row=6, column=0, padx=20, pady=(10, 10))
self.label_tab_2 = CTkLabel(self.tabview.tab("L&C"), text="CTkLabel on Tab 2")
self.label_tab_2.grid(row=0, column=0, padx=20, pady=20)
# create radiobutton frame
self.radiobutton_frame = CTkFrame(self)
self.radiobutton_frame.grid(row=0, column=3, padx=20, pady=(40, 10),sticky="nsew")
# CHARACTER RADIOS
self.radio_var = tkinter.StringVar(value='')
# self.label_radio_group = CTkLabel(master=self.radiobutton_frame, text="Character Preset")
# self.label_radio_group.grid(row=0, column=2, columnspan=1, padx=10, pady=10, sticky="")
self.scrollable_frame_radios = CTkScrollableFrame(self.radiobutton_frame, label_text="Characters")
self.scrollable_frame_radios.grid(row=1, column=1,sticky="nsew")
# self.scrollable_frame_radios.grid_columnconfigure(0, weight=1)
self.scrollable_frame_radios_switches = []
switches = ['switch','switch2']
for ndx,i in enumerate(switches):
self.radio_button = CTkRadioButton(master=self.scrollable_frame_radios, text=i,variable=self.radio_var, value=i,command=lambda:self.radio_test(self.radio_var.get()))
self.radio_button.grid(row=ndx, column=0, pady=10, padx=20, sticky="nsew")
self.scrollable_frame_radios_switches.append(self.radio_button)
# CHARACTER RADIOS
# OBJECT RADIOS
self.radio_var_2 = tkinter.IntVar(value=0)
self.radios_objects = CTkScrollableFrame(self.radiobutton_frame, label_text="Objects")
self.radios_objects.grid(row=1, column=2,sticky="nsew")
# self.radios_objects.grid_columnconfigure(0, weight=1)
self.radios_objects_switches = []
switches = ['Modern House','Tree','Flower','Tablet','Burger','Bed']
for ndx,i in enumerate(switches):
self.radio_button = CTkRadioButton(master=self.radios_objects, text=i,variable=self.radio_var_2, value=ndx)
self.radio_button.grid(row=ndx, column=0, pady=10, padx=20, sticky="nsew")
self.radios_objects_switches.append(self.radio_button)
# OBJECT RADIOS
# CAR RADIOS
self.radio_var_3 = tkinter.IntVar(value=0)
self.radios_more_characters = CTkScrollableFrame(self.radiobutton_frame, label_text="Cars")
self.radios_more_characters.grid(row=2, column=1,sticky="nsew")
# self.radios_more_characters.grid_columnconfigure(0, weight=1)
self.radios_more_characters_switches = []
switches = ['Mercedes Benz','Honda','Hyundai','Toyota Sedan','Chevrolet Truck']
for ndx,i in enumerate(switches):
self.radio_button = CTkRadioButton(master=self.radios_more_characters, text=i,variable=self.radio_var_3, value=ndx)
self.radio_button.grid(row=ndx, column=0, pady=10, padx=20, sticky="nsew")
self.radios_more_characters_switches.append(self.radio_button)
# CAR RADIOS
# ANIMAL RADIOS
self.radio_var_4 = tkinter.IntVar(value=0)
self.radios_animals = CTkScrollableFrame(self.radiobutton_frame, label_text="Animals")
self.radios_animals.grid(row=2, column=2,sticky="nsew")
# self.radios_animals.grid_columnconfigure(0, weight=1)
self.radios_animals_switches = []
switches = ['Feline','Canine','Amphibians','Insects','Birds','Fish']
for ndx,i in enumerate(switches):
self.radio_button = CTkRadioButton(master=self.radios_animals, text=i,variable=self.radio_var_4, value=ndx)
self.radio_button.grid(row=ndx, column=0, pady=10, padx=20, sticky="nsew")
self.radios_animals_switches.append(self.radio_button)
# ANIMAL RADIOS
self.slider_progressbar_frame = CTkFrame(
self, fg_color="transparent")
self.slider_progressbar_frame.grid(row=1,
column=1,
padx=(20, 0),
pady=(20, 0),
sticky="nsew")
self.slider_progressbar_frame.grid_columnconfigure(0, weight=1)
self.slider_progressbar_frame.grid_rowconfigure(4, weight=1)
self.seg_button_1 = CTkSegmentedButton(self.slider_progressbar_frame)
self.seg_button_1.grid(row=0, column=0, padx=(
20, 10), pady=(10, 10), sticky="ew")
self.progressbar_1 = CTkProgressBar(self.slider_progressbar_frame)
self.progressbar_1.grid(row=1, column=0, padx=(20, 10), pady=(10, 10), sticky="ew")
self.progressbar_2 = CTkProgressBar(self.slider_progressbar_frame)
self.progressbar_2.grid(row=2, column=0, padx=(20, 10), pady=(10, 10), sticky="ew")
self.slider_1 = CTkSlider(self.slider_progressbar_frame, from_=0, to=1, number_of_steps=4)
self.slider_1.grid(row=3, column=0, padx=(20, 10), pady=(10, 10), sticky="ew")
self.slider_2 = CTkSlider(self.slider_progressbar_frame, orientation="vertical")
self.slider_2.grid(row=0, column=1, rowspan=5, padx=(10, 10), pady=(10, 10), sticky="ns")
self.progressbar_3 = CTkProgressBar(
self.slider_progressbar_frame, orientation="vertical")
self.progressbar_3.grid(row=0,
column=2,
rowspan=5,
padx=(10, 20),
pady=(10, 10),
sticky="ns")
# create scrollable frame
self.scrollable_frame = CTkScrollableFrame(
self, label_text="Settings")
self.scrollable_frame.grid(row=1, column=2, padx=(
20, 0), pady=(20, 0), sticky="nsew")
self.scrollable_frame.grid_columnconfigure(0, weight=1)
self.scrollable_frame_switches = []
switches = ['Locations','Architecture','Artists','Animals','Automobiles','Buildings','Nature']
for ndx,i in enumerate(switches):
switch = CTkSwitch(
master=self.scrollable_frame, text=f"{i}")
switch.grid(row=ndx, column=0, padx=10, pady=(0, 20),sticky="nsew")
self.scrollable_frame_switches.append(switch)
# create checkbox and switch frame
self.checkbox_slider_frame = CTkFrame(self)
self.checkbox_slider_frame.grid(row=1, column=3, padx=(20, 20), pady=(20, 0), sticky="nsew")
self.checkbox_1 = CTkCheckBox(
master=self.checkbox_slider_frame, text="Kid Mode")
self.checkbox_1.grid(row=1, column=0, pady=(
20, 0), padx=20, sticky="nsew")
self.checkbox_2 = CTkCheckBox(
master=self.checkbox_slider_frame, text="Expert Mode")
self.checkbox_2.grid(row=2, column=0, pady=(
20, 0), padx=20, sticky="nsew")
self.checkbox_3 = CTkCheckBox(
master=self.checkbox_slider_frame, text="Debug")
self.checkbox_3.grid(row=3,
column=0,
pady=20,
padx=20,
sticky="nsew")
#IMAGE FRAME
self.frame_images = CTkFrame(self)
self.frame_images.grid(row=2,
column=2,
columnspan=2,
padx=(20, 20),
pady=(20, 0),
sticky="nsew")
# self.my_image = CTkImage(light_image=Image.open("./gallery/IMG_4159.png"),
# dark_image=Image.open("./gallery/IMG_4159.png"),
# size=(300, 300))
# self.my_image.place(x=0,y=0)
# button = CTkButton(master=self.frame_images,
# image = self.my_image,
# fg_color='black',
# hover_color='black',
# text="",
# width=500,height=400,
# compound='left')
# button.place(relx=0.5, rely=0.5, anchor=tkinter.CENTER)
#IMAGE FRAME
# set default values
self.button_side_bar_disabled.configure(
state="disabled", text="Disabled")
self.checkbox_3.configure(state="disabled")
self.checkbox_1.select()
self.scrollable_frame_switches[0].select()
self.scrollable_frame_switches[-1].select()
# self.radio_button_3.configure(state="disabled")
self.appearance_mode_optionemenu.set("Dark")
# self.appearance_color_theme_optionemenu.set("green")
self.scaling_optionemenu.set("100%")
self.menu_persona.set("Woman")
self.menu_media.set("Photo")
self.menu_location.set("random")
self.slider_1.configure(command=self.progressbar_2.set)
self.slider_2.configure(command=self.progressbar_3.set)
self.progressbar_1.configure(mode="indeterminnate")
self.progressbar_1.start()
self.textbox.insert(
"0.0", """Welcome to Prompt Genius. Generate a prompt and be amazed!""")
# self.textbox_2.insert("0.0",'asdfasdfasdf')
self.seg_button_1.configure(
values=["Recents", "Current", "All Prompts"])
self.seg_button_1.set("Value 2")
treestyle = ttk.Style()
treestyle.theme_use('default')
# treestyle.configure("Treeview", background=bg_color, foreground=text_color, fieldbackground=bg_color, borderwidth=0)
# treestyle.map('Treeview', background=[('selected', bg_color)], foreground=[('selected', selected_color)])
self.bind("<<TreeviewSelect>>", lambda event: self.focus_set())
##Treeview widget data
treeview = ttk.Treeview(self, height=6, show="tree")
treeview.grid(padx=10)
treeview.insert('', '0', 'i1', text ='Categories')
treeview.insert('', '1', 'i2', text ='Logins')
treeview.insert('', '2', 'i3', text ='Identities')
treeview.insert('i2', 'end', 'Frame', text ='Frame')
treeview.insert('i2', 'end', 'Label', text ='Label')
treeview.insert('i3', 'end', 'Treeview', text ='Treeview')
# treeview.insert('', '3', 'i4', text ='Tags')
treeview.move('i2', 'i1', 'end')
treeview.move('i3', 'i1', 'end')
def open_input_dialog_event(self):
dialog = CTkInputDialog(
text="Type in a number:", title="CTkInputDialog")
print("CTkInputDialog:", dialog.get_input())
def get_checked_items(self):
return [checkbox.cget("text") for checkbox in self.scrollable_frame_radios_switches if checkbox.cget('value') == 1]
def change_appearance_mode_event(self, new_appearance_mode: str):
customtkinter.set_appearance_mode(new_appearance_mode)
def change_theme_mode_event(self, new_theme_mode: str):
customtkinter.set_default_color_theme(new_theme_mode)
def change_scaling_event(self, new_scaling: str):
new_scaling_float = int(new_scaling.replace("%", "")) / 100
customtkinter.set_widget_scaling(new_scaling_float)
def sidebar_button_event(self):
print("Created new chat..")
def generate_prompt(self, info='Welcme'):
print("Generated prompt")
self.textbox.delete(1.0, "end")
self.textbox.insert("end", 'Generated')
def clear_prompts(self, info='Welcme'):
print("Celared prompt")
self.textbox.delete(1.0, "end")
if __name__ == "__main__":
app = App()
app.mainloop()