# CurrencyConvBinding

- `Download example`

A PyObjC Example without documentation

## Sources

### Converter.py

    import objc
    from Foundation import NSObject
    from objc import super

    class Converter(NSObject):
        exchangeRate = objc.ivar.double()
        dollarsToConvert = objc.ivar.double()

        def init(self):
            self = super(Converter, self).init()
            self.exchangeRate = 3
            self.dollarsToConvert = 4
            return self

        def amountInOtherCurrency(self):
            return self.dollarsToConvert * self.exchangeRate

    Converter.setKeys_triggerChangeNotificationsForDependentKey_(
        ["dollarsToConvert", "exchangeRate"], "amountInOtherCurrency"
    )

### CurrencyConvBinding.py

    # import classes required to start application
    import Converter  # noqa: F401
    import CurrencyConvBindingDocument  # noqa: F401
    from PyObjCTools import AppHelper

    if __name__ == "__main__":
        AppHelper.runEventLoop()

### CurrencyConvBindingDocument.py

    from Cocoa import NSDocument

    class CurrencyConvBindingDocument(NSDocument):
        def windowNibName(self):
            return "CurrencyConvBindingDocument"

### setup.py

    """
    Script for building the example:

    Usage:
        python3 setup.py py2app
    """
    from setuptools import setup

    plist = {
        "CFBundleDocumentTypes": [
            {
                "CFBundleTypeExtensions": ["CurrencyConvBinding", "*"],
                "CFBundleTypeName": "CurrencyConvBinding File",
                "CFBundleTypeRole": "Editor",
                "NSDocumentClass": "CurrencyConvBindingDocument",
            }
        ]
    }

    setup(
        name="CurrencyConvBinding",
        app=["CurrencyConvBinding.py"],
        data_files=["English.lproj"],
        options={"py2app": {"plist": plist}},
        setup_requires=["py2app", "pyobjc-framework-Cocoa"],
    )