Jun-30-2017, 08:10 PM
(Jun-30-2017, 06:49 PM)nilamo Wrote:(Jun-30-2017, 06:07 PM)Barrowman Wrote: I haven't been using classes myself but looking at this and other ( working ) examples of code I think you need a change:
[snip]
to this:
class Fireplace@ def __init__(self): if (bus1.read_pin(15) == 1): bus1.write_pin(15, 0) Mainfloor.toggleButton1["text"] = ("Fireplace On") else:Mainfloor bus1.write_pin(15, 1) Mainfloor.toggleButton1["text"] = ("Fireplace Off")Of course I may be wrong as I usually am
Quote:Theclass Fireplace@class
keyword starts a definition block, and like all other block structures (def, if, for), it uses a colon at the end of the line, not an @.
Quote:The Mainfloor class, itself, does not have a toggleButton1, but it's instances do. So that would throw an error as you're trying to modify something that doesn't exist.Mainfloor.toggleButton1["text"] = ("Fireplace On")
Nice try, though :)
I have no idea where the @ came from! I copied his code and then pasted his code as was and then again but modified it. I hadn't noticed that somehow the : had changed to @
Ah well I said I'm usually wrong.