Skip to content

Latest commit

 

History

History

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 

README.md

Weight Converter GUI

Description

A user-friendly weight converter with a graphical interface that supports conversion between 9 different weight units including metric and imperial systems.

Features

  • Convert between 9 weight units
  • Real-time conversion as you type
  • Swap units with one click
  • Clear and intuitive interface
  • High precision results (6 decimal places)
  • Input validation
  • Modern, colorful design

Stack

  • Language: Pure Python
  • Libraries: tkinter (standard library)
  • Complexity: Beginner

Installation & Usage

No external dependencies required!

python main.py

Supported Units

Metric System

  • Milligrams (mg) - 1/1000 of a gram
  • Grams (g) - Base metric unit
  • Kilograms (kg) - 1000 grams
  • Metric Tons (t) - 1000 kilograms

Imperial/US System

  • Ounces (oz) - 1/16 of a pound
  • Pounds (lb) - Standard US/UK weight
  • Stones (st) - 14 pounds (UK)
  • US Tons - 2000 pounds
  • UK Tons - 2240 pounds

How to Use

  1. Enter Value: Type the weight value you want to convert
  2. Select From Unit: Choose the source unit from dropdown
  3. Select To Unit: Choose the target unit from dropdown
  4. View Result: Conversion happens automatically!

Quick Actions

  • 🔄 Convert: Manual conversion trigger
  • ⇄ Swap: Swap from/to units instantly
  • 🗑️ Clear: Clear all fields

Conversion Examples

1 kg = 1000 g
1 lb = 16 oz
1 kg ≈ 2.20462 lb
1 stone = 14 lb
1 metric ton = 1000 kg

Features Explained

Real-time Conversion

  • Converts automatically as you type
  • No need to click convert button
  • Instant feedback

Swap Functionality

  • Quickly reverse conversion direction
  • Maintains entered value
  • One-click operation

High Precision

  • Results shown to 6 decimal places
  • Accurate conversion factors
  • Suitable for scientific use

Learning Outcomes

  • Tkinter GUI development
  • Combobox (dropdown) widgets
  • Event binding
  • Unit conversion logic
  • Dictionary data structures
  • Input validation
  • State management

Conversion Formula

All conversions use grams as the base unit:

# Step 1: Convert input to grams
grams = input_value * conversion_factor_from

# Step 2: Convert grams to output unit
output_value = grams / conversion_factor_to

Common Conversions

From To Multiply by
kg lb 2.20462
lb kg 0.453592
oz g 28.3495
g oz 0.035274
stone kg 6.35029

Future Enhancements

  • Add more units (carats, grains, etc.)
  • Conversion history
  • Favorite conversions
  • Copy result to clipboard
  • Keyboard shortcuts
  • Dark mode theme
  • Export conversion table
  • Scientific notation support

Tips

  • Use Tab key to navigate between fields
  • Decimal values are supported
  • Very large/small numbers handled accurately
  • Swap button useful for reverse calculations

License

Open source for educational purposes.