Saturday, May 4, 2024

Tkinter Library Program

 


import tkinter as tk

  1. Simple Program with Button Command:

def button_click():

    label.config(text="Button Clicked!")


root = tk.Tk()

root.title("Button Example")


label = tk.Label(root, text="Click the button")

label.pack()


button = tk.Button(root, text="Click Me", command=button_click)

button.pack()


root.mainloop()

Output:




No comments:

Post a Comment

Input Text and Display in tkinter

  import tkinter as tk def display_text():     text = entry.get()     label.config(text="You entered: " + text) root = tk.Tk() roo...