Skip to content

Commit

Permalink
Added 1.0.0 project
Browse files Browse the repository at this point in the history
  • Loading branch information
lapisangularis committed May 30, 2020
1 parent 457915a commit f87303f
Show file tree
Hide file tree
Showing 25 changed files with 701 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -127,3 +127,6 @@ dmypy.json

# Pyre type checker
.pyre/

.DS_Store
target/
46 changes: 46 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# Physical Units Converter
5 minute test project by lapisangularis

## Installation
#### Requirements
Application works fine on the newest Windows, MacOSX and linux distributions.

#### Installation & Running
Double click on the executable.

## Usage
Write your value in the first field. Pick your conversion method from available buttons. Click the reset button for the default value and conversion (1kg to lb). Converted value will appear in the second field.
## Development

#### Requirements

- `python 3.7.3`
- `pip 20.1.1`

#### Setting up project

If you meet the `Requirements`, you can develop this codebase, just need to setup the environment.

Instructions to do in commandline or terminal:

1. Go to main folder of the project
- Windows `cd c:\path\to\project`
- MacOSX and Linux `cd /path/to/project`
2. Create new virtualenv
- `python3 -m venv venv`
3. Activate virtualenv
- Windows `call venv/scripts/activate.bat`
- MacOSX and Linux `source venv/bin/activate`
4. Install packages with `pip`
- `pip install -r requirements.txt `

For running the app, type:
- `fbs run`

#### Executable, compilation

For creating executable, after `Setting up project` part, you just need to type.

- `fbs freeze`

In project folder there will be `target` folder with executable inside. (`.exe` for Windows, `.app` for MacOSX, binary for Linux)
68 changes: 68 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
altgraph==0.17
appnope==0.1.0
attrs==19.3.0
backcall==0.1.0
bleach==3.1.5
cycler==0.10.0
decorator==4.4.2
defusedxml==0.6.0
entrypoints==0.3
fbs==0.8.6
future==0.18.2
importlib-metadata==1.6.0
ipykernel==5.3.0
ipython==7.14.0
ipython-genutils==0.2.0
ipywidgets==7.5.1
jedi==0.17.0
Jinja2==2.11.2
jsonschema==3.2.0
jupyter==1.0.0
jupyter-client==6.1.3
jupyter-console==6.1.0
jupyter-core==4.6.3
kiwisolver==1.2.0
macholib==1.14
MarkupSafe==1.1.1
matplotlib==3.2.1
mistune==0.8.4
mpmath==1.1.0
nbconvert==5.6.1
nbformat==5.0.6
nose==1.3.7
notebook==6.0.3
numpy==1.18.4
packaging==20.4
pandas==1.0.4
pandocfilters==1.4.2
parso==0.7.0
pefile==2019.4.18
pexpect==4.8.0
pickleshare==0.7.5
prometheus-client==0.8.0
prompt-toolkit==3.0.5
ptyprocess==0.6.0
Pygments==2.6.1
PyInstaller==3.4
pyparsing==2.4.7
PyQt5==5.9.2
PyQt5-stubs==5.14.2.2
pyrsistent==0.16.0
python-dateutil==2.8.1
pytz==2020.1
pyzmq==19.0.1
qtconsole==4.7.4
QtPy==1.9.0
scipy==1.4.1
Send2Trash==1.5.0
sip==4.19.8
six==1.15.0
sympy==1.6
terminado==0.8.3
testpath==0.4.4
tornado==6.0.4
traitlets==4.3.3
wcwidth==0.1.9
webencodings==0.5.1
widgetsnbextension==3.5.1
zipp==3.1.0
6 changes: 6 additions & 0 deletions src/build/settings/base.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"app_name": "physical-units-converter",
"author": "lapisangularis",
"main_module": "src/main/python/__main__.py",
"version": "1.0.0"
}
6 changes: 6 additions & 0 deletions src/build/settings/linux.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"categories": "Utility;",
"description": "Physical Units Converter",
"author_email": "[email protected]",
"url": ""
}
3 changes: 3 additions & 0 deletions src/build/settings/mac.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"mac_bundle_identifier": "com.lapisangularis.physical-units-converter"
}
Binary file added src/main/icons/Icon.ico
Binary file not shown.
Binary file added src/main/icons/base/16.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/main/icons/base/24.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/main/icons/base/32.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/main/icons/base/48.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/main/icons/base/64.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/main/icons/linux/1024.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/main/icons/linux/128.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/main/icons/linux/256.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/main/icons/linux/512.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/main/icons/mac/1024.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/main/icons/mac/128.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/main/icons/mac/256.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/main/icons/mac/512.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
26 changes: 26 additions & 0 deletions src/main/python/__main__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import sys
from fbs_runtime.application_context.PyQt5 import ApplicationContext
from models.conversion import Conversion
from views.converter_view import ConverterView
from controllers.converter_controller import ConverterController


