pythonenaml

What purpose does passing Atom do when creating a python class for use with enaml?


I'm trying to code my first GUI with Enaml and I can't figure out the reference to Atom when they're creating a class. I know it's an IDE (I'm using PyCharm) but I'm not sure if that's what it's even referencing. I can't find seem to find any helpful documentation online. Can you explain it to me in this example code from their documentation? I've formatted it below:

class Person(Atom):
    """ A simple class representing a person object.

    """
    last_name = Unicode()

    first_name = Unicode()

    age = Range(low=0)

    debug = Bool(False)

    @observe('age')
    def debug_print(self, change):
        """ Prints out a debug message whenever the person's age changes.

        """
        if self.debug:
            templ = "{first} {last} is {age} years old."
            s = templ.format(
                first=self.first_name, last=self.last_name, age=self.age,
            )
            print(s)

I thought I should mention this isn't the entire file provided in the linked documentation!

edit: I missed some helpful stuff on their github where I found more, albeit still lacking, documentation.


Solution

  • atom is a library (not the popular editor) on top of which enaml is built. It basically provides low-memory footprint Python object and implements the observer pattern which allows to get notified when the value of an attribute change. When installing enaml pip should pull atom automatically. Atom currently lacks documentation but the basics are covered in the examples (https://github.com/nucleic/atom).

    Best

    Matthieu