Skip to main content

Python unit converter with a Tkinter interface for easy and precise conversions across various measurements such as force, length, and mass

Project description

Metricus

made-with-python PyPi license Open Source? Yes!

Getting StartedCollaboratorsContributeLicensePreview

This Python-based unit converter is a simple and efficient tool for converting measurements between various units, such as force, length, mass, and others, including complex operations like displacement. It features an intuitive graphical user interface built with Tkinter, allowing users to navigate and perform conversions easily. The converter returns precise results, formatted with or without the unit abbreviation for easy readability.

🚀 Getting started

pip install metricus

Usage Example

from Metricus.gui import MetricusGUI
from Metricus import temperature_converter
from Metricus.utilities import round_number, humanize_input, decomputarize_input, plot_temperature_variation

# ----------------------------
# Temperature Conversion Example
# ----------------------------
temp_celsius = 25
temp_rankine = temperature_converter(temp_celsius, 'celsius', 'rankine')
print(f"{temp_celsius} degrees Celsius equals {temp_rankine} Rankine")

# ----------------------------
# Time Conversion Examples
# ----------------------------

# Example 1: Basic usage
time_seconds = 3600
time_hours = time_converter(time_seconds, 'second', 'hour')
print(f"{time_seconds} seconds equals {time_hours} hours")

# Example 2: Using rounded_result
time_days = 365
time_year = time_converter(time_days, 'day', 'year', rounded_result=True)
print(f"{time_days} days equals {time_year} year")

# Example 3: Using humanized_input
time_years = 100
time_century = time_converter(time_years, 'year', 'century', humanized_input=True)
print(f"{time_years} years equals {time_century} century")

# ----------------------------
# Displacement Calculation Example
# ----------------------------
length_kilometers = 100
speed_kmh = 100
time_unit = 'minute'
result = calculate_displacement(length=length_kilometers, speed=speed_kmh, time_unit=time_unit)
print(f"Covering {length_kilometers} km at a speed of {speed_kmh} km/h takes {result} minutes.")

# ----------------------------
# Number Rounding Example
# ----------------------------
# Rounding a numeric result
time_days = 365
time_result = time_converter(time_days, 'day', 'year')
rounded_number = round_number(time_result)
print(f"The number {time_result} rounded is {rounded_number}")

# Rounding a string result
time_result_with_unit = time_converter(time_days, 'day', 'year', with_unit=True)
rounded_number_with_unit = round_number(time_result_with_unit)
print(f"The number {time_result_with_unit} rounded is {rounded_number_with_unit}")

# ----------------------------
# Humanizing and Decomputadorizing Input
# ----------------------------
from_acceleration = 'Meter per second squared'
to_acceleration = 'Foot per second squared'

# Humanizing input
acceleration_result = acceleration_converter(
    100,
    humanize_input(from_acceleration),
    humanize_input(to_acceleration)
)
print(f"The conversion result from {from_acceleration} to {to_acceleration} is {acceleration_result}")

# Decomputadorizing input
decomputarized_from = decomputarize_input(humanize_input(from_acceleration))
decomputarized_to = decomputarize_input(humanize_input(to_acceleration))
print(f"The decomputarized input from '{humanize_input(from_acceleration)}' is '{decomputarized_from}'")
print(f"The decomputarized input to '{humanize_input(to_acceleration)}' is '{decomputarized_to}'")

# ----------------------------
# Temperature Variation Plotting Examples
# ----------------------------
# Daily temperatures for 30 days (based on the provided list)
temperatures = [
    15.3, 16.1, 14.8, 13.5, 12.4, 11.8, 13.0, 15.5, 16.2, 14.9,
    13.0, 12.5, 11.6, 13.4, 15.1, 11.0, 17.2, 18.5, 19.0, 18.3,
    17.8, 16.4, 15.0, 14.2, 13.6, 12.7, 13.8, 14.5, 15.2, 16.0
]

# Example 1: Basic usage - Plot in Celsius with statistical info
plot_temperature_variation(
    temperatures=temperatures,
    temperature_unit='celsius'
)

# Example 2: Convert temperatures to Fahrenheit
plot_temperature_variation(
    temperatures=temperatures,
    temperature_unit='celsius',
    convert_to='fahrenheit'
)

# Example 3: Disable statistical information
plot_temperature_variation(
    temperatures=temperatures,
    temperature_unit='celsius',
    convert_to='fahrenheit',
    with_info=False
)

# Example 4: Save the graph to a file
plot_temperature_variation(
    temperatures=temperatures,
    temperature_unit='celsius',
    convert_to='fahrenheit',
    save_path='temperature_variation.png'
)

# Example 5: Save graph in Kelvin with statistics
plot_temperature_variation(
    temperatures=temperatures,
    temperature_unit='celsius',
    convert_to='kelvin',
    save_path='temperature_variation_kelvin.pdf',
    with_info=True
)

# ----------------------------
# Launching the Graphical Interface
# ----------------------------
MetricusGUI()

🌟 Preview

Below is a preview of the Metricus graphical user interface (GUI):

Simple Conversions:

Metricus GUI

Complex Conversions:

Metricus GUI

The GUI is built with Tkinter and provides an intuitive way to perform unit conversions quickly and accurately.

Prerequisites

  • Python 3.8+
  • Matplotlib

Cloning

git clone https://github.com/guifreschi/Metricus

Starting

Clone the repository git clone https://github.com/guifreschi/Metricus

Navigate into the project directory cd Metricus

Create a virtual environment python -m venv venv

Activate the virtual environment

  • On Windows venv\Scripts\activate
  • On Unix or MacOS source venv/bin/activate

Install Metricus pip install -e .

🤝 Collaborators

This project is maintained and created by:

Guilherme Freschi Profile Picture
Guilherme Freschi
Yaron Buchler Profile Picture
Yaron Buchler

📫 Contribute

  1. git clone https://github.com/guifreschi/Metricus
  2. git checkout -b feature/NAME
  3. Follow commit patterns
  4. Open a Pull Request explaining the problem solved or feature made, if exists, append screenshot of visual modifications and wait for the review!

Documentations that might help

📝 How to create a Pull Request

💾 Commit pattern

📝 License

This project is licensed under the MIT License. See the LICENSE file for details.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

metricus-1.0.3.tar.gz (49.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

metricus-1.0.3-py3-none-any.whl (110.3 kB view details)

Uploaded Python 3

File details

Details for the file metricus-1.0.3.tar.gz.

File metadata

  • Download URL: metricus-1.0.3.tar.gz
  • Upload date:
  • Size: 49.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.12.4

File hashes

Hashes for metricus-1.0.3.tar.gz
Algorithm Hash digest
SHA256 a78fec6038244ef3965c3f36e4b8dcdd6e1e4629c1306f000abeb6c7b1db45c8
MD5 23dd8f7a21e66bcd7c00cbd62d9c611b
BLAKE2b-256 3d88dbe5a979eb904bf6fe8afaa7452b03e0c81c12adc2f53ac7d4d6cae42990

See more details on using hashes here.

File details

Details for the file metricus-1.0.3-py3-none-any.whl.

File metadata

  • Download URL: metricus-1.0.3-py3-none-any.whl
  • Upload date:
  • Size: 110.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.12.4

File hashes

Hashes for metricus-1.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 f50820feceba6384ddf4c330633048bf2a63245c0a29ee7f38e02d8fb4c2be1c
MD5 ffb2c8211db1cc7bf696e4525261ca28
BLAKE2b-256 08a7fc5f89b4f8d2332eb83999a5d69f2a7a52e380ff28dc4f9dfa65f5deb4e8

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page