def __init__(self, view: Window, model: MainModel): Observer.__init__(self) self.model = model self.view = view self.view.attach(self) self.model.attach(self)
def __init__(self): """ constructor for neighborhood inititates observer and calls house grid generation method """ Observer.__init__(self) self.makeHouseGrid()
def __init__(self, model): tk.Tk.__init__(self) Subject.__init__(self) # VIEW OBSERVES THE MODEL FOR STATE CHANGES Observer.__init__(self) self.model = model self.model.attach(self) for x in self.model.layout_algos: print(x, self.model.layout_algos[x]) for x in self.model.algos: print(x, self.model.algos[x]) self.info_menu = None self.geometry("1920x1080") # Init. canvas self.tabs = {} self.nb = ttk.Notebook(self, name="nb") self.index = 0 self.nb.grid(column=0, row=0, sticky=tk.N) self.bind("<Control-t>", self.open_new_graph) self.bind("<Control-w>", self.delete_tab) self.bind("<Control-s>", self.do_algo) self.bind("<Control-r>", self.zoom_out) self.bind("<Control-f>", self.zoom_in)
def __init__(self): # Create Home as an Observer object Observer.__init__(self) # Create Home as an Observable object Observable.__init__(self) # Monsters/NPCs within the house self.monsters = [] # Populates the homes with random monsters for i in range(randint(0, 10)): randNum = randint(1, 5) if (randNum == 1): currMonster = Persons() elif (randNum == 2): currMonster = Zombies() elif (randNum == 3): currMonster = Ghouls() elif (randNum == 4): currMonster = Vampires() elif (randNum == 5): currMonster = Werewolves() # Has house observe each monster currMonster.add_observer(self) self.monsters.append(currMonster)
def __init__(self, model, view): """Inits the class with the view and model.""" Observer.__init__(self, view) self.model = model self.view = view self.update()
def __init__(self, parent, bg="white", width=600, height=300): Observer.__init__(self) self.canvas = tk.Canvas(parent, bg=bg, width=width, height=height) self.a, self.f, self.p = 10.0, 2.0, 0.0 self.signal = [] self.width, self.height = width, height self.units = 1 self.canvas.bind("<Configure>", self.resize)
def __init__(self, parent, width=600, height=600, from_=1, to=10): Observer.__init__(self) self.frame = tk.LabelFrame(parent, text="Generator ", borderwidth=5, padx=20, pady=20) # self.menu = Menubar(parent) self.notes = [ "C", "C#", "D", "D#", "E", "F", "F#", "G", "G#", "A", "A#", "B" ] self.octave = tk.IntVar() self.octave.set(4) # Note selection self.noteList = tk.Listbox(self.frame, height=15, bd=4, selectborderwidth=1) for note in self.notes: self.noteList.insert("end", note) # Octave selection self.octaveScale = tk.Scale(self.frame, variable=self.octave, label="Octave", orient="vertical", length=350, from_=from_, to=to, tickinterval=1) # Generate Button self.generateButton = tk.Button(self.frame, text="Generate") # Play Button self.playButton = tk.Button(self.frame, text="Play note", bg="light sky blue") self.playChordButton = tk.Button(self.frame, text="Play chord", bg="light sky blue") # Chords prepate self.addToChord = tk.Button(self.frame, text="Add to chord => ") self.chordPrepareListbox = tk.Listbox(self.frame, height=5, bd=4, selectborderwidth=1) # Generate chord self.generateChord = tk.Button(self.frame, text="Generate chord") # Chords selection self.chordsSelection = tk.Listbox(self.frame, height=15, bd=4, selectborderwidth=1)
def __init__(self,parent,subject,bg="white"): print("View : __init__") Observer.__init__(self) self.subject=subject self.parent=parent self.signal_id=None self.canvas=Canvas(parent,bg=bg) self.canvas.bind("<Configure>", self.resize) self.width=int(self.canvas.cget("width")) self.height=int(self.canvas.cget("height"))
def __init__(self): Observer.__init__(self) self.__observers = [] # keys are properties names, values are pairs (bool, methods) # inside the observer. bool is True for custom observing # methods, False otherwise self.__value_notifications = {} self.__instance_notif_before = {} self.__instance_notif_after = {} self.__signal_notif = {} for key in self.get_properties(): self.register_property(key) return
def __init__(self, logger, spectrumId, pdata, dataSource, reference): Observer.__init__(self, logger) self.logger = logger self.id = spectrumId self.pdata = pdata self.dataSource = dataSource reference.addObserver(lambda n: referenceObserver(self, n)) self.sources = dict() self.sources['integration'] = ColumnDataSource( data=dict(x=[], y=[], width=[], height=[])) self.initIntegral = None
def __init__(self, logger, spectrumId, dic, udic, pdata, dataSource, reference): Observer.__init__(self, logger) self.logger = logger self.id = spectrumId self.dic = dic self.udic = udic self.pdata = pdata self.mpdata = np.array(map(lambda x: -x, pdata)) self.dataSource = dataSource reference.addObserver(lambda n: referenceObserver(self, n)) self.sources = dict() self.sources['peaks'] = ColumnDataSource(data=dict(x=[], y=[]))
def __init__(self, agents): """ This class is used to setup, run and log the results of an experiment. """ Observer.__init__(self) for ag in agents: for topic in ["motor", "presence", "td_error", "activation", "weights", "reward", "aud_act", "amp"]: ag.subscribe(topic, self) self.ags = agents self.n_ag = len(agents) self.log = [defaultdict(list) for _ in range(self.n_ag)] self.eval_at = [] self._running = threading.Event()
def __init__(self): Observer.__init__(self) self.__observers = [] # keys are properties names, values are pairs (method, # kwargs|None) inside the observer. kwargs is the keyword # argument possibly specified when explicitly defining the # notification method in observers, and it is used to build # the NTInfo instance passed down when the notification method # is invoked. If kwargs is None (special case), the # notification method is "old style" (property_<name>_...) and # won't be receiving the property name. self.__value_notifications = {} self.__instance_notif_before = {} self.__instance_notif_after = {} self.__signal_notif = {} for key in self.get_properties(): self.register_property(key) return
def __init__(self, model, spurious=False): Observer.__init__(self, model, spurious) self.view = None self.__adapters = [] return
def __init__(self): Observer.__init__(self) # Observer's init needs to be called self.__serial_port.port = "" self.__serial_port.baudrate = 576000 self.__serial_port.timeout = 0.1
def __init__(self): Observer.__init__(self) # Observer's init needs to be called
def __init__(self, webSocketHandler): Observer.__init__(self) self.handler = webSocketHandler
def __init__(self, model: NoteModel, view: NoteConsoleView) -> None: Observer.__init__(self) self.model = model self.load_notebooks() self.view = view self.view.attach(self)