Tkinter
- Definition: Tkinter is Python’s standard GUI (Graphical User Interface) library. It provides tools to create windows, dialogs, buttons, and other GUI elements.
- Creating a Simple GUI:
- Importing Tkinter: python
import tkinter as tk root = tk.Tk() root.title("Simple GUI") root.geometry("300x200") label = tk.Label(root, text="Hello, Tkinter!") label.pack() button = tk.Button(root, text="Click Me", command=lambda: print("Button Clicked")) button.pack() root.mainloop() - Explanation: The
tk.Tk()function creates the main window. TheLabelwidget displays text, and theButtonwidget creates a clickable button. Thepack()method arranges the widgets in the window. Themainloop()method starts the GUI event loop, waiting for user interactions.
- Importing Tkinter: python