Jun-30-2017, 06:57 PM
toggleButton1
only exists in the MainFloor class. You're trying to change it from within the Fireplace class. A nice way to handle this would be using events or signals (something frequently done in game programming, and is how something like the physics code will do most of it's communication). But that'd be a whole lot of changes.You currently pass each object a controller object, but the Fireplace doesn't keep track of it. If you do, then you can crawl into the controller and manipulate it's frames to get to the MainFloor to do what you're trying to do. So, Fireplace would then look like this:
class Fireplace(): def __init__(self, controller): self.controller = controller main_floor = self.controller.frames["MainFloor"] if (bus1.read_pin(15) == 1): bus1.write_pin(15, 0) main_floor.toggleButton1["text"] = ("Fireplace On") else: bus1.write_pin(15, 1) main_floor.toggleButton1["text"] = ("Fireplace Off")