class AppContext(ApplicationContext):
def _setup_converter(self):
self.conversion_model = Conversion()
self.converter_controller = ConverterController(self.conversion_model)
self.converter_view = ConverterView(self.conversion_model, self.converter_controller)

def __init__(self):
super(AppContext, self).__init__()
self._setup_converter()

def run(self):
self.converter_view.show()
return self.app.exec_()


if __name__ == '__main__':
app_context = AppContext()
exit_code = app_context.run()
sys.exit(exit_code)
130 changes: 130 additions & 0 deletions src/main/python/controllers/converter_controller.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,130 @@
from PyQt5.QtCore import QObject, pyqtSlot


class ConverterController(QObject):
def __init__(self, model):
super().__init__()
self._model = model

def _calculate_reset_state(self, value):
self._model.enable_reset = True if value else False

@pyqtSlot(int)
def calculate_kilograms_to_pounds(self, value):
self._model.input_value = float(value)
self._model.kilograms_to_pounds()
self._calculate_reset_state(value)

@pyqtSlot(int)
def calculate_pounds_to_kilograms(self, value):
self._model.input_value = float(value)
self._model.pounds_to_kilograms()
self._calculate_reset_state(value)

@pyqtSlot(int)
def calculate_grams_to_pounds(self, value):
self._model.input_value = float(value)
self._model.grams_to_pounds()
self._calculate_reset_state(value)

@pyqtSlot(int)
def calculate_pounds_to_grams(self, value):
self._model.input_value = float(value)
self._model.pounds_to_grams()
self._calculate_reset_state(value)

@pyqtSlot(int)
def calculate_kilograms_to_ounces(self, value):
self._model.input_value = float(value)
self._model.kilograms_to_ounces()
self._calculate_reset_state(value)

@pyqtSlot(int)
def calculate_ounces_to_kilograms(self, value):
self._model.input_value = float(value)
self._model.ounces_to_kilograms()
self._calculate_reset_state(value)

@pyqtSlot(int)
def calculate_grams_to_ounces(self, value):
self._model.input_value = float(value)
self._model.grams_to_ounces()
self._calculate_reset_state(value)

@pyqtSlot(int)
def calculate_ounces_to_grams(self, value):
self._model.input_value = float(value)
self._model.ounces_to_grams()
self._calculate_reset_state(value)

@pyqtSlot(int)
def calculate_meters_to_inches(self, value):
self._model.input_value = float(value)
self._model.meters_to_inches()
self._calculate_reset_state(value)

@pyqtSlot(int)
def calculate_inches_to_meters(self, value):
self._model.input_value = float(value)
self._model.inches_to_meters()
self._calculate_reset_state(value)

@pyqtSlot(int)
def calculate_meters_to_feet(self, value):
self._model.input_value = float(value)
self._model.meters_to_feet()
self._calculate_reset_state(value)

@pyqtSlot(int)
def calculate_feet_to_meters(self, value):
self._model.input_value = float(value)
self._model.feet_to_meters()
self._calculate_reset_state(value)

@pyqtSlot(int)
def calculate_meters_to_yards(self, value):
self._model.input_value = float(value)
self._model.meters_to_yards()
self._calculate_reset_state(value)

@pyqtSlot(int)
def calculate_yards_to_meters(self, value):
self._model.input_value = float(value)
self._model.yards_to_meters()
self._calculate_reset_state(value)

@pyqtSlot(int)
def calculate_meters_to_miles(self, value):
self._model.input_value = float(value)
self._model.meters_to_miles()
self._calculate_reset_state(value)

@pyqtSlot(int)
def calculate_miles_to_meters(self, value):
self._model.input_value = float(value)
self._model.miles_to_meters()
self._calculate_reset_state(value)

@pyqtSlot(int)
def calculate_joules_to_ev(self, value):
self._model.input_value = float(value)
self._model.joules_to_ev()
self._calculate_reset_state(value)

@pyqtSlot(int)
def calculate_ev_to_joules(self, value):
self._model.input_value = float(value)
self._model.ev_to_joules()
self._calculate_reset_state(value)

@pyqtSlot(int)
def calculate_joules_to_calories(self, value):
self._model.input_value = float(value)
self._model.joules_to_calories()
self._calculate_reset_state(value)

@pyqtSlot(int)
def calculate_calories_to_joules(self, value):
self._model.input_value = float(value)
self._model.calories_to_joules()
self._calculate_reset_state(value)
Loading

0 comments on commit f87303f

Please sign in to comment.