Python GUI Tkinter




 Ø Introduction

  1. Tkinter is Python’s built-in GUI library
  2. It is used to create desktop applications
  3. It works on Windows, Linux, and macOS

Ø 2. Importing Tkinter

  1. Tkinter is imported using import tkinter as tk
  2. No external installation is required
  3. Tkinter comes with standard Python

Ø Main Window

  1. The main window is created using tk.Tk()
  2. It is usually stored in a variable named root
  3. All widgets are placed inside this window

Ø Window Properties

  1. The window title is set using root.title()
  2. Window size is set using root.geometry()
  3. Geometry uses width × height format

Ø Widgets

  1. Widgets are GUI components
  2. The label widget displays text
  3. The button widget performs actions

Ø User Input

  1. The entry widget is used for input
  2. User data is read using. get()
  3. Entry widgets are common in forms

Ø Layout Management

  1. Widgets must be placed on the window
  2. .pack() is the simplest layout method
  3. .grid() arranges widgets in rows and columns

Ø Styling

  1. Colors are set using fg and bg
  2. Fonts are defined using tuples
  3. Padding adds spacing around widgets

Ø Event Handling

  1. Button actions are linked with functions
  2. Events respond to user interaction
  3. command= is used for button events

Ø Main Loop

  1. GUI runs using an event loop
  2. The loop starts with root.mainloop()
  3. Without it, the window closes immediately

 

Comments

Popular posts from this blog

Python Programming Complete Path

Artificial Intelligence using Python

Python Programming Using Digital Marketing