kxgames / glooey

An object-oriented GUI library for pyglet.
MIT License
91 stars 6 forks source link

Parameters for Frames' Decoration class #23

Closed UplinkPhobia closed 5 years ago

UplinkPhobia commented 5 years ago

I'd like to create a Frame using a custom Background that uses a variable parameter.

The thing I'd logically want to do is something like

class MyFrame(glooey.Frame):
    def __init__(self):
        super().__init__()
        self.decoration_layer = MyBackground("variable parameter")

Would there be an easy way to do this that I don't know? I'd like to do it properly, but I don't see any clean way to.

kalekundert commented 5 years ago

That's a good comment; I don't think there was an easy way to do that. I just added a decoration setter to Frame that should do what you want, though. If you pull the latest commit, the following should work:

class MyFrame(glooey.Frame):
    def __init__(self):
        super().__init__()
        self.decoration = MyBackground("variable parameter")

Let me know if anything doesn't work. Obviously I just wrote this code, so it's definitely possible that I made some mistake.

UplinkPhobia commented 5 years ago

Thanks for the very quick fix, it seems to be working nicely :)