The @Gtk.Template decorator loops through the class’ attributes and checks whether they’re of instance CallThing (this is how @Gtk.Template.Callback works) or Child. It doesn’t loop through iterable attributes.
Here I define them at class level and only put them in an array afterwards. My guess is that loop a not been run here already. If I move the array creation into _init_, it works.
(Why, oh why, do cash registers need so many buttons… )
Well, that is how attributes work in Python in general. If you do:
class MyClass:
foo = 42
def __init__(self):
self.bar = 35
Then foo is a class attribute MyClass.foo (which is also accessible on instances of the class), and bar is in instance attribute. Each instance of the class has its own bar, independently of others, whereas there is a single foo on the class (which is accessible through any instance).
Now, Gtk.Template.Child is a magic thing that you use to define an attribute on the class, and it results in your instances having the resulting object (typically widget) as an instance attribute of the same name. So it shadows the class attribute – when you write self.plu_1_0_0, you access the instance attribute, of type Gtk.Button, but if you write MyClass.plu_1_0_0 you will still see the class attribute, of type Gtk.Template.Child. If you want to do something with those instance attributes (or any other instance attributes), you should do that in __init__ – before that, there isn’t even an instance to speak of.