Tkinter Library Functions in Python
| Function/Class | Description | Example Usage |
|---|---|---|
Tk() | Creates a main window | root = tkinter.Tk() |
Label(master, options) | Creates a text label | label = tkinter.Label(root, text="Hello") |
Button(master, options) | Creates a button | button = tkinter.Button(root, text="Click") |
Entry(master, options) | Creates a single-line text entry | entry = tkinter.Entry(root) |
Text(master, options) | Creates a multi-line text area | text = tkinter.Text(root) |
Frame(master, options) | Creates a container for other widgets | frame = tkinter.Frame(root) |
Canvas(master, options) | Creates a drawing area | canvas = tkinter.Canvas(root) |
Menu(master, options) | Creates a menu | menu = tkinter.Menu(root) |
Scrollbar(master, options) | Creates a scrollbar | scrollbar = tkinter.Scrollbar(root) |
Listbox(master, options) | Creates a listbox widget | listbox = tkinter.Listbox(root) |
Checkbutton(master, options) | Creates a checkbutton | checkbutton = tkinter.Checkbutton(root, text="Check") |
Radiobutton(master, options) | Creates a radiobutton | radiobutton = tkinter.Radiobutton(root, text="Radio") |
Scale(master, options) | Creates a scale (slider) widget | scale = tkinter.Scale(root) |
Spinbox(master, options) | Creates a spinbox widget | spinbox = tkinter.Spinbox(root) |
Toplevel(master, options) | Creates a new top-level window | top = tkinter.Toplevel(root) |
PanedWindow(master, options) | Creates a container for panes | paned_window = tkinter.PanedWindow(root) |
PhotoImage(file='path') | Creates an image from a file | image = tkinter.PhotoImage(file='image.png') |
pack(options) | Packs a widget into its parent | button.pack() |
grid(options) | Places a widget in a grid | label.grid(row=0, column=0) |
place(options) | Places a widget at specific coordinates | entry.place(x=10, y=10) |
bind(event, function) | Binds an event to a function | button.bind('<Button-1>', callback) |
mainloop() | Enters the Tk event loop | root.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