Monday, January 29, 2024

Tkinter Library Functions in Python

 Tkinter Library Functions in Python

Function/ClassDescriptionExample Usage
Tk()Creates a main windowroot = tkinter.Tk()
Label(master, options)Creates a text labellabel = tkinter.Label(root, text="Hello")
Button(master, options)Creates a buttonbutton = tkinter.Button(root, text="Click")
Entry(master, options)Creates a single-line text entryentry = tkinter.Entry(root)
Text(master, options)Creates a multi-line text areatext = tkinter.Text(root)
Frame(master, options)Creates a container for other widgetsframe = tkinter.Frame(root)
Canvas(master, options)Creates a drawing areacanvas = tkinter.Canvas(root)
Menu(master, options)Creates a menumenu = tkinter.Menu(root)
Scrollbar(master, options)Creates a scrollbarscrollbar = tkinter.Scrollbar(root)
Listbox(master, options)Creates a listbox widgetlistbox = tkinter.Listbox(root)
Checkbutton(master, options)Creates a checkbuttoncheckbutton = tkinter.Checkbutton(root, text="Check")
Radiobutton(master, options)Creates a radiobuttonradiobutton = tkinter.Radiobutton(root, text="Radio")
Scale(master, options)Creates a scale (slider) widgetscale = tkinter.Scale(root)
Spinbox(master, options)Creates a spinbox widgetspinbox = tkinter.Spinbox(root)
Toplevel(master, options)Creates a new top-level windowtop = tkinter.Toplevel(root)
PanedWindow(master, options)Creates a container for panespaned_window = tkinter.PanedWindow(root)
PhotoImage(file='path')Creates an image from a fileimage = tkinter.PhotoImage(file='image.png')
pack(options)Packs a widget into its parentbutton.pack()
grid(options)Places a widget in a gridlabel.grid(row=0, column=0)
place(options)Places a widget at specific coordinatesentry.place(x=10, y=10)
bind(event, function)Binds an event to a functionbutton.bind('<Button-1>', callback)
mainloop()Enters the Tk event looproot.mainloop()

These are just a few examples of functions and classes available in the tkinter library for building graphical user interfaces (GUIs) in Python. You can explore more options and details in the Python documentation or by using the help(tkinter) function in the Python interpreter.

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...