我正在创建两个类,一个类需要保存另一个类的实例。但是我无法弄清楚如何正确初始化它。
class Buttons:
def __init__(self, number, scene):
self.DICT = {}
self.number = number
self.DICT[number] = scene
def add_btn(self, number, scene):
self.DICT[number] = scene
class Switches:
enclosure_name = ""
gatewate_name = ""
enclosure_id = 0
switch_name = ""
switch_location = ""
switch_device_id = 0
switch_mac = 0
switch_termination = 0
switch_group = 0
Buttons buttons = Buttons()
我计划创建许多开关,每个开关有 2 到 6 个按钮。每个按钮都有一个数字和一个动作。如何将 Buttons 变量放入开关中?
呼唤远方
相关分